Sam Varshavchik wrote:Download: http://www.courier-mta.org/download.php
Any chance of this patch (or something similar) making it in before the next release?
http://phantom.dragonsdawn.net/~gordon/courier-patches/cdfilters-EAGAIN.patch
This is not correct. No matter what you're trying to do, throwing away the return code from connect() is patently wrong. This may work on your particular operating system or revision, but it's a sure bet it's not going to work for everyone.
I believe that the following patch, instead, is the correct way to do this.
pgp00000.pgp
Description: PGP signature
Index: courier/cdfilters.C
===================================================================
RCS file: /cvsroot/courier/courier/courier/courier/cdfilters.C,v
retrieving revision 1.7
diff -U3 -r1.7 cdfilters.C
--- courier/cdfilters.C 5 Aug 2001 20:00:33 -0000 1.7
+++ courier/cdfilters.C 6 Oct 2003 01:59:49 -0000
@@ -9,6 +9,9 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <errno.h>
#include <ctype.h>
#include "mydirent.h"
@@ -83,16 +86,29 @@
{
int s;
struct sockaddr_un ssun;
+int triedagain=0;
+int rc;
if ((s=socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
clog_msg_errno();
+ if (fcntl(s, F_SETFL, O_NDELAY) < 0)
+ clog_msg_errno();
+
ssun.sun_family=AF_UNIX;
strcpy(ssun.sun_path, sockname);
- if (fcntl(s, F_SETFL, O_NDELAY) < 0)
- clog_msg_errno();
- if (connect(s, (struct sockaddr *)&ssun, sizeof(ssun)) < 0)
+ while ((rc=connect(s, (struct sockaddr *)&ssun, sizeof(ssun)) < 0)
+ && errno == EAGAIN)
+ {
+ if (++triedagain > 5)
+ break;
+ sleep(1);
+ ssun.sun_family=AF_UNIX;
+ strcpy(ssun.sun_path, sockname);
+ }
+
+ if (rc < 0)
{
struct timeval tv;
fd_set fds;
pgp00001.pgp
Description: PGP signature
