Bug #72935 [Opn]: ONDEMAND: Race condition causes incoming connections hang

From: Date: Wed, 24 Aug 2016 21:56:26 +0000
Subject: Bug #72935 [Opn]: ONDEMAND: Race condition causes incoming connections hang
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203527@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72935&edit=1 ID: 72935 User updated by: nick at cpanel dot net Reported by: nick at cpanel dot net Summary: ONDEMAND: Race condition causes incoming connections hang Status: Open Type: Bug Package: FPM related Operating System: Linux PHP Version: 5.6.25 Block user comment: N Private report: N New Comment: I found a duplicate bug in the system after I submitted this. 69724 Previous Comments: ------------------------------------------------------------------------ [2016-08-24 20:12:59] nick at cpanel dot net Description: ------------ TLDR; If two clients connect to PHP-FPM in ondemand mode on the same unix socket before accept() happens in the child only one gets accept()ed. PHP-FPM uses epoll() on linux to detect when an incoming connection needs to be handled. With ONDEMAND, when the epoll() has an EPOLLIN event it triggers sapi/fpm/fpm/fpm_process_ctl.c.:fpm_pctl_on_socket_accept which will either spawn a child or rely on an idle child to do the accept() If a second connect() happens from another client before the first one is accept()ed the state will never change so the second client will hang until the the next state change on the listening socket. See: https://lkml.org/lkml/2011/11/17/234 sapi/fpm/fpm/fpm_children.c: fpm_event_set(wp->ondemand_event, wp->listening_socket, FPM_EV_READ | FPM_EV_EDGE, fpm_pctl_on_socket_accept, wp); sapi/fpm/fpm/events/epoll.c: if (ev->flags & FPM_EV_EDGE) { sapi/fpm/fpm/events/epoll.c- e.events = e.events | EPOLLET; sapi/fpm/fpm/events/epoll.c- } Expected result: ---------------- Both clients get accept()ed Actual result: -------------- The first client gets accept()ed and the second client hangs waiting for php-fpm to respond. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72935&edit=1

« previous php.bugs (#203527) next »