Skip to contentSkip to conversation

poll() emulation in git

DISCUSSION Joachim Schmitz 3 participants 14 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw
Quoted 58 lines

From: Joachim Schmitz [mailto:[email protected]]
Sent: Tuesday, September 04, 2012 1:49 PM
To: 'Junio C Hamano'
Cc: '[email protected]'; 'Erik Faye-Lund'
Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 10 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Friday, August 24, 2012 9:47 PM
To: Joachim Schmitz
Cc: [email protected]; 'Erik Faye-Lund'
Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 1 line · Joachim Schmitz

Different, but related question: would poll.[ch] be allowed to #include "git-compat-util.h"?

Quoted 7 lines

Seeing other existing generic wrappers directly under compat/, e.g. fopen.c, mkdtemp.c, doing so, I would say why not.

Windows folks (I see Erik is already CC'ed, which is good ;-), please work with Joachim to make sure such a move won't break your builds. I believe that it should just be the matter of updating a couple of paths in the top-level Makefile.

Haven't heard anything from the Windows folks yet.

I'd prefer to move compat/win32/poll.[ch] into compat/poll. Then adjust a few paths in Makefile and that would be the 1st patch

A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.

compat/poll/poll.c +6 -3
index 403eaa7..49541f1 100644
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif
 
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
 
--
Quoted 1 line

1.7.12

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all kind if file descriptors, at least that is my understanding.

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a socket to talk to, so the poll() just hangs/loops.

As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo

Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?
There is some code that pertains to a seemingly similar problem in Mac OS X, but my problem is not identical, as that fix doesn't help.

Bye, Jojo

#1 lore raw

Il 05/09/2012 13:24, Joachim Schmitz ha scritto:

Quoted 3 lines

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all kind if file descriptors, at least that is my understanding.

Actually recv(...,MSG_PEEK) on most Unix variants works on non-sockets too. The trick is taken from GNU Pth in turn.

Quoted 2 lines

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a socket to talk to, so the poll() just hangs/loops.

Does your system have a working FIONREAD ioctl for pipes?

Quoted 5 lines

As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo

Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?
There is some code that pertains to a seemingly similar problem in Mac OS X, but my problem is not identical, as that fix doesn't help.

Paolo

#2 lore raw
Quoted 9 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Wednesday, September 05, 2012 2:05 PM
To: Joachim Schmitz
Cc: 'Junio C Hamano'; [email protected]; 'Erik Faye-Lund'; [email protected]
Subject: Re: poll() emulation in git

Il 05/09/2012 13:24, Joachim Schmitz ha scritto:

Quoted 2 lines

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on

all

Quoted 9 lines
Quoted 1 line

kind if file descriptors, at least that is my understanding.

Actually recv(...,MSG_PEEK) on most Unix variants works on non-sockets too. The trick is taken from GNU Pth in turn.

Quoted 2 lines

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a socket to talk to, so the poll() just hangs/loops.

Does your system have a working FIONREAD ioctl for pipes?

It does have FIONREAD ioctl. Whether it works properly is to be determined... I'll test if you could show me how?

Bye, Jojo

#3 lore raw
In reply to Paolo Bonzini
Quoted 15 lines

From: Joachim Schmitz [mailto:[email protected]]
Sent: Wednesday, September 05, 2012 2:58 PM
To: 'Paolo Bonzini'
Cc: 'Junio C Hamano'; '[email protected]'; 'Erik Faye-Lund'; '[email protected]'
Subject: RE: poll() emulation in git

Quoted 9 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Wednesday, September 05, 2012 2:05 PM
To: Joachim Schmitz
Cc: 'Junio C Hamano'; [email protected]; 'Erik Faye-Lund'; [email protected]
Subject: Re: poll() emulation in git

Il 05/09/2012 13:24, Joachim Schmitz ha scritto:

Quoted 2 lines

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works

on all

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

kind if file descriptors, at least that is my understanding.

Actually recv(...,MSG_PEEK) on most Unix variants works on non-sockets too. The trick is taken from GNU Pth in turn.

Quoted 1 line

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of

a

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

socket to talk to, so the poll() just hangs/loops.

Does your system have a working FIONREAD ioctl for pipes?

It does have FIONREAD ioctl. Whether it works properly is to be determined... I'll test if you could show me how?

Oh, now I see what you aimed at, but no, that Mac OS X method doesn't work for me, I tried (at least I think I did).

And <sys/ioctl.h> has
/*
* Normal IOCTL's supported by the socket interface */

#define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */
#define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */

So these seem to be supported on sockets only, I guess. And indeed the man pages for ioctl confirms:

Valid values for the request parameter for AF_INET or AF_INET6 sockets are:

FIONREAD Gets the number of bytes available for reading and
stores it at the int pointed at by arg.

So not even AF_UNIX sockets, not to mention pipes...

Bye, Jojo

#4 lore raw

Il 05/09/2012 15:36, Joachim Schmitz ha scritto:

Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Does your system have a working FIONREAD ioctl for pipes?

It does have FIONREAD ioctl. Whether it works properly is to be determined... I'll test if you could show me how?

Oh, now I see what you aimed at, but no, that Mac OS X method doesn't work for me, I tried (at least I think I did).

And <sys/ioctl.h> has
/*
* Normal IOCTL's supported by the socket interface */

#define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */
#define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */

So these seem to be supported on sockets only, I guess. And indeed the man pages for ioctl confirms:

Valid values for the request parameter for AF_INET or AF_INET6 sockets are:

Quoted 5 lines

FIONREAD Gets the number of bytes available for reading and
stores it at the int pointed at by arg.

So not even AF_UNIX sockets, not to mention pipes...

So there's no way you can support POLLHUP. Your system is quite crippled. :(

Paolo

#5 lore raw
Quoted 27 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Wednesday, September 05, 2012 5:26 PM
To: Joachim Schmitz
Cc: 'Junio C Hamano'; [email protected]; 'Erik Faye-Lund'; [email protected]
Subject: Re: poll() emulation in git

Il 05/09/2012 15:36, Joachim Schmitz ha scritto:

Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Does your system have a working FIONREAD ioctl for pipes?

It does have FIONREAD ioctl. Whether it works properly is to be determined... I'll test if you could show me how?

Oh, now I see what you aimed at, but no, that Mac OS X method doesn't work for me, I tried (at least I think I did).

And <sys/ioctl.h> has
/*
* Normal IOCTL's supported by the socket interface */

#define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */
#define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */

So these seem to be supported on sockets only, I guess. And indeed the man pages for ioctl confirms:

Valid values for the request parameter for AF_INET or AF_INET6 sockets are:

Quoted 8 lines
Quoted 5 lines

FIONREAD Gets the number of bytes available for reading and
stores it at the int pointed at by arg.

So not even AF_UNIX sockets, not to mention pipes...

So there's no way you can support POLLHUP. Your system is quite crippled. :(

Unfortunatly.

But is there something that could be done to make git work even without poll()? It is used in 5 places:

$ grep -n poll\( *.c */*.c
credential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {
daemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {
help.c:361:                     poll(NULL, 0, autocorrect * 100);
upload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {
builtin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {

Don't quite understand why in help.c it has that NULL, which should always result in an EFAULT and other than that basically is a NOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead? So I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.

In daemon.c it seems to be all sockets it polls on, so it should work on NonStop. Same in credential-cache--daemon.c

Remains upload-pack.c and builtin/upload-archive.c
In both start_command() gathers the FDs to poll() on and that indeed works on pipes -> problem on NonStop!

Seeing that in those cases xread() takes care of EAGAIN, I've now used 'brute force' in poll.c:

...

# else
      char data[64];
      r = recv (fd, data, sizeof (data), MSG_PEEK);
      socket_errno = (r < 0) ? errno : 0;
# endif
      if (r == 0)
        happened |= POLLHUP;
      /* If the event happened on an unconnected server socket,
         that's fine. */
      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
        happened |= (POLLIN | POLLRDNORM) & sought;

      /* Distinguish hung-up sockets from other errors.  */
      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
        happened |= POLLHUP;
#ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */
      else if (socket_errno == ENOTSOCK)
        happened |= (POLLIN | POLLRDNORM) & sought;
#endif
      else
        happened |= POLLERR;
    }

...

We won't detect POLLHUP that way I think. However it seems to work, we've been able to clone, push, pull, branch that way with NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that). Someone in for a cleaner way of managing this?

