]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add o_stream_get_disconnect_reason()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Mar 2021 13:07:56 +0000 (15:07 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
src/lib/ostream.c
src/lib/ostream.h

index 8c1394b9bd388ffa0870e8973d705eadc6259a17..acfa527d1f29ded633bf16f772d2cc70e86db5c7 100644 (file)
@@ -43,6 +43,11 @@ const char *o_stream_get_error(struct ostream *stream)
        return strerror(stream->stream_errno);
 }
 
+const char *o_stream_get_disconnect_reason(struct ostream *stream)
+{
+       return io_stream_get_disconnect_reason(NULL, stream);
+}
+
 static void o_stream_close_full(struct ostream *stream, bool close_parents)
 {
        /* Ideally o_stream_finish() would be called for all non-failed
index a43e8043ada56c6a8d824a186b0a5e4529add667..2063847ca0db37e3647587aa611e17b172dff24e 100644 (file)
@@ -94,6 +94,12 @@ const char *o_stream_get_name(struct ostream *stream);
 int o_stream_get_fd(struct ostream *stream);
 /* Returns error string for the previous error. */
 const char *o_stream_get_error(struct ostream *stream);
+/* Returns human-readable reason for why ostream was disconnected.
+   The output is either "Connection closed" for clean disconnections or
+   "Connection closed: <error>" for unclean disconnections. This is an
+   alternative to o_stream_get_error(), which is preferred to be used when
+   logging errors about client connections. */
+const char *o_stream_get_disconnect_reason(struct ostream *stream);
 
 /* Close this stream (but not its parents) and unreference it. */
 void o_stream_destroy(struct ostream **stream);