summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-04-08 13:12:10 +0200
committerantirez <antirez@gmail.com>2019-05-06 18:02:51 +0200
commit463ccf86642ae35e18cf0c84be4e8e9e7c905c70 (patch)
tree8b463074ecb51f893a43f3143fc9b1f33685464e
parent8d7d2be24fb74234603667e8da4de2d2f466aff1 (diff)
downloadredis-463ccf86642ae35e18cf0c84be4e8e9e7c905c70.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;
}