This standardizes the disconnection log message.
In most places we don't have to check for this explicitly,
but login_proxy_detach() attempts to get and use the
istream's fd, which is now -1. */
- client_destroy(client, "Disconnected");
+ client_destroy_iostream_error(client);
return;
}
size_t i, size, len;
if (i_stream_read_more(client->input, &data, &size) == -1) {
- client_destroy(client, "Disconnected");
+ client_destroy_iostream_error(client);
return -1;
}
#include "llist.h"
#include "istream.h"
#include "ostream.h"
+#include "iostream.h"
#include "iostream-ssl.h"
#include "iostream-proxy.h"
#include "iostream-rawlog.h"
login_refresh_proctitle();
}
+void client_destroy_iostream_error(struct client *client)
+{
+ const char *reason =
+ io_stream_get_disconnect_reason(client->input, client->output);
+ client_destroy(client, reason);
+}
+
void client_destroy_success(struct client *client, const char *reason)
{
client->login_success = TRUE;
int ret;
if ((ret = o_stream_flush(client->output)) < 0) {
- client_destroy(client, "Disconnected");
+ client_destroy_iostream_error(client);
return 1;
}
return FALSE;
case -1:
/* disconnected */
- client_destroy(client, "Disconnected");
+ client_destroy_iostream_error(client);
return FALSE;
case 0:
/* nothing new read */
void client_disconnect(struct client *client, const char *reason,
bool add_disconnected_prefix);
void client_destroy(struct client *client, const char *reason);
+void client_destroy_iostream_error(struct client *client);
/* Destroy the client after a successful login. Either the client fd was
sent to the post-login process, or the connection will be proxied. */
void client_destroy_success(struct client *client, const char *reason);