changeset: 7091:219b9064cf28 user: Kevin McCarthy <ke...@8t8.us> date: Tue Jun 20 15:09:43 2017 -0700 link: http://dev.mutt.org/hg/mutt/rev/219b9064cf28
Block SIGWINCH during connect(). (closes #3941) FreeBSD's connect() does not respect SA_RESTART, so a SIGWINCH will end up interrupting the connect. If this code is needed in other places, it should be moved into signal.c. For this one place, inlining the sigprocmask() seemed okay. diffs (47 lines): diff -r d56fd3f91de9 -r 219b9064cf28 mutt_socket.c --- a/mutt_socket.c Sun Jun 18 10:58:12 2017 -0700 +++ b/mutt_socket.c Tue Jun 20 15:09:43 2017 -0700 @@ -35,6 +35,7 @@ #include <netinet/in.h> #include <netdb.h> #include <stdlib.h> +#include <signal.h> #include <fcntl.h> #include <sys/types.h> #ifdef HAVE_SYS_TIME_H @@ -344,6 +345,7 @@ { int sa_size; int save_errno; + sigset_t set; if (sa->sa_family == AF_INET) sa_size = sizeof (struct sockaddr_in); @@ -356,12 +358,18 @@ dprint (1, (debugfile, "Unknown address family!\n")); return -1; } - + if (ConnectTimeout > 0) alarm (ConnectTimeout); mutt_allow_interrupt (1); + /* FreeBSD's connect() does not respect SA_RESTART, meaning + * a SIGWINCH will cause the connect to fail. */ + sigemptyset (&set); + sigaddset (&set, SIGWINCH); + sigprocmask (SIG_BLOCK, &set, NULL); + save_errno = 0; if (connect (fd, sa, sa_size) < 0) @@ -374,6 +382,7 @@ if (ConnectTimeout > 0) alarm (0); mutt_allow_interrupt (0); + sigprocmask (SIG_UNBLOCK, &set, NULL); return save_errno; }