Skip to content

Commit

Permalink
update php to 8.1.27 [fpm]
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jan 16, 2024
1 parent 7a6319e commit 4bf55d4
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ tmp-php.ini
/pool/
/vendor
/thirdparty
/usr
/var
/ext/redis
/ext/memcached
/ext/imagick
Expand Down
34 changes: 31 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice.
dnl ----------------------------------------------------------------------------

AC_PREREQ([2.68])
AC_INIT([PHP],[8.1.12],[https://bugs.php.net],[php],[https://www.php.net])
AC_INIT([PHP],[8.1.27],[https://github.com/php/php-src/issues],[php],[https://www.php.net])
AC_CONFIG_SRCDIR([main/php_version.h])
AC_CONFIG_AUX_DIR([build])
AC_PRESERVE_HELP_ORDER
Expand Down Expand Up @@ -128,7 +128,9 @@ PKG_PROG_PKG_CONFIG
AC_PROG_CC([cc gcc])
PHP_DETECT_ICC
PHP_DETECT_SUNCC
AC_PROG_CC_C99

dnl AC_PROG_CC_C99 is obsolete with autoconf >= 2.70 yet necessary for <= 2.69.
m4_version_prereq([2.70],,[AC_PROG_CC_C99])
AC_PROG_CPP
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_LN_S
Expand Down Expand Up @@ -365,6 +367,12 @@ if test "$ac_cv_func_dlopen" = "yes"; then
fi
AC_CHECK_LIB(m, sin)

case $host_alias in
riscv64*)
PHP_CHECK_FUNC(__atomic_exchange_1, atomic)
;;
esac

dnl Check for inet_aton in -lc, -lbind and -lresolv.
PHP_CHECK_FUNC(inet_aton, resolv, bind)

Expand Down Expand Up @@ -611,6 +619,9 @@ nanosleep \
memmem \
)

dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
AC_FUNC_STRERROR_R

AX_FUNC_WHICH_GETHOSTBYNAME_R

dnl Some systems (like OpenSolaris) do not have nanosleep in libc.
Expand Down Expand Up @@ -1523,6 +1534,23 @@ if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [
CFLAGS="$CFLAGS -fsanitize=undefined"
CXXFLAGS="$CXXFLAGS -fsanitize=undefined"
dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be
dnl cast to void*. In that case, set -fno-sanitize=function.
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-sanitize-recover=undefined"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
void foo(char *string) {}
int main(void) {
void (*f)(void *) = (void (*)(void *))foo;
f("foo");
}
]])],,[ubsan_needs_no_function=yes],)
CFLAGS="$OLD_CFLAGS"
if test "$ubsan_needs_no_function" = yes; then
CFLAGS="$CFLAGS -fno-sanitize=function"
CXXFLAGS="$CFLAGS -fno-sanitize=function"
fi
], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
fi

Expand Down Expand Up @@ -1633,7 +1661,7 @@ PHP_ADD_SOURCES(Zend, \
zend_closures.c zend_weakrefs.c zend_float.c zend_string.c zend_signal.c zend_generators.c \
zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \
zend_default_classes.c zend_inheritance.c zend_smart_str.c zend_cpuinfo.c zend_gdb.c \
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c \
zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_max_execution_timer.c \
Optimizer/zend_optimizer.c \
Optimizer/pass1.c \
Optimizer/pass3.c \
Expand Down
8 changes: 7 additions & 1 deletion sapi/cli/fpm/events/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,20 @@ static int fpm_event_port_wait(struct fpm_event_queue_s *queue, unsigned long in
}

for (i = 0; i < nget; i++) {
struct fpm_event_s *ev;

/* do we have a ptr to the event ? */
if (!events[i].portev_user) {
continue;
}

ev = (struct fpm_event_s *)events[i].portev_user;

/* re-associate for next event */
fpm_event_port_add(ev);

/* fire the event */
fpm_event_fire((struct fpm_event_s *)events[i].portev_user);
fpm_event_fire(ev);

/* sanity check */
if (fpm_globals.parent_pid != getpid()) {
Expand Down
10 changes: 5 additions & 5 deletions sapi/cli/fpm/fpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct fpm_globals_s fpm_globals = {
.send_config_pipe = {0, 0},
};

int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr) /* {{{ */
enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr) /* {{{ */
{
fpm_globals.argc = argc;
fpm_globals.argv = argv;
Expand All @@ -67,22 +67,22 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int t
0 > fpm_event_init_main()) {

if (fpm_globals.test_successful) {
exit(FPM_EXIT_OK);
return FPM_INIT_EXIT_OK;
} else {
zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
return FPM_INIT_ERROR;
}
}

if (0 > fpm_conf_write_pid()) {
zlog(ZLOG_ERROR, "FPM initialization failed");
return -1;
return FPM_INIT_ERROR;
}

fpm_stdio_init_final();
zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);

return 0;
return FPM_INIT_CONTINUE;
}
/* }}} */

Expand Down
8 changes: 7 additions & 1 deletion sapi/cli/fpm/fpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@
#endif


enum fpm_init_return_status {
FPM_INIT_ERROR,
FPM_INIT_CONTINUE,
FPM_INIT_EXIT_OK,
};

int fpm_run(int *max_requests);
int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr);
enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr);

struct fpm_globals_s {
pid_t parent_pid;
Expand Down
31 changes: 28 additions & 3 deletions sapi/cli/fpm/fpm_children.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,27 @@ static void fpm_child_free(struct fpm_child_s *child) /* {{{ */
}
/* }}} */

