event: move buffer size to a macro

Move buffer size for incoming messages to a macro. So it can be changed
in one place.
This commit is contained in:
Dmitry Podgorny
2020-01-07 22:20:12 +02:00
parent 133abd096d
commit 3f05bafffb

View File

@@ -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) {