diff --git a/src/log.c b/src/log.c index ed45a73a1..b2e6231fa 100644 --- a/src/log.c +++ b/src/log.c @@ -1672,8 +1672,15 @@ send: iovec[7].iov_len = 1; if (logsrv->addr.ss_family == AF_UNSPEC) { - /* the target is a direct file descriptor */ + /* the target is a direct file descriptor. While writev() guarantees + * to write everything, it doesn't guarantee that it will not be + * interrupted while doing so. This occasionally results in interleaved + * messages when the output is a tty, hence the lock. There's no real + * performance concern here for such type of output. + */ + HA_SPIN_LOCK(LOGSRV_LOCK, &logsrv->lock); sent = writev(*plogfd, iovec, 8); + HA_SPIN_UNLOCK(LOGSRV_LOCK, &logsrv->lock); } else { msghdr.msg_name = (struct sockaddr *)&logsrv->addr;