summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2015-06-14 06:14:43 +0200
committerFelix Fietkau <nbd@openwrt.org>2015-06-14 18:28:40 +0200
commit7df968175ffd3bc7df5682d5852fbf20fe454759 (patch)
treed2e022091a3497534a1504fa886ad2e1f30790f5
parent47462caa6346dd4c51ae4ba6061f124e94ecce7a (diff)
downloadunitd-7df968175ffd3bc7df5682d5852fbf20fe454759.tar
unitd-7df968175ffd3bc7df5682d5852fbf20fe454759.zip
service: optimize relaying stdio output of daemons a bit.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r--service/instance.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/service/instance.c b/service/instance.c
index 3367885..4ace40b 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -366,6 +366,10 @@ instance_stdio(struct ustream *s, int prio, struct service_instance *in)
char *newline, *str, *arg0, ident[32];
int len;
+ arg0 = basename(blobmsg_data(blobmsg_data(in->command)));
+ snprintf(ident, sizeof(ident), "%s[%d]", arg0, in->proc.pid);
+ ulog_open(ULOG_SYSLOG, LOG_DAEMON, ident);
+
do {
str = ustream_get_read_buf(s, NULL);
if (!str)
@@ -376,17 +380,13 @@ instance_stdio(struct ustream *s, int prio, struct service_instance *in)
break;
*newline = 0;
- len = newline + 1 - str;
-
- arg0 = basename(blobmsg_data(blobmsg_data(in->command)));
- snprintf(ident, sizeof(ident), "%s[%d]", arg0, in->proc.pid);
-
- ulog_open(ULOG_SYSLOG, LOG_DAEMON, ident);
ulog(prio, "%s\n", str);
- ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd");
+ len = newline + 1 - str;
ustream_consume(s, len);
} while (1);
+
+ ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd");
}
static void