Bye, Jojo

#6 lore raw

Il 06/09/2012 16:02, Joachim Schmitz ha scritto:

Quoted 11 lines

But is there something that could be done to make git work even without poll()? It is used in 5 places:

$ grep -n poll\( *.c */*.c
credential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {
daemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {
help.c:361:                     poll(NULL, 0, autocorrect * 100);
upload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {
builtin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {
Quoted 3 lines

Don't quite understand why in help.c it has that NULL, which should always result in an EFAULT and other than that basically is a NOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead? So I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.

Yes, it's an usleep(autocorrect * 100000) basically (poll takes milliseconds, not micro).

Quoted 26 lines

...

# else
      char data[64];
      r = recv (fd, data, sizeof (data), MSG_PEEK);
      socket_errno = (r < 0) ? errno : 0;
# endif
      if (r == 0)
        happened |= POLLHUP;
      /* If the event happened on an unconnected server socket,
         that's fine. */
      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
        happened |= (POLLIN | POLLRDNORM) & sought;

      /* Distinguish hung-up sockets from other errors.  */
      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
        happened |= POLLHUP;
#ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */
      else if (socket_errno == ENOTSOCK)
        happened |= (POLLIN | POLLRDNORM) & sought;
#endif
      else
        happened |= POLLERR;
    }
