Mercurial > dovecot > core-2.2
comparison src/director/director-connection.c @ 22693:a11fd794807e
director: Log connection stats for all types of disconnections
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 28 Nov 2017 15:06:27 +0200 |
parents | 281472b3bb20 |
children | 2cf68aa64129 |
comparison
equal
deleted
inserted
replaced
22692:281472b3bb20 | 22693:a11fd794807e |
---|---|
2237 /* still handshaking USER list */ | 2237 /* still handshaking USER list */ |
2238 o_stream_cork(conn->output); | 2238 o_stream_cork(conn->output); |
2239 ret = director_connection_send_users(conn); | 2239 ret = director_connection_send_users(conn); |
2240 o_stream_uncork(conn->output); | 2240 o_stream_uncork(conn->output); |
2241 if (ret < 0) { | 2241 if (ret < 0) { |
2242 director_connection_log_disconnect(conn, 0, | |
2243 o_stream_get_error(conn->output)); | |
2242 director_connection_disconnected(&conn, | 2244 director_connection_disconnected(&conn, |
2243 o_stream_get_error(conn->output)); | 2245 o_stream_get_error(conn->output)); |
2244 } else { | 2246 } else { |
2245 o_stream_set_flush_pending(conn->output, TRUE); | 2247 o_stream_set_flush_pending(conn->output, TRUE); |
2246 } | 2248 } |
2528 dir_debug("output: %s: %s", conn->name, *lines); | 2530 dir_debug("output: %s: %s", conn->name, *lines); |
2529 } T_END; | 2531 } T_END; |
2530 ret = o_stream_send(conn->output, data, len); | 2532 ret = o_stream_send(conn->output, data, len); |
2531 if (ret != (off_t)len) { | 2533 if (ret != (off_t)len) { |
2532 if (ret < 0) { | 2534 if (ret < 0) { |
2533 i_error("director(%s): write() failed: %s", conn->name, | 2535 director_connection_log_disconnect(conn, 0, t_strdup_printf( |
2534 o_stream_get_error(conn->output)); | 2536 "write() failed: %s", |
2537 o_stream_get_error(conn->output))); | |
2535 } else { | 2538 } else { |
2536 i_error("director(%s): Output buffer full, " | 2539 director_connection_log_disconnect(conn, 0, t_strdup_printf( |
2537 "disconnecting", conn->name); | 2540 "Output buffer full at %zu", |
2541 o_stream_get_buffer_used_size(conn->output))); | |
2538 } | 2542 } |
2539 o_stream_close(conn->output); | 2543 o_stream_close(conn->output); |
2540 /* closing the stream when output buffer is full doesn't cause | 2544 /* closing the stream when output buffer is full doesn't cause |
2541 disconnection itself. */ | 2545 disconnection itself. */ |
2542 if (conn->to_disconnect != NULL) | 2546 if (conn->to_disconnect != NULL) |
2556 director_connection_ping_idle_timeout(struct director_connection *conn) | 2560 director_connection_ping_idle_timeout(struct director_connection *conn) |
2557 { | 2561 { |
2558 string_t *str = t_str_new(128); | 2562 string_t *str = t_str_new(128); |
2559 int diff = timeval_diff_msecs(&ioloop_timeval, &conn->ping_sent_time); | 2563 int diff = timeval_diff_msecs(&ioloop_timeval, &conn->ping_sent_time); |
2560 | 2564 |
2561 str_printfa(str, "Ping timed out in %u.%03u secs, disconnecting (", | 2565 str_printfa(str, "Ping timed out in %u.%03u secs: ", |
2562 diff/1000, diff%1000); | 2566 diff/1000, diff%1000); |
2563 director_ping_append_extra(conn, str, 0, (uintmax_t)-1); | 2567 director_ping_append_extra(conn, str, 0, (uintmax_t)-1); |
2564 str_append(str, ", "); | 2568 director_connection_log_disconnect(conn, 0, str_c(str)); |
2565 director_connection_append_stats(conn, str); | |
2566 if (conn->handshake_received) | |
2567 str_append(str, ", handshaked"); | |
2568 if (conn->synced) | |
2569 str_append(str, ", synced"); | |
2570 str_append_c(str, ')'); | |
2571 i_error("director(%s): %s", conn->name, str_c(str)); | |
2572 director_connection_disconnected(&conn, "Ping timeout"); | 2569 director_connection_disconnected(&conn, "Ping timeout"); |
2573 } | 2570 } |
2574 | 2571 |
2575 static void director_connection_pong_timeout(struct director_connection *conn) | 2572 static void director_connection_pong_timeout(struct director_connection *conn) |
2576 { | 2573 { |
2577 int diff = timeval_diff_msecs(&ioloop_timeval, &conn->ping_sent_time); | 2574 int diff = timeval_diff_msecs(&ioloop_timeval, &conn->ping_sent_time); |
2578 | 2575 const char *errstr; |
2579 i_error("director(%s): PONG reply not received in %u.%03u secs, " | 2576 |
2580 "although other input keeps coming, disconnecting", conn->name, | 2577 errstr = t_strdup_printf( |
2578 "PONG reply not received in %u.%03u secs, " | |
2579 "although other input keeps coming", | |
2581 diff/1000, diff%1000); | 2580 diff/1000, diff%1000); |
2581 director_connection_log_disconnect(conn, 0, errstr); | |
2582 director_connection_disconnected(&conn, "Pong timeout"); | 2582 director_connection_disconnected(&conn, "Pong timeout"); |
2583 } | 2583 } |
2584 | 2584 |
2585 void director_connection_ping(struct director_connection *conn) | 2585 void director_connection_ping(struct director_connection *conn) |
2586 { | 2586 { |