php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #65800
Patch fpm-solaris-event_ports revision 2015-09-20 08:18 UTC by rainer dot jung at kippdata dot de
Patch patch-sapi_fpm_fpm_events_port.c revision 2014-06-13 12:58 UTC by filip at hajny dot net

Patch fpm-solaris-event_ports for FPM related Bug #65800

Patch version 2015-09-20 08:18 UTC

Return to Bug #65800 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: rainer.jung@kippdata.de

--- sapi/fpm/fpm/events/port.c	2015-09-03 23:32:51.000000000 +0200
+++ sapi/fpm/fpm/events/port.c	2015-09-20 09:36:53.865300000 +0200
@@ -116,8 +116,10 @@
  */
 static int fpm_event_port_wait(struct fpm_event_queue_s *queue, unsigned long int timeout) /* {{{ */
 {
-	int ret, i, nget;
+	int ret;
+	unsigned int i, nget;
 	timespec_t t;
+	struct fpm_event_s *ev;
 
 	/* convert timeout into timespec_t */
 	t.tv_sec = (int)(timeout / 1000);
@@ -125,6 +127,8 @@
 
 	/* wait for inconming event or timeout. We want at least one event or timeout */
 	nget = 1;
+	events[0].portev_user = (void *)-1; /* so we can double check that an event was returned */
+
 	ret = port_getn(pfd, events, nevents, &nget, &t);
 	if (ret < 0) {
 
@@ -132,6 +136,16 @@
 		if (errno != EINTR && errno != ETIME) {
 			zlog(ZLOG_WARNING, "poll() returns %d", errno);
 			return -1;
+		} else if (nget > 0 && events[0].portev_user == (void *)-1) {
+			/* This confusing API can return an event at the same time
+			 * that it reports EINTR or ETIME.  If that occurs, just
+			 * report the event.  With EINTR, nget can be > 0 without
+			 * any event, so check that portev_user was filled in.
+			 *
+			 * See discussion thread
+			 *   http://marc.info/?l=opensolaris-networking-discuss&m=125071205204540
+			 */
+			nget = 0;
 		}
 	}
 
@@ -142,8 +156,13 @@
 			continue;
 		}
 
+		ev = (struct fpm_event_s *)events[i].portev_user;
+
+		/* TODO: Escalate an error? */
+		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()) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC