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>
Mon, 13 Dec 2010 17:24:40 +0000 (18:24 +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 54bceb7a5f4468ffbd91a1f06071a925e3e47765..8052e24e4ac8ced4b22747d4029f5ba3fa313e4d 100644 (file)
@@ -231,7 +231,9 @@ INLINE int sock_read(int *sock, char *buf, int bytes,
  * 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;
@@ -239,7 +241,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 ba5e35068b75cb392463cc4eea219948a5ae37c3..cb93d849bacc482862425f159394af76c12c1a44 100644 (file)
@@ -22,6 +22,7 @@ int sock_connect(char *host, char *service);
 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 4661c2f2ff9a1095f02a6eda13b500714818aa9a..7212731de39fcd7ec5342dbbce4f6a46cec4e1a6 100644 (file)
@@ -1268,7 +1268,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",