Skip to content

Commit dd8a7e6

Browse files
committed
Add initial port of stdio to use zlog_stream
1 parent a5887f9 commit dd8a7e6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

sapi/fpm/fpm/fpm_stdio.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
122122
int is_stdout;
123123
struct fpm_event_s *event;
124124
int fifo_in = 1, fifo_out = 1;
125-
int is_last_message = 0;
126125
int in_buf = 0;
127126
int res;
127+
int init_stream_prefix_and_suffix = 1;
128+
struct zlog_stream stream;
128129

129130
if (!arg) {
130131
return;
@@ -137,6 +138,8 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
137138
event = &child->ev_stderr;
138139
}
139140

141+
zlog_stream_init_for_stdio(&stream, ZLOG_WARNING, STDERR_FILENO);
142+
140143
while (fifo_in || fifo_out) {
141144
if (fifo_in) {
142145
res = read(fd, buf + in_buf, max_buf_size - 1 - in_buf);
@@ -151,7 +154,6 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
151154
}
152155

153156
fpm_event_del(event);
154-
is_last_message = 1;
155157

156158
if (is_stdout) {
157159
close(child->fd_stdout);
@@ -193,8 +195,13 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
193195
*nl = '\0';
194196
}
195197

196-
zlog(ZLOG_WARNING, "[pool %s] child %d said into %s: \"%s\"%s", child->wp->config->name,
197-
(int) child->pid, is_stdout ? "stdout" : "stderr", buf, is_last_message ? ", pipe is closed" : "");
198+
if (init_stream_prefix_and_suffix) {
199+
zlog_stream_set_wrapping_prefix(&stream, "[pool %s] child %d said into %s: \"",
200+
child->wp->config->name, (int) child->pid, is_stdout ? "stdout" : "stderr");
201+
zlog_stream_set_wrapping_suffix(&stream, "\"", ", pipe is closed");
202+
init_stream_prefix_and_suffix = 0;
203+
}
204+
zlog_stream_str(&stream, buf, strlen(buf));
198205

199206
if (nl) {
200207
int out_buf = 1 + nl - buf;
@@ -207,6 +214,8 @@ static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg)
207214
}
208215
}
209216
}
217+
zlog_stream_finish(&stream);
218+
zlog_stream_destroy(&stream);
210219
}
211220
/* }}} */
212221

0 commit comments

Comments
 (0)