pidgin/pidgin

xmpp: Correctly handle server-closed connections.

2020-04-26, Elliott Sales de Andrade
a4de01fc9a6b
Parents 351db01b452d
Children 1d7bfb35d82f
xmpp: Correctly handle server-closed connections.

A return of 0 is a disconnect, whose handling was lost in a previous PR.
--- a/libpurple/protocols/jabber/jabber.c Sun Apr 26 18:51:58 2020 -0400
+++ b/libpurple/protocols/jabber/jabber.c Sun Apr 26 18:57:48 2020 -0400
@@ -610,7 +610,12 @@
len = g_pollable_input_stream_read_nonblocking(
G_POLLABLE_INPUT_STREAM(stream), buf, sizeof(buf) - 1,
js->cancellable, &error);
- if (len < 0) {
+ if (len == 0) {
+ purple_connection_error(js->gc,
+ PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
+ _("Server closed the connection"));
+ return G_SOURCE_REMOVE;
+ } else if (len < 0) {
if (error->code == G_IO_ERROR_WOULD_BLOCK) {
g_error_free(error);
return G_SOURCE_CONTINUE;
@@ -623,6 +628,7 @@
}
return G_SOURCE_REMOVE;
}
+
purple_connection_update_last_received(gc);
#ifdef HAVE_CYRUS_SASL
if (js->sasl_maxbuf > 0) {