$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
*/
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);
}
}
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.
ERROR + CMD_NOT_SUPPORTED);
}
+ unbuffer_output();
+
/* Run any after-each-command routines registered by modules */
PerformSessionHooks(EVT_CMD);
}
struct CitContext *t_context;
int retval;
+ unbuffer_output();
+
if (!(CC->logged_in)) {
cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
return;
char nosup_response[SIZ];
char error_response[SIZ];
+ unbuffer_output();
+
sprintf(ok_response,
"%d Begin TLS negotiation now\n",
CIT_OK);
*/
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;
}