Skip to content

Commit 04078a5

Browse files
psumberakrakjoe
authored andcommitted
php-fpm: fix Solaris port events.mechanism
Bug #65800 Fix by: rainer.jung@kippdata.de
1 parent 57918b1 commit 04078a5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ PHP NEWS
1111
(cmb)
1212
. Fixed bug #80972 (Memory exhaustion on invalid string offset). (girgias)
1313

14+
- FPM:
15+
. Fixed bug #65800 (Events port mechanism). (psumbera)
16+
1417
- FTP:
1518
. Fixed bug #80901 (Info leak in ftp extension). (cmb)
1619
. Fixed bug #79100 (Wrong FTP error messages). (cmb)

sapi/fpm/fpm/events/port.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ static int fpm_event_port_clean() /* {{{ */
114114
*/
115115
static int fpm_event_port_wait(struct fpm_event_queue_s *queue, unsigned long int timeout) /* {{{ */
116116
{
117-
int ret, i, nget;
117+
int ret
118+
unsigned int i, nget;
118119
timespec_t t;
119120

120121
/* convert timeout into timespec_t */
@@ -123,13 +124,25 @@ static int fpm_event_port_wait(struct fpm_event_queue_s *queue, unsigned long in
123124

124125
/* wait for inconming event or timeout. We want at least one event or timeout */
125126
nget = 1;
127+
events[0].portev_user = (void *)-1; /* so we can double check that an event was returned */
128+
126129
ret = port_getn(pfd, events, nevents, &nget, &t);
127130
if (ret < 0) {
128131

129132
/* trigger error unless signal interrupt or timeout */
130133
if (errno != EINTR && errno != ETIME) {
131134
zlog(ZLOG_WARNING, "poll() returns %d", errno);
132135
return -1;
136+
} else if (nget > 0 && events[0].portev_user == (void *)-1) {
137+
/* This confusing API can return an event at the same time
138+
* that it reports EINTR or ETIME. If that occurs, just
139+
* report the event. With EINTR, nget can be > 0 without
140+
* any event, so check that portev_user was filled in.
141+
*
142+
* See discussion thread
143+
* http://marc.info/?l=opensolaris-networking-discuss&m=125071205204540
144+
*/
145+
nget = 0;
133146
}
134147
}
135148

0 commit comments

Comments
 (0)