diff options
author | Michael Vetter <jubalh@iodoru.org> | 2022-08-08 17:51:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 17:51:30 +0200 |
commit | 712fdc475f9f36527b71c8ca8e4034e57b59f84e (patch) | |
tree | d052d16edf3a5d75c698f4d67dadfb2bc708a40b | |
parent | 082de1363813d504581fccbd1c203ab7269e79a5 (diff) | |
parent | 65acffcf072a80932ca178182bbd30c416bf3584 (diff) | |
download | profani-tty-712fdc475f9f36527b71c8ca8e4034e57b59f84e.tar.gz |
Merge pull request #1746 from profanity-im/replay-queue
fixup 11f52ad5474c7adb7f11df5b0c318597e4150312
-rw-r--r-- | src/xmpp/connection.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 6ba3c935..71b31c9d 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -1000,11 +1000,14 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status // lost connection for unknown reason if (conn.conn_status == JABBER_CONNECTED) { + int send_queue_len = xmpp_conn_send_queue_len(conn.xmpp_conn); log_debug("Connection handler: Lost connection for unknown reason"); conn.sm_state = xmpp_conn_get_sm_state(conn.xmpp_conn); - conn.queued_messages = calloc(xmpp_conn_send_queue_len(conn.xmpp_conn) + 1, sizeof(*conn.queued_messages)); - for (int n = 0; n < xmpp_conn_send_queue_len(conn.xmpp_conn); ++n) { - conn.queued_messages[n] = xmpp_conn_send_queue_drop_element(conn.xmpp_conn, XMPP_QUEUE_OLDEST); + if (send_queue_len > 0) { + conn.queued_messages = calloc(send_queue_len + 1, sizeof(*conn.queued_messages)); + for (int n = 0; n < send_queue_len && conn.queued_messages[n]; ++n) { + conn.queued_messages[n] = xmpp_conn_send_queue_drop_element(conn.xmpp_conn, XMPP_QUEUE_OLDEST); + } } session_lost_connection(); |