X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fverbose.c;h=3e266a18663c2c4e1c71617fa46e94c877bf253f;hb=cab05ba72abeb335b456b0820e053c94b91986e7;hp=f330c6f5f590736efcb02b13d828706365112b81;hpb=8be63ed03413ee79bb3aa3900950f695eb511960;p=src%2Fapp-framework-binder.git diff --git a/src/verbose.c b/src/verbose.c index f330c6f5..3e266a18 100644 --- a/src/verbose.c +++ b/src/verbose.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2016, 2017 "IoT.bzh" + Copyright (C) 2016, 2017, 2018 "IoT.bzh" author: José Bollo @@ -85,6 +85,7 @@ void verbose_set_name(const char *name, int authority) #include #include #include +#include static const char *appname; @@ -105,6 +106,8 @@ static int tty; static const char chars[] = { '\n', '?', ':', ' ', '[', ',', ']' }; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + static void _vverbose_(int loglevel, const char *file, int line, const char *function, const char *fmt, va_list args) { char buffer[4000]; @@ -169,7 +172,9 @@ static void _vverbose_(int loglevel, const char *file, int line, const char *fun iov[n].iov_base = (void*)&chars[0]; iov[n++].iov_len = 1; + pthread_mutex_lock(&mutex); writev(STDERR_FILENO, iov, n); + pthread_mutex_unlock(&mutex); errno = saverr; }