Quoted 5 lines

...

We won't detect POLLHUP that way I think. However it seems to work, we've been able to clone, push, pull, branch that way with NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that). Someone in for a cleaner way of managing this?

I suppose it works to always handle ENOTSOCK that way, even on non-__TANDEM systems.

Paolo

#7 lore raw
Quoted 6 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Thursday, September 06, 2012 4:32 PM
To: Joachim Schmitz
Cc: [email protected]; 'Junio C Hamano'; 'Erik Faye-Lund'; [email protected]; [email protected]
Subject: Re: poll() emulation in git

Quoted 13 lines

Il 06/09/2012 16:02, Joachim Schmitz ha scritto:

Quoted 12 lines

But is there something that could be done to make git work even without poll()? It is used in 5 places:

$ grep -n poll\( *.c */*.c
credential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {
daemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {
help.c:361:                     poll(NULL, 0, autocorrect * 100);
upload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {
builtin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {

Don't quite understand why in help.c it has that NULL, which should always result in an EFAULT and other than that basically is

a

Quoted 5 lines
Quoted 2 lines

NOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead? So I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.

Yes, it's an usleep(autocorrect * 100000) basically (poll takes milliseconds, not micro).

OK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:
/* EFAULT is not necessary to implement, but let's do it in the
simplest case. */
if (!pfd)

    {
      errno = EFAULT;
      return -1;
    }

poll() is doing this before calling select(), so won't sleep. So there's a bug in {gnulib|git}'s poll(), right?

Quoted 28 lines
Quoted 28 lines

...

# else
      char data[64];
      r = recv (fd, data, sizeof (data), MSG_PEEK);
      socket_errno = (r < 0) ? errno : 0;
# endif
      if (r == 0)
        happened |= POLLHUP;
      /* If the event happened on an unconnected server socket,
         that's fine. */
      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
        happened |= (POLLIN | POLLRDNORM) & sought;

      /* Distinguish hung-up sockets from other errors.  */
      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
        happened |= POLLHUP;
#ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */
      else if (socket_errno == ENOTSOCK)
        happened |= (POLLIN | POLLRDNORM) & sought;
#endif
      else
        happened |= POLLERR;
    }

