delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/01/01/19:00:29

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Ralf Habacker" <Ralf DOT Habacker AT freenet DOT de>
To: "Cygwin" <cygwin AT sources DOT redhat DOT com>
Subject: RE: duplicate regexec/regcomp functions detected
Date: Wed, 2 Jan 2002 00:57:25 +0100
Message-ID: <002501c19320$0fb94080$865c07d5@BRAMSCHE>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
In-Reply-To: <20020101160631.B27340@cygbert.vinschen.de>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Importance: Normal

> -----Original Message-----
> From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com]On Behalf
> Of Corinna Vinschen
> Sent: Tuesday, January 01, 2002 4:07 PM
> To: cygwin AT cygwin DOT com
> Subject: Re: duplicate regexec/regcomp functions detected
>
>
> On Mon, Dec 31, 2001 at 07:53:28PM +0100, Ralf Habacker wrote:
> > > >- unix domain socket - The above mentioned os supports creating unix
> > > >domain sockets with previous existing files.  On cygwin the unix domain
> > > >sockets couldn't be bound on existing files, so it has to be removed
> > > >first.
> > >
> > > Sounds like a bug.  Submit a patch.
>
> It's not a bug, it's Linux compliant behaviour.  Try the following
> code on Linux and Cygwin:
>
> ================================== SNIP ==============================
> #include <stdio.h>
> #include <errno.h>
> #include <sys/socket.h>
> #include <sys/un.h>
>
> int
> main(int argc, char **argv)
> {
>   int sockfd;
>   socklen_t len;
>   struct sockaddr_un addr1, addr2;
>
>   if (argc != 2)
>     {
>       fprintf (stderr, "Idiot\n");
>       return 1;
>     }
>   sockfd = socket (AF_LOCAL, SOCK_STREAM, 0);
>   if (sockfd < 0)
>     {
>       fprintf (stderr, "socket: %d, %s\n", errno, strerror (errno));
>       return 1;
>     }
>   memset (&addr1, 0, sizeof addr1);
>   addr1.sun_family = AF_LOCAL;
>   strncpy (addr1.sun_path, argv[1], sizeof addr1.sun_path - 1);
>   if (bind (sockfd, (struct sockaddr *) &addr1, SUN_LEN (&addr1)) < 0)
>     {
>       fprintf (stderr, "bind: %d, %s\n", errno, strerror (errno));
>       return 1;
>     }
>   len = sizeof addr2;
>   if (getsockname (sockfd, (struct sockaddr *) &addr2, &len) < 0)
>     {
>       fprintf (stderr, "getsockname: %d, %s\n", errno, strerror (errno));
>       return 1;
>     }
>   printf ("bound name = %s, returned len = %d\n", addr2.sun_path, len);
>   return 0;
> }
> ================================== SNAP ==============================
>
> Linux:
> ------
> $ gcc -o uds uds.c
> $ ./uds /tmp/foo.bar
> bound name = /tmp/foo.bar, returned len = 15
> $ ./uds /tmp/foo.bar
> bind: 98, Address already in use
>
> Cygwin:
> -------
> $ gcc -o uds uds.c
> $ ./uds /tmp/foo.bar
> bound name = <some random string here>, returned len = 16
> $ ./uds /tmp/foo.bar
> bind: 112, Address already in use
>
> That shows that Cygwin's getsockname() doesn't return a correct
> sockname for unix domain sockets but the bind() call behaves
> correct.  An application that depends on (actually undocumented)
> behaviour that a unix domain socket can be rebound is doing something
> wrong.

Thanks for this hints. While porting kdelibs I have had to explicity closed and delete the
socket file before I can bound to it (which wasn't used under other ported os) and as I found
the decribed code in the bind() function, the first thoughts was that this may be the
problem. After this correction I will look at the kde code to identify the called functions.
Perhaps the problem is the getsockname().

After looking in the code I have an additional question. Does cygwin and linux differs in the
possibilites of deleting of open files ? This could be a difference, because I have found
that before binding an unlink() is made, but fails.

Ralf



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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