delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/08/21/12:17:22

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:content-type:content-transfer-encoding; q=dns; s=default; b=H+n
aayi57zYEs/5DAjZcaZxzThmsDKGAQEPw4wBnH09O0WlL4zzbdW09wKLNf66M3tV
Gc3kxC2iySSo97MOjE84ZnQtH46S4qKxf6K9FwRQQ4vIuy7jItr9d8g30pfZeH+L
zcPV0JU/rzGGfYVoyRUNgjZ8VIsyHeY5/yukIIc0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:content-type:content-transfer-encoding; s=default; bh=djrmMyMAb
m+4gTdhHzHNEMXCXz4=; b=JAxTrqqTZ2rdE1SRQuYLEMiusvW7mumN/W9sMBQvc
K+EIJNnURjsQ63GpW8s5R0Kky6S5RHR51rNIGFx5kxaqzYcKgY69GN2c6+JacEtY
v65eI3upt/LXn2fBjBoa8z+sZcv3in6lYaJXAjf7ioQPSr2Xp2nZ86AilyTp1FOd
w4=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2
X-HELO: mailout10.t-online.de
Message-ID: <53F61B70.2020600@t-online.de>
Date: Thu, 21 Aug 2014 18:16:48 +0200
From: Christian Franke <Christian DOT Franke AT t-online DOT de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: connect() hangs on a listen()ing AF_UNIX socket
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019