From cd67528ced33f23e326f33f9517ace0b589ae827 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 6 Feb 2010 18:03:36 +0000 Subject: [PATCH] * optimize SMTP in, first step: - don't overuse CC, split function into wrapper so ones with higher frequency users can retrieve it outside. --- citadel/sysdep.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 83e87f3d9..a4746f7bb 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -547,7 +547,7 @@ void cprintf(const char *format, ...) { * -1 The socket is broken. * If the socket breaks, the session will be terminated. */ -int client_read_to(char *buf, int bytes, int timeout) +INLINE int client_read_backend(char *buf, int bytes, int timeout, CitContext *CCC) { int len,rlen; fd_set rfds; @@ -556,12 +556,12 @@ int client_read_to(char *buf, int bytes, int timeout) int retval; #ifdef HAVE_OPENSSL - if (CC->redirect_ssl) { + if (CCC->redirect_ssl) { return (client_read_ssl(buf, bytes, timeout)); } #endif len = 0; - fd = CC->client_socket; + fd = CCC->client_socket; while(lenkill_me = 1; + CCC->kill_me = 1; return (-1); } } @@ -597,7 +597,7 @@ int client_read_to(char *buf, int bytes, int timeout) rlen = read(fd, &buf[len], bytes-len); if (rlen<1) { /* The socket has been disconnected! */ - CC->kill_me = 1; + CCC->kill_me = 1; return(-1); } len = len + rlen; @@ -605,6 +605,12 @@ int client_read_to(char *buf, int bytes, int timeout) return(1); } + +int client_read_to(char *buf, int bytes, int timeout) +{ + return client_read_backend(buf, bytes, timeout, CC); +} + /* * Read data from the client socket with default timeout. * (This is implemented in terms of client_read_to() and could be @@ -624,11 +630,12 @@ INLINE int client_read(char *buf, int bytes) int client_getln(char *buf, int bufsize) { int i, retval; + CitContext *CCC=CC; /* Read one character at a time. */ for (i = 0;;i++) { - retval = client_read(&buf[i], 1); + retval = client_read_backend(&buf[i], 1, config.c_sleeping, CCC); if (retval != 1 || buf[i] == '\n' || i == (bufsize-1)) break; } @@ -713,7 +720,7 @@ void sysdep_master_cleanup(void) { CtdlDestroyServiceHook(); CtdlDestroyRoomHooks(); #ifdef HAVE_BACKTRACE - eCrash_Uninit(); +/// eCrash_Uninit(); #endif } -- 2.39.2