From: Michael Hampton Date: Sun, 5 Sep 2004 15:41:46 +0000 (+0000) Subject: * Network optimizations - buffer output server-side for better network X-Git-Tag: v7.86~5275 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1ca3b27da2235dcf4ec1fba5a79f81a3c8256da7 * Network optimizations - buffer output server-side for better network utilization; one client-side optimization --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index dc2b440ef..1bc3cd77c 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 625.12 2004/09/05 15:41:45 error + * Network optimizations - buffer output server-side for better network + utilization; one client-side optimization + Revision 625.11 2004/09/05 15:20:41 error * sysdep.c: unbuffer_output(): Split the writing part to a new function flush_output() for more precise control @@ -6042,4 +6046,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 9a07aa2cd..ce5729cb2 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -2834,9 +2834,22 @@ void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf) */ static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf) { - /* error_printf("< %s\n", buf); */ - serv_write(ipc, buf, strlen(buf)); - serv_write(ipc, "\n", 1); + char *cmd = NULL; + int len; + + len = strlen(buf); + cmd = malloc(len + 2); + if (!cmd) { + /* This requires no extra memory */ + serv_write(ipc, buf, len); + serv_write(ipc, "\n", 1); + } else { + /* This is network-optimized */ + strncpy(cmd, buf, len); + strcpy(cmd + len, "\n"); + serv_write(ipc, cmd, len + 1); + free(cmd); + } ipc->last_command_sent = time(NULL); } diff --git a/citadel/citserver.c b/citadel/citserver.c index 1e52d43e2..c38cc0b4c 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -948,6 +948,8 @@ void do_command_loop(void) { } lprintf(CTDL_INFO, "Citadel: %s\n", cmdbuf); + buffer_output(); + /* * Let other clients see the last command we executed, and * update the idle time, but not NOOP, QNOP, PEXP, or GEXP. @@ -1316,6 +1318,8 @@ void do_command_loop(void) { ERROR + CMD_NOT_SUPPORTED); } + unbuffer_output(); + /* Run any after-each-command routines registered by modules */ PerformSessionHooks(EVT_CMD); } diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index 89d715faa..ce5770b32 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -241,6 +241,8 @@ void cmd_chat(char *argbuf) struct CitContext *t_context; int retval; + unbuffer_output(); + if (!(CC->logged_in)) { cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN); return; diff --git a/citadel/serv_crypto.c b/citadel/serv_crypto.c index a2593aaa0..19df6a879 100644 --- a/citadel/serv_crypto.c +++ b/citadel/serv_crypto.c @@ -515,6 +515,8 @@ void cmd_stls(char *params) char nosup_response[SIZ]; char error_response[SIZ]; + unbuffer_output(); + sprintf(ok_response, "%d Begin TLS negotiation now\n", CIT_OK); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 5925aa613..d2c509248 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -482,8 +482,10 @@ void flush_output(void) { */ void unbuffer_output(void) { if (CC->buffering == 1) { - flush_output(); CC->buffering = 0; + /* We don't call flush_output because we can't. */ + client_write(CC->output_buffer, CC->buffer_len); + CC->buffer_len = 0; free(CC->output_buffer); CC->output_buffer = NULL; }