This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]