public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* connect() hangs on a listen()ing AF_UNIX socket
@ 2014-08-21 16:17 Christian Franke
  2014-08-21 16:44 ` Corinna Vinschen
  0 siblings, 1 reply; 15+ messages in thread
From: Christian Franke @ 2014-08-21 16:17 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen wrote (in thread "[ITP] libsuexec 1.0"):
> Postfix for Cygwin would be *so* nice.  Sigh.  ...

Due to the following problem, Postfix hangs during startup (and blocks 
any possible "[ITP] postfix ..."):

If a AF_UNIX socket is in listen()ing state, a client connect() should 
succeed immediately. On Cygwin, connect() waits until the server site 
accept()s the connection.

Testcase:

#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>

int main()
{
   sockaddr_un sa = {AF_UNIX, "testsocket"};
   unlink(sa.sun_path);

   int sd1 = socket(AF_UNIX, SOCK_STREAM, 0);
   if (sd1 < 0) {
     perror("socket"); return 1;
   }
   if (bind(sd1, (sockaddr*) &sa, sizeof(sa))) {
     perror("bind"); return 1;
   }
   if (listen(sd1, 10) < 0) {
     perror("listen"); return 1;
   }

   int sd2 = socket(AF_UNIX, SOCK_STREAM, 0);
   if (sd2 < 0) {
     perror("socket"); return 1;
   }
   printf("connecting to %s ...\n", sa.sun_path);

   // Cygwin hangs here:
   if (connect(sd2, (sockaddr*) &sa, sizeof(sa))) {
     perror("connect"); return 1;
   }

   // Linux & friends arrive here:
   printf("connected\n");
   return 0;
}


This is likely because fhandler_socket::af_local_connect() waits for 
some secret. Sending it in af_local_accept() is too late in this case.

Unfortunately the event handling of postfix relies on the correct 
behavior and there is possibly no easy workaround.

Christian


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-10-08 12:39 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 16:17 connect() hangs on a listen()ing AF_UNIX socket Christian Franke
2014-08-21 16:44 ` Corinna Vinschen
2014-08-21 19:14   ` Christian Franke
2014-08-22  9:39     ` Corinna Vinschen
2014-08-22 18:32       ` Christian Franke
2014-08-22 20:16         ` Corinna Vinschen
2014-08-26 19:03           ` Christian Franke
2014-08-26 20:56             ` Corinna Vinschen
2014-08-27  8:58               ` Achim Gratz
2014-08-27  9:50                 ` Corinna Vinschen
2014-08-27 10:12                   ` Corinna Vinschen
2014-08-27 17:57                     ` Achim Gratz
2014-08-28  9:57                       ` Corinna Vinschen
2014-09-25 14:35               ` Christian Franke
2014-10-08 12:39                 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).