From 119aee5979b9ad21a6b47a1d926e5ba377c3ad68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Fri, 21 May 2010 20:22:51 +0000 Subject: [PATCH] * add possibility to specify the inbound buffer size * XMPP: increase our buffer on start, so client_read_random_blob() can unveil all its power. --- citadel/modules/xmpp/serv_xmpp.c | 1 + citadel/sysdep.c | 31 ++++++++++++++++++++++++++++++- citadel/sysdep_decls.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/citadel/modules/xmpp/serv_xmpp.c b/citadel/modules/xmpp/serv_xmpp.c index 31656c18b..835b30195 100644 --- a/citadel/modules/xmpp/serv_xmpp.c +++ b/citadel/modules/xmpp/serv_xmpp.c @@ -513,6 +513,7 @@ void xmpp_cleanup_function(void) { * Here's where our XMPP session begins its happy day. */ void xmpp_greeting(void) { + client_set_inbound_buf(4); strcpy(CC->cs_clientname, "XMPP session"); CC->session_specific_data = malloc(sizeof(citxmpp)); memset(XMPP, 0, sizeof(citxmpp)); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index ce3523d98..d9f34470e 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -622,6 +622,16 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) } +/* + * to make client_read_random_blob() more efficient, increase buffer size. + * just use in greeting function, else your buffer may be flushed + */ +void client_set_inbound_buf(long N) +{ + FlushStrBuf(CC->ReadBuf); + ReAdjustEmptyBuf(CC->ReadBuf, N * SIZ, N * SIZ); +} + int client_read_random_blob(StrBuf *Target, int timeout) { CitContext *CCC=CC; @@ -645,11 +655,30 @@ int client_read_random_blob(StrBuf *Target, int timeout) StrBufAppendBufPlain(Target, pch, len, 0); FlushStrBuf(CCC->ReadBuf); CCC->Pos = NULL; +#ifdef BIGBAD_IODBG + { + int rv = 0; + char fn [SIZ]; + FILE *fd; + + snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid); + + fd = fopen(fn, "a+"); + fprintf(fd, "Read: BufSize: %d BufContent: [", + StrLength(Target)); + rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd); + fprintf(fd, "]\n"); + + + fclose(fd); + } +#endif + return StrLength(Target); } return rc; } - else + else return rc; } diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index 4789914fd..df25cbf94 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -65,6 +65,7 @@ int client_read (char *buf, int bytes); int client_getln (char *buf, int maxbytes); int CtdlClientGetLine(StrBuf *Target); int client_read_blob(StrBuf *Target, int bytes, int timeout); +void client_set_inbound_buf(long N); int client_read_random_blob(StrBuf *Target, int timeout); void sysdep_master_cleanup (void); void kill_session (int session_to_kill); -- 2.30.2