...

Quoted 6 lines
Quoted 3 lines

We won't detect POLLHUP that way I think. However it seems to work, we've been able to clone, push, pull, branch that way with NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that). Someone in for a cleaner way of managing this?

I suppose it works to always handle ENOTSOCK that way, even on non-__TANDEM systems.

So you think this is a clean way of dealing with it?

Bye, Jojo

#8 lore raw

Il 06/09/2012 16:44, Joachim Schmitz ha scritto:

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Yes, it's an usleep(autocorrect * 100000) basically (poll takes milliseconds, not micro).

OK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:
/* EFAULT is not necessary to implement, but let's do it in the
simplest case. */
if (!pfd)

Quoted 8 lines
    {
      errno = EFAULT;
      return -1;
    }

poll() is doing this before calling select(), so won't sleep. So there's a bug in {gnulib|git}'s poll(), right?

Yes, it should be "if (!pfd && nfd)".

Paolo

#9 lore raw
Quoted 18 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Thursday, September 06, 2012 5:15 PM
To: Joachim Schmitz
Cc: [email protected]; 'Junio C Hamano'; 'Erik Faye-Lund'; [email protected]; [email protected]
Subject: Re: poll() emulation in git

Il 06/09/2012 16:44, Joachim Schmitz ha scritto:

Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

Yes, it's an usleep(autocorrect * 100000) basically (poll takes milliseconds, not micro).

OK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:
/* EFAULT is not necessary to implement, but let's do it in the
simplest case. */
if (!pfd)

    {
      errno = EFAULT;
      return -1;
    }
Quoted 5 lines
Quoted 3 lines

poll() is doing this before calling select(), so won't sleep. So there's a bug in {gnulib|git}'s poll(), right?

Yes, it should be "if (!pfd && nfd)".

Are you going to fix this in gnulib?

Bye, Jojo

#10 lore raw
In reply to Paolo Bonzini
Quoted 35 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini
Sent: Thursday, September 06, 2012 4:32 PM
To: Joachim Schmitz
Cc: [email protected]; 'Junio C Hamano'; 'Erik Faye-Lund'; [email protected]; [email protected]
Subject: Re: poll() emulation in git

Il 06/09/2012 16:02, Joachim Schmitz ha scritto:

Quoted 28 lines

...

# else
      char data[64];
      r = recv (fd, data, sizeof (data), MSG_PEEK);
      socket_errno = (r < 0) ? errno : 0;
# endif
      if (r == 0)
        happened |= POLLHUP;
      /* If the event happened on an unconnected server socket,
         that's fine. */
      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
        happened |= (POLLIN | POLLRDNORM) & sought;

      /* Distinguish hung-up sockets from other errors.  */
      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
        happened |= POLLHUP;
#ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */
      else if (socket_errno == ENOTSOCK)
        happened |= (POLLIN | POLLRDNORM) & sought;
#endif
      else
        happened |= POLLERR;
    }

...

Quoted 6 lines
Quoted 3 lines

We won't detect POLLHUP that way I think. However it seems to work, we've been able to clone, push, pull, branch that way with NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that). Someone in for a cleaner way of managing this?

I suppose it works to always handle ENOTSOCK that way, even on non-__TANDEM systems.

Will you be fixing this in gnulib? How?

Bye, Jojo

#11 lore raw

Il 07/09/2012 09:39, Joachim Schmitz ha scritto:

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

I suppose it works to always handle ENOTSOCK that way, even on non-__TANDEM systems.

Will you be fixing this in gnulib? How?

I don't have access to the system, so it's best if you post the patches yourself to bug-gnulib and git mailing lists (separately, since the code is cross-pollinated but forked).

Paolo

#12 lore raw
In reply to Joachim Schmitz
Quoted 64 lines · Joachim Schmitz
Quoted 58 lines