static void fpm_postponed_child_free(struct fpm_event_s *ev, short which, void *arg)
{
struct fpm_child_s *child = (struct fpm_child_s *) arg;

if (child->fd_stdout != -1) {
fpm_event_del(&child->ev_stdout);
close(child->fd_stdout);
}
if (child->fd_stderr != -1) {
fpm_event_del(&child->ev_stderr);
close(child->fd_stderr);
}

fpm_child_free((struct fpm_child_s *) child);
}

static void fpm_child_close(struct fpm_child_s *child, int in_event_loop) /* {{{ */
{
if (child->fd_stdout != -1) {
if (in_event_loop) {
child->postponed_free = true;
fpm_event_fire(&child->ev_stdout);
}
if (child->fd_stdout != -1) {
Expand All @@ -76,14 +93,20 @@ static void fpm_child_close(struct fpm_child_s *child, int in_event_loop) /* {{{

if (child->fd_stderr != -1) {
if (in_event_loop) {
child->postponed_free = true;
fpm_event_fire(&child->ev_stderr);
}
if (child->fd_stderr != -1) {
close(child->fd_stderr);
}
}

fpm_child_free(child);
if (in_event_loop && child->postponed_free) {
fpm_event_set_timer(&child->ev_free, 0, &fpm_postponed_child_free, child);
fpm_event_add(&child->ev_free, 1000);
} else {
fpm_child_free(child);
}
}
/* }}} */

Expand Down Expand Up @@ -120,7 +143,7 @@ static void fpm_child_unlink(struct fpm_child_s *child) /* {{{ */
}
/* }}} */

static struct fpm_child_s *fpm_child_find(pid_t pid) /* {{{ */
struct fpm_child_s *fpm_child_find(pid_t pid) /* {{{ */
{
struct fpm_worker_pool_s *wp;
struct fpm_child_s *child = 0;
Expand Down Expand Up @@ -297,8 +320,10 @@ void fpm_children_bury(void)
break;
}
}
} else if (fpm_globals.parent_pid == 1) {
zlog(ZLOG_DEBUG, "unknown child (%d) exited %s - most likely an orphan process (master process is the init process)", pid, buf);
} else {
zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s. Please open a bug report (https://github.com/php/php-src/issues).", pid, buf);
zlog(ZLOG_WARNING, "unknown child (%d) exited %s - potentially a bug or pre exec child (e.g. s6-notifyoncheck)", pid, buf);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions sapi/cli/fpm/fpm_children.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@
#include "fpm_events.h"
#include "zlog.h"

struct fpm_child_s;

int fpm_children_create_initial(struct fpm_worker_pool_s *wp);
int fpm_children_free(struct fpm_child_s *child);
void fpm_children_bury(void);
int fpm_children_init_main(void);
int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug);

struct fpm_child_s;
struct fpm_child_s *fpm_child_find(pid_t pid);

struct fpm_child_s {
struct fpm_child_s *prev, *next;
struct timeval started;
struct fpm_worker_pool_s *wp;
struct fpm_event_s ev_stdout, ev_stderr;
struct fpm_event_s ev_stdout, ev_stderr, ev_free;
int shm_slot_i;
int fd_stdout, fd_stderr;
void (*tracer)(struct fpm_child_s *);
struct timeval slow_logged;
int idle_kill;
bool idle_kill;
bool postponed_free;
pid_t pid;
int scoreboard_i;
struct zlog_stream *log_stream;
Expand Down
2 changes: 1 addition & 1 deletion sapi/cli/fpm/fpm_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ static int fpm_conf_post_process(int force_daemon) /* {{{ */
fpm_evaluate_full_path(&fpm_global_config.error_log, NULL, PHP_LOCALSTATEDIR, 0);
}

if (0 > fpm_stdio_save_original_stderr()) {
if (!fpm_global_config.daemonize && 0 > fpm_stdio_save_original_stderr()) {
return -1;
}

Expand Down
25 changes: 25 additions & 0 deletions sapi/cli/fpm/fpm_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "fpm_env.h"
#include "fpm.h"
#include "fpm_cleanup.h"

#ifndef HAVE_SETPROCTITLE
#if defined(__linux__) || defined(__APPLE__)
Expand Down Expand Up @@ -194,6 +195,26 @@ static int fpm_env_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
}
/* }}} */


#ifndef HAVE_SETPROCTITLE
#if defined(__linux__) || defined(__APPLE__)
/* Frees our copied environment variables. */
static void fpm_env_cleanup(int which, void *arg) /* {{{ */
{
char** allocated_environ = environ;
if (allocated_environ) {
environ = NULL;
unsigned int i = 0;
while (allocated_environ[i]) {
free(allocated_environ[i]);
i++;
}
free(allocated_environ);
}
}
#endif
#endif

int fpm_env_init_main(void)
{
struct fpm_worker_pool_s *wp;
Expand Down Expand Up @@ -254,6 +275,10 @@ int fpm_env_init_main(void)
env_nb++;
}

if (0 > fpm_cleanup_add(FPM_CLEANUP_PARENT_EXIT_MAIN, fpm_env_cleanup, 0)) {
return -1;
}

if ((new_environ = malloc((1U + env_nb) * sizeof (char *))) == NULL) {
return -1;
}
Expand Down
Loading

0 comments on commit 4bf55d4

Please sign in to comment.