Commit Graph

64 Commits

Author SHA1 Message Date
Rob Landers
d532772355 fix: reset sapi response code (#964)
* fix: reset sapi response code
It turns out that the sapi response code is NOT reset between requests by the zend engine. This resets the code for cgi-based requests.
fixes: #960

* update response header test

* fix assertion

* appears to affect workers too
2024-08-11 22:34:50 +02:00
Rob Landers
fb23c64632 perf: cgi-mode 1700% improvement (#933)
* major perf

* clean up before thread returns

* fix lint

* clean up and refactor server-context initialization

* removing the request-startup memset
I'm electing to remove the memset at startup and keeping it in shutdown. Why? Security! Keeping around the request data after a request may result in a leak of important information in a core dump or something. By setting it to zero when we shutdown the request, we can ensure no information is left laying around
2024-07-26 09:22:08 +02:00
Kévin Dunglas
0500ebc191 perf: improve PHP thread management (#898) 2024-07-09 09:39:03 +02:00
Kévin Dunglas
8ff6cfdda8 refactor: prevent a useless allocation (#895)
* refactor: prevent a useless allocation

* cs
2024-06-28 16:46:34 +02:00
Kévin Dunglas
d6d1b2731c feat: add support for max_input_time in worker mode (#874) 2024-06-18 12:00:01 +02:00
Kévin Dunglas
c4aba6be02 chore: uniformize C comment style 2024-06-09 12:13:15 +02:00
Kévin Dunglas
4537f27f67 fix: prevent crash when worker terminates after a file upload 2024-06-08 13:36:32 +02:00
Kévin Dunglas
3714fdf3a1 fix: superglobals-realated crash with custom extensions in worker mode (#796)
* test: failing test reproducing #767

* fix

* Update frankenphp.c

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

* Update frankenphp.c

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

* review

* ZVAL_COPY

* fix

* add back current $_SERVER behavior

* add docs

* bad fix for the leak

* clean test

* improve tests

* fix test

* fix

* cleanup

* clarify destroy super globals name

* micro-optim: use zval_ptr_dtor_nogc to destroy super globals

* style

* fix

* better name for frankenphp_free_server_context

* more cleanup

* remove useless memset

* more cleanup

* continue refactoring

* fix and update docs

* docs

---------

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2024-06-05 15:24:16 +02:00
Kévin Dunglas
b18a079eb9 perf: hint the number of threads to TSRM (#655)
* perf: hint the number of threads to TSRM

* fix: PHP 8.2 compat
2024-03-13 18:28:07 +01:00
Kévin Dunglas
71661c45e2 fix: crash when a write error occurs (#651) 2024-03-13 17:57:23 +01:00
Kévin Dunglas
07a74e5c5a perf: reduce allocs when creating $_SERVER (#540)
* perf: reduce allocs when creating $_SERVER

* improve

* refactor: prevent C allocs when populating $_SERVER

* cs

* remove append()

* simplify

* wip

* cleanup

* add cache

* cleanup otter init

* some fixes

* cleanup

* test with a leak

* remove const?

* add const

* wip

* wip

* allocate dynamic variables in Go memory

* cleanup

* typo

* bump otter

* chore: bump deps
2024-03-12 18:31:30 +01:00
Kévin Dunglas
b71dae9b03 fix: prevent crash when calling apache_request_headers() in non-HTTP context 2024-02-27 17:51:10 +01:00
Kévin Dunglas
241ca55d7a feat: automatically import environment variables in $_SERVER 2024-02-03 12:25:18 +01:00
Kévin Dunglas
fe7e9e7c79 fix: crash when using apache_request_headers() (#536)
* fix: potential crash when using apache_request_headers()

* refactor: better apache_request_headers
2024-02-01 10:00:11 +01:00
Kévin Dunglas
5a8e5f9518 feat: add apache_response_headers() function (#530) 2024-01-31 12:34:30 +01:00
Kévin Dunglas
49baf02035 feat: add go_apache_request_headers() 2024-01-23 23:14:24 +01:00
Rob Landers
2055142904 apply just an optimization (#450) 2023-12-30 11:21:21 +01:00
Kévin Dunglas
517e086786 fix: random crashes when reloading (#394) 2023-12-18 09:05:49 +01:00
Kévin Dunglas
ebcd937092 fix: skip shebang in CLI mode 2023-12-17 14:40:20 +01:00
Kévin Dunglas
c9bf9940d1 ci: add Super-Linter (#323) 2023-12-01 17:26:21 +01:00
Kévin Dunglas
b4aa8038ff feat: detect when worker crashes or terminates normally (#315) 2023-11-21 23:15:07 +01:00
Kévin Dunglas
2c583bcb16 feat: add support for input filters 2023-11-16 15:14:54 +01:00
Kévin Dunglas
aa1d968dcf refactor: faster $_SERVER variables creation 2023-11-16 14:40:52 +01:00
Kévin Dunglas
c615fe0087 feat: add experimental CLI support (#239)
* feat: add CLI support

* updated

* debug

* fix tests

* Caddy php-cli command

* use thread

* $_SERVER and input streams support

* Update frankenphp.c

Co-authored-by: Francis Lavoie <lavofr@gmail.com>

---------

Co-authored-by: Francis Lavoie <lavofr@gmail.com>
2023-10-09 14:38:15 +02:00
Kévin Dunglas
09b2282441 feat: set SAPI version 2023-09-16 13:55:41 +02:00
Kévin Dunglas
fb63099a88 feat: allow passing env vars to workers (#210) 2023-09-15 12:59:43 +02:00
Kévin Dunglas
f5b599bc2b fix: superfluous response.WriteHeader call 2023-08-24 12:23:59 +02:00
Kévin Dunglas
65e34172e9 style: minor C style improvements 2023-08-18 21:31:41 +02:00
Kévin Dunglas
ab0783519e perf: reduce the number of calls to cgo to set the headers 2023-08-18 19:20:32 +02:00
Kévin Dunglas
70110dcc77 ci: Docker images for various PHP versions
Also adds semver support.
2023-07-17 10:18:33 +02:00
Kévin Dunglas
95e83a280e feat: compatibility with PHP 8.3 2023-07-04 17:22:29 +02:00
Kévin Dunglas
75cd310292 feat: add support for PHP timeouts on Linux (#128) 2023-03-05 15:47:20 +01:00
Kévin Dunglas
8e824a7906 perf: remove an extra call to cgo (#117) 2022-11-28 18:06:37 +01:00
Kévin Dunglas
878a30d92f fix: ensure there is always a free thread for non-worker scripts (#105) 2022-11-14 22:45:51 +01:00
Kévin Dunglas
6a6dda5ed9 feat: expose PHP version (#102) 2022-11-12 14:48:10 +01:00
Jockos
f0b2eb7445 feat: improve of performance of PHP variables registration (#94)
* feat: enhance php register variables

* apply comments

* fix errors

* improve benchmark

* remove debug statement

* use defer

* don't use defer in a loop

Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
2022-11-10 14:03:50 +01:00
Rob Landers
3abda4fbb6 feat: handle aborted connection (#95)
* Handle aborted connection

* Handle when writing as well

* return bytes written

* optimize return

* remove goroutine

* fix style

* Add tests

* add missing newline
2022-11-09 15:09:45 +01:00
Kévin Dunglas
8e136d0d25 feat: implement flush() (#90)
* feat: implement flush()

* add tests
2022-11-09 00:56:00 +01:00
Rob Landers
9ef3bd7c47 feat: add fastcgi_finish_request() support (#69)
* Add function to ext

* buggy af, but kinda working

* Get worker and regular mode working

* fix formatting

* add eol

* add eol

* 🤦

* properly generate file

* use sync.Once
2022-11-03 08:36:47 +01:00
Joe Watkins
3f4ad4ee66 fix: crash on macOS (#81)
* nogc variants

* don't duplicate dtor, cleanup track vars with memset

* even cleaner
2022-11-01 09:31:56 +01:00
Joe Watkins
213a0dfa55 fix: memory leak in worker mode (#76)
* fix #50

* clearer

* only clean globals from symbol table

* use opt, avoid reading uninitialized COUNTED
2022-11-01 01:17:48 +01:00
Kévin Dunglas
13fb0beae9 fix: remove some more memory leaks in worker mode (#65)
* refactor: worker mode

* chore: small cleanup

* fix: remove some more memory leaks in worker mode
2022-10-24 20:38:09 +02:00
Kévin Dunglas
d339c6902f ci: fix Docker Push (#60) 2022-10-23 16:47:00 +02:00
Kévin Dunglas
c4c8319042 fix: memory leak in worker mode (#56)
* fix: memory leak in worker mode

* fix tests
2022-10-23 10:18:52 +02:00
Kévin Dunglas
084decfe97 feat: remove automatic exceptions handling (#53) 2022-10-21 17:40:31 +02:00
Kévin Dunglas
1e453036b2 fix: signals handling (#39) 2022-10-19 11:19:49 +02:00
Kévin Dunglas
acc48830f7 feat: improve Dockerfile and add some docs (#15) 2022-10-13 18:05:22 +02:00
Kévin Dunglas
5af6b10d1f feat: add support for 103 Early Hints (#12) 2022-10-11 17:40:12 +02:00
Kévin Dunglas
46ec897d2e feat: add stub PHP functions (#10) 2022-10-11 08:57:23 +02:00
Kévin Dunglas
7ec0043fe8 feat: handle errors in worker mode (#9)
* feat: handle errors in worker mode (not working)

* feat: better exception and error handling
2022-10-11 08:10:46 +02:00