From: Jeffrey Stedfast Date: Tue, 6 Aug 2002 05:21:34 +0000 (+0000) Subject: If writing to the sendmail pipe fails, wait for the sendmail process to X-Git-Tag: upstream/3.7.4~10163 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69a11ad93fc4e0ec5aa3c0ecab921e4fef2933e2;p=platform%2Fupstream%2Fevolution-data-server.git If writing to the sendmail pipe fails, wait for the sendmail process to 2002-08-06 Jeffrey Stedfast * providers/sendmail/camel-sendmail-transport.c (sendmail_send_to): If writing to the sendmail pipe fails, wait for the sendmail process to exit before returning. Fixes bug #19636. --- diff --git a/camel/ChangeLog b/camel/ChangeLog index ef540ba5..c543d51 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2002-08-06 Jeffrey Stedfast + + * providers/sendmail/camel-sendmail-transport.c + (sendmail_send_to): If writing to the sendmail pipe fails, wait + for the sendmail process to exit before returning. Fixes bug + #19636. + 2002-08-06 Not Zed * providers/pop3/camel-pop3-folder.c (cmd_list): Add messageinfo diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c index 604d7f2..1af237f 100644 --- a/camel/providers/sendmail/camel-sendmail-transport.c +++ b/camel/providers/sendmail/camel-sendmail-transport.c @@ -122,14 +122,14 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, g_strerror (errno)); return FALSE; } - + /* Block SIGCHLD so the calling application doesn't notice * sendmail exiting before we do. */ sigemptyset (&mask); sigaddset (&mask, SIGCHLD); sigprocmask (SIG_BLOCK, &mask, &omask); - + pid = fork (); switch (pid) { case -1: @@ -140,39 +140,47 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, sigprocmask (SIG_SETMASK, &omask, NULL); g_free (argv); return FALSE; - case 0: /* Child process */ nullfd = open ("/dev/null", O_RDWR); dup2 (fd[0], STDIN_FILENO); - /* dup2 (nullfd, STDOUT_FILENO); - dup2 (nullfd, STDERR_FILENO);*/ + /*dup2 (nullfd, STDOUT_FILENO); + dup2 (nullfd, STDERR_FILENO);*/ close (nullfd); close (fd[1]); - + execv (SENDMAIL_PATH, (char **)argv); _exit (255); } g_free (argv); - + /* Parent process. Write the message out. */ close (fd[0]); out = camel_stream_fs_new_with_fd (fd[1]); if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1 - || camel_stream_close(out) == -1) { + || camel_stream_close (out) == -1) { camel_object_unref (CAMEL_OBJECT (out)); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not send message: %s"), - strerror(errno)); + g_strerror (errno)); + + /* Wait for sendmail to exit. */ + while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) + ; + + sigprocmask (SIG_SETMASK, &omask, NULL); + return FALSE; } + camel_object_unref (CAMEL_OBJECT (out)); - + /* Wait for sendmail to exit. */ while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR) ; + sigprocmask (SIG_SETMASK, &omask, NULL); - + if (!WIFEXITED (wstat)) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("sendmail exited with signal %s: " @@ -193,7 +201,7 @@ sendmail_send_to (CamelTransport *transport, CamelMimeMessage *message, } return FALSE; } - + return TRUE; }