From: Joachim Schmitz [mailto:[email protected]]
Sent: Tuesday, September 04, 2012 1:49 PM
To: 'Junio C Hamano'
Cc: '[email protected]'; 'Erik Faye-Lund'
Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 10 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Friday, August 24, 2012 9:47 PM
To: Joachim Schmitz
Cc: [email protected]; 'Erik Faye-Lund'
Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 1 line · Joachim Schmitz

Different, but related question: would poll.[ch] be allowed to #include "git-compat-util.h"?

Quoted 7 lines

Seeing other existing generic wrappers directly under compat/, e.g. fopen.c, mkdtemp.c, doing so, I would say why not.

Windows folks (I see Erik is already CC'ed, which is good ;-), please work with Joachim to make sure such a move won't break your builds. I believe that it should just be the matter of updating a couple of paths in the top-level Makefile.

Haven't heard anything from the Windows folks yet.

I'd prefer to move compat/win32/poll.[ch] into compat/poll. Then adjust a few paths in Makefile and that would be the 1st patch

A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.

compat/poll/poll.c +6 -3
index 403eaa7..49541f1 100644
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif
 
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
 
--
Quoted 1 line

1.7.12

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all kind if file descriptors, at least that is my understanding.

Quoted 8 lines

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a socket to talk to, so the poll() just hangs/loops.

As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo

Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?
There is some code that pertains to a seemingly similar problem in Mac OS X, but my problem is not identical, as that fix doesn't help.

Could you give more context ? Are you speaking about win32 or about HP non stop?

If so pipe are broken and unfixable under windows see
http://www.mail-archive.com/[email protected]/msg23365.html

Quoted 3 lines

Bye, Jojo

#13 lore raw
Quoted 74 lines

From: Bastien ROUCARIES [mailto:[email protected]]
Sent: Wednesday, September 05, 2012 1:55 PM
To: Joachim Schmitz
Cc: Junio C Hamano; Paolo Bonzini; [email protected]; [email protected]; Erik Faye-Lund
Subject: Re: poll() emulation in git

Quoted 67 lines · Joachim Schmitz
Quoted 58 lines

From: Joachim Schmitz [mailto:[email protected]]
Sent: Tuesday, September 04, 2012 1:49 PM
To: 'Junio C Hamano'
Cc: '[email protected]'; 'Erik Faye-Lund'
Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 10 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Friday, August 24, 2012 9:47 PM
To: Joachim Schmitz
Cc: [email protected]; 'Erik Faye-Lund'
Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 1 line · Joachim Schmitz

Different, but related question: would poll.[ch] be allowed to #include "git-compat-util.h"?

Quoted 7 lines

Seeing other existing generic wrappers directly under compat/, e.g. fopen.c, mkdtemp.c, doing so, I would say why not.

Windows folks (I see Erik is already CC'ed, which is good ;-), please work with Joachim to make sure such a move won't break your builds. I believe that it should just be the matter of updating a couple of paths in the top-level Makefile.

Haven't heard anything from the Windows folks yet.

I'd prefer to move compat/win32/poll.[ch] into compat/poll. Then adjust a few paths in Makefile and that would be the 1st patch

A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.

compat/poll/poll.c +6 -3
index 403eaa7..49541f1 100644
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif
 
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
 
--
Quoted 1 line

1.7.12

However: this poll implementation, while compiling OK, doesn't work properly.
Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all kind if file descriptors, at least that is my understanding.

Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a socket to talk to, so the poll() just hangs/loops.

Quoted 7 lines
Quoted 5 lines

As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo

Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?
There is some code that pertains to a seemingly similar problem in Mac OS X, but my problem is not identical, as that fix doesn't help.

Could you give more context ? Are you speaking about win32 or about HP non stop?

HP NonStop

Quoted 2 lines

If so pipe are broken and unfixable under windows see
http://www.mail-archive.com/[email protected]/msg23365.html

Bye, Jojo