From 3f05bafffba72477e27669ac8d006c4f89eb0412 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Tue, 7 Jan 2020 22:20:12 +0200 Subject: [PATCH] event: move buffer size to a macro Move buffer size for incoming messages to a macro. So it can be changed in one place. --- src/event.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/event.c b/src/event.c index 027fa2a..89bfc34 100644 --- a/src/event.c +++ b/src/event.c @@ -57,6 +57,9 @@ #include "common.h" #include "parser.h" +/** Max buffer size for receiving messages. */ +#define STROPE_MESSAGE_BUFFER_SIZE 4096 + /** Run the event loop once. * This function will run send any data that has been queued by * xmpp_send and related functions and run through the Strophe even @@ -80,7 +83,7 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout) struct timeval tv; xmpp_send_queue_t *sq, *tsq; int towrite; - char buf[4096]; + char buf[STROPE_MESSAGE_BUFFER_SIZE]; uint64_t next; uint64_t usec; int tls_read_bytes = 0; @@ -260,9 +263,9 @@ void xmpp_run_once(xmpp_ctx_t *ctx, const unsigned long timeout) case XMPP_STATE_CONNECTED: if (FD_ISSET(conn->sock, &rfds) || (conn->tls && tls_pending(conn->tls))) { if (conn->tls) { - ret = tls_read(conn->tls, buf, 4096); + ret = tls_read(conn->tls, buf, STROPE_MESSAGE_BUFFER_SIZE); } else { - ret = sock_read(conn->sock, buf, 4096); + ret = sock_read(conn->sock, buf, STROPE_MESSAGE_BUFFER_SIZE); } if (ret > 0) {