Skip to content

Commit 1233f18

Browse files
committed
Fix flush splitting
1 parent 8e34059 commit 1233f18

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

sapi/fpm/fpm/fpm_stdio.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
122122
struct fpm_child_s *child;
123123
int is_stdout;
124124
struct fpm_event_s *event;
125-
int in_buf = 0, pos, start;
125+
int in_buf = 0, cmd_pos = 0, pos, start;
126126
int read_fail = 0, create_log_stream;
127127
struct zlog_stream *log_stream;
128128

@@ -152,6 +152,7 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
152152
}
153153

154154
while (1) {
155+
stdio_read:
155156
in_buf = read(fd, buf, max_buf_size - 1);
156157
if (in_buf <= 0) { /* no data */
157158
if (in_buf == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
@@ -160,21 +161,33 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
160161
}
161162
break;
162163
}
163-
164-
for (start = 0, pos = 0; pos < in_buf; pos++) {
164+
start = 0;
165+
if (cmd_pos > 0) {
166+
if (!memcmp(buf, &FPM_STDIO_CMD_FLUSH[cmd_pos], sizeof(FPM_STDIO_CMD_FLUSH) - cmd_pos)) {
167+
zlog_stream_finish(log_stream);
168+
start = cmd_pos;
169+
}
170+
cmd_pos = 0;
171+
}
172+
for (pos = 0; pos < in_buf; pos++) {
165173
switch (buf[pos]) {
166174
case '\n':
167175
zlog_stream_str(log_stream, buf + start, pos - start);
168176
zlog_stream_finish(log_stream);
169177
start = pos + 1;
170178
break;
171179
case '\0':
172-
if (pos + sizeof(FPM_STDIO_CMD_FLUSH) <= in_buf &&
173-
!memcmp(buf + pos, FPM_STDIO_CMD_FLUSH, sizeof(FPM_STDIO_CMD_FLUSH))) {
180+
if (pos + sizeof(FPM_STDIO_CMD_FLUSH) <= in_buf) {
181+
if (!memcmp(buf + pos, FPM_STDIO_CMD_FLUSH, sizeof(FPM_STDIO_CMD_FLUSH))) {
182+
zlog_stream_str(log_stream, buf + start, pos - start);
183+
zlog_stream_finish(log_stream);
184+
start = pos + sizeof(FPM_STDIO_CMD_FLUSH);
185+
pos = start - 1;
186+
}
187+
} else if (!memcmp(buf + pos, FPM_STDIO_CMD_FLUSH, in_buf - pos)) {
188+
cmd_pos = in_buf - pos;
174189
zlog_stream_str(log_stream, buf + start, pos - start);
175-
zlog_stream_finish(log_stream);
176-
start = pos + sizeof(FPM_STDIO_CMD_FLUSH);
177-
pos = start - 1;
190+
goto stdio_read;
178191
}
179192
break;
180193
}

sapi/fpm/tests/log-bwp-msg-flush-split.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,3 @@ Done
4444
require_once "tester.inc";
4545
FPM\Tester::clean();
4646
?>
47-
--XFAIL--
48-
Split flush not implemented yet

0 commit comments

Comments
 (0)