]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Fix logging disconnection error reasons
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 28 Nov 2017 17:01:19 +0000 (19:01 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 28 Nov 2017 18:29:57 +0000 (20:29 +0200)
The previous commit set errno=0, which weren't logged. If error string is
provided, it doesn't matter what the errno is set (as long as it's not 0),
so we'll just use EINVAL.

src/director/director-connection.c

index 4e3e6ed032ea62400b61f86e3b38634a7b41e627..47f6f110f3eb994b5c5543c5981feecb48db304d 100644 (file)
@@ -2239,7 +2239,7 @@ static int director_connection_output(struct director_connection *conn)
                ret = director_connection_send_users(conn);
                o_stream_uncork(conn->output);
                if (ret < 0) {
-                       director_connection_log_disconnect(conn, 0,
+                       director_connection_log_disconnect(conn, conn->output->stream_errno,
                                o_stream_get_error(conn->output));
                        director_connection_disconnected(&conn,
                                o_stream_get_error(conn->output));
@@ -2532,13 +2532,14 @@ void director_connection_send(struct director_connection *conn,
        ret = o_stream_send(conn->output, data, len);
        if (ret != (off_t)len) {
                if (ret < 0) {
-                       director_connection_log_disconnect(conn, 0, t_strdup_printf(
-                               "write() failed: %s",
-                               o_stream_get_error(conn->output)));
+                       director_connection_log_disconnect(conn,
+                               conn->output->stream_errno,
+                               t_strdup_printf("write() failed: %s",
+                                       o_stream_get_error(conn->output)));
                } else {
-                       director_connection_log_disconnect(conn, 0, t_strdup_printf(
-                               "Output buffer full at %zu",
-                               o_stream_get_buffer_used_size(conn->output)));
+                       director_connection_log_disconnect(conn, EINVAL,
+                               t_strdup_printf("Output buffer full at %zu",
+                                       o_stream_get_buffer_used_size(conn->output)));
                }
                o_stream_close(conn->output);
                /* closing the stream when output buffer is full doesn't cause
@@ -2565,7 +2566,7 @@ director_connection_ping_idle_timeout(struct director_connection *conn)
        str_printfa(str, "Ping timed out in %u.%03u secs: ",
                    diff/1000, diff%1000);
        director_ping_append_extra(conn, str, 0, (uintmax_t)-1);
-       director_connection_log_disconnect(conn, 0, str_c(str));
+       director_connection_log_disconnect(conn, EINVAL, str_c(str));
        director_connection_disconnected(&conn, "Ping timeout");
 }
 
@@ -2578,7 +2579,7 @@ static void director_connection_pong_timeout(struct director_connection *conn)
                "PONG reply not received in %u.%03u secs, "
                "although other input keeps coming",
                diff/1000, diff%1000);
-       director_connection_log_disconnect(conn, 0, errstr);
+       director_connection_log_disconnect(conn, EINVAL, errstr);
        director_connection_disconnected(&conn, "Pong timeout");
 }