This is the mail archive of the 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: Cygwin port of rsync -- patch for Win2k (rsync 2.5.1)

I don't think I have enough knowledge on the "fork() in cygwin" subject to
evaluate if there are better solutions, I reply also in the mailing list.


BTW: I'll try the fix soon, just wanted some more "advice from the gurus"
about the issue ;)

Chuck Messenger wrote:

> Hi Lapo,
> I've been trying out the Cygwin port of rsync -- version 2.5.1.  I've
> found that it doesn't work in server (i.e. --daemon) mode on my Win2k
> box, but it does work on my Win98 box.
> I did some debugging, and came up with a fix.
> In socket.c, we have the following code which the server executes after
> being connected to by a client:
>          if (fork()==0) {
>              close(s);
>              /* open log file in child before possibly giving
>                 up privileges  */
>              log_open();
>              _exit(fn(fd));
>          }
>   >>> delay(1);    /* CHM addition */
>          close(fd);
> I've marked my addition with >>>.  What seems to happen on Win2k is that
> the close(fd) gets called by the mother process before the child process
> gets going.  By adding a 1 second delay after the fork in the mother
> process, it seems to give enough time for the child to replicate the
> socket, so the mother can safely close(fd) it.
> The code for delay is:
>      static void  /* CHM addition */
>      delay(
>          int secs)
>      {
>          struct timeval timeout;
>          timeout.tv_sec = secs;
>          timeout.tv_usec = 0;
>          select(0, NULL, NULL, NULL, &timeout);
>      }
> I've been running rsync with this mod, and it seems to work fine.
> I know it's ugly -- the real solution would be to fix fork() -- but at
> least it works...
>      - Chuck

Lapo 'Raist' Luchini (PGP & X.509 keys available) (ICQ UIN: 529796)

Unsubscribe info:
Bug reporting:

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