summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-04-08 13:12:10 +0200
committerantirez <antirez@gmail.com>2019-04-30 15:16:07 +0200
commit45167c56de0d2af780403bd5c806eda6e15ed7a3 (patch)
tree4f3dd84e56892f56e81936a33dc3c25d13b6b330
parent9f052b368616036c1666d642a2dfcefadfaf87b3 (diff)
downloadredis-45167c56de0d2af780403bd5c806eda6e15ed7a3.tar.gz
Threaded IO: logging should be safe in I/O threads.
Potentially it is possible that we get interleaved writes, even if serverLog() makes sure to write into a buffer and then use printf(), so even this should be ok. However in general POSIX guarantees that writing to the same file pointer object from multiple threads is safe. Anyway currently we *reopen* the file at each call, but for the standard output logging. The logging functions actually also access global configuration while performing the log (for instance in order to check the log level, the log filename and so forth), however dunring the I/O threads execution we cannot alter such shared state in any way.
-rw-r--r--src/networking.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c
index 29a56e983..0e11e1f3f 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1174,14 +1174,13 @@ int writeToClient(int fd, client *c, int handler_installed) {
zmalloc_used_memory() < server.maxmemory) &&
!(c->flags & CLIENT_SLAVE)) break;
}
- /* FIXME: Fixme, use atomic var for this. */
server.stat_net_output_bytes += totwritten;
if (nwritten == -1) {
if (errno == EAGAIN) {
nwritten = 0;
} else {
- // serverLog(LL_VERBOSE,
- // "Error writing to client: %s", strerror(errno));
+ serverLog(LL_VERBOSE,
+ "Error writing to client: %s", strerror(errno));
freeClientAsync(c);
return C_ERR;
}