* sock_getln (): CtdlSockGetLine() gives us lines without \r\n, no need to look for...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index 1d7dd0e7ebb558f1bf9e4732921c2cb3c4cb1ca8..fdd20889efc2585131e6f85a6cfacdeffebef7d3 100644 (file)
@@ -1085,7 +1085,21 @@ void smtp_try(const char *key, const char *addr, int *status,
                CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
                sock = sock_connect(mx_host, mx_port, "tcp");
                snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
-               if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n");
+               if (sock >= 0) 
+               {
+                       CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n");
+                               int fdflags; 
+                               fdflags = fcntl(sock, F_GETFL);
+                               if (fdflags < 0)
+                                       CtdlLogPrintf(CTDL_DEBUG,
+                                                     "unable to get SMTP-Client socket flags! %s \n",
+                                                     strerror(errno));
+                               fdflags = fdflags | O_NONBLOCK;
+                               if (fcntl(sock, F_SETFL, fdflags) < 0)
+                                       CtdlLogPrintf(CTDL_DEBUG,
+                                                     "unable to set SMTP-Client socket nonblocking flags! %s \n",
+                                                     strerror(errno));
+               }
                if (sock < 0) {
                        if (errno > 0) {
                                snprintf(dsn, SIZ, "%s", strerror(errno));