From d9acad3d91375fb8c90a96940b3e65e3c5cb832e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 6 Jul 2021 11:14:58 +0200 Subject: [PATCH] add xmpp_conn_send_queue_len() Signed-off-by: Steffen Jaeckel --- ChangeLog | 1 + src/conn.c | 14 ++++++++++++++ strophe.h | 1 + 3 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index b536a42..5994aed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - Add code coverage support - Add support for password-protected TLS key & PKCS#12/PFX files - New API: + - xmpp_conn_send_queue_len() - xmpp_conn_get_keyfile() - xmpp_conn_set_password_callback() - xmpp_conn_set_password_retries() diff --git a/src/conn.c b/src/conn.c index b099819..a6884c6 100644 --- a/src/conn.c +++ b/src/conn.c @@ -1252,6 +1252,20 @@ int xmpp_conn_is_disconnected(xmpp_conn_t *conn) return conn->state == XMPP_STATE_DISCONNECTED; } +/** + * @return The number of entries in the send queue + * + * @ingroup Connections + */ +int xmpp_conn_send_queue_len(const xmpp_conn_t *conn) +{ + if (conn->send_queue_head && conn->send_queue_head->written && + conn->send_queue_head->owner == XMPP_QUEUE_USER) + return conn->send_queue_user_len - 1; + else + return conn->send_queue_user_len; +} + /* timed handler for cleanup if normal disconnect procedure takes too long */ static int _disconnect_cleanup(xmpp_conn_t *conn, void *userdata) { diff --git a/strophe.h b/strophe.h index 8b180db..8aac69f 100644 --- a/strophe.h +++ b/strophe.h @@ -383,6 +383,7 @@ void xmpp_conn_set_sockopt_callback(xmpp_conn_t *conn, int xmpp_conn_is_connecting(xmpp_conn_t *conn); int xmpp_conn_is_connected(xmpp_conn_t *conn); int xmpp_conn_is_disconnected(xmpp_conn_t *conn); +int xmpp_conn_send_queue_len(const xmpp_conn_t *conn); int xmpp_connect_client(xmpp_conn_t *conn, const char *altdomain,