SMTP Async I/O:
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 13 Dec 2010 17:23:31 +0000 (18:23 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 14 Dec 2010 00:50:07 +0000 (01:50 +0100)
 - while sending data, wait relative to the size of the mail /128 + a minimal set of 50.

citadel/clientsocket.c
citadel/clientsocket.h
citadel/modules/smtp/serv_smtp.c

index 91094aa8a615295006c8d49da6addd7db698b5d1..572f28f17c1293d324b732e51b11261fbda33a28 100644 (file)
@@ -264,7 +264,9 @@ INLINE int sock_read(int *sock, char *buf, int bytes, int keep_reading_until_ful
  * sock_write() - send binary to server.
  * Returns the number of bytes written, or -1 for error.
  */
-int sock_write(int *sock, const char *buf, int nbytes)
+int sock_write(int *sock, const char *buf, int nbytes) 
+{ return sock_write_timeout(sock, buf, nbytes, 50); }
+int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout)
 {
        int nSuccessLess = 0;
        int bytes_written = 0;
@@ -272,7 +274,6 @@ int sock_write(int *sock, const char *buf, int nbytes)
        fd_set rfds;
         int fdflags;
        int IsNonBlock;
-       int timeout = 50;
        struct timeval tv;
        int selectresolution = 100;
 
index 491d7e3b122de69f44ce18cdc4ad6606a20434ea..69898156d0fc4c4a30514d2db41a2e06fc35574c 100644 (file)
@@ -24,6 +24,7 @@ int sock_connect(char *host, char *service, char *protocol);
 int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_until_full);
 int sock_read(int *sock, char *buf, int bytes, int keep_reading_until_full);
 int sock_write(int *sock, const char *buf, int nbytes);
+int sock_write_timeout(int *sock, const char *buf, int nbytes, int timeout);
 int ml_sock_gets(int *sock, char *buf, int nSec);
 int sock_getln(int *sock, char *buf, int bufsize);
 int CtdlSockGetLine(int *sock, StrBuf *Target, int nSec);
index b0572f5a1f7b96f347a4328169d56941e0447970..fc43a9624529001f924df11e379d9ef126e565d4 100644 (file)
@@ -1272,7 +1272,10 @@ void smtp_try(const char *key, const char *addr, int *status,
        }
 
        /* If we reach this point, the server is expecting data.*/
-       sock_write(&sock, msgtext, msg_size);
+       sock_write_timeout(&sock, 
+                          msgtext, 
+                          msg_size, 
+                          (msg_size / 128) + 50);
        if (msgtext[msg_size-1] != 10) {
                CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
                        "correctly terminate. (expecting 0x10, got 0x%02x)\n",