{"thread":{"id":"31443","subject":"RE: poll() emulation in git","startedAt":"2012-09-05T11:24:25Z","lastAt":"2012-09-07T09:40:47Z","messageCount":14,"participants":["Joachim Schmitz","Bastien ROUCARIES","Paolo Bonzini"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"198372","messageId":"00c001cd8b59$028e41c0$07aac540$@schmitz-digital.de","threadId":"31443","inReplyTo":null,"subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-05T11:24:25Z","receivedAt":"2012-09-05T11:24:25Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> Sent: Tuesday, September 04, 2012 1:49 PM\n> To: 'Junio C Hamano'\n> Cc: 'git@vger.kernel.org'; 'Erik Faye-Lund'\n> Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n> \n> > From: Junio C Hamano [mailto:gitster@pobox.com]\n> > Sent: Friday, August 24, 2012 9:47 PM\n> > To: Joachim Schmitz\n> > Cc: git@vger.kernel.org; 'Erik Faye-Lund'\n> > Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n> >\n> > \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> >\n> > > Different, but related question: would poll.[ch] be allowed to #include \"git-compat-util.h\"?\n> >\n> > Seeing other existing generic wrappers directly under compat/,\n> > e.g. fopen.c, mkdtemp.c, doing so, I would say why not.\n> >\n> > Windows folks (I see Erik is already CC'ed, which is good ;-),\n> > please work with Joachim to make sure such a move won't break your\n> > builds.  I believe that it should just be the matter of updating a\n> > couple of paths in the top-level Makefile.\n> \n> Haven't heard anything from the Windows folks yet.\n> \n> I'd prefer to move compat/win32/poll.[ch] into compat/poll.\n> Then adjust a few paths in Makefile and that would be the 1st patch\n> \n> A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.\n> \n> diff --git a/compat/poll/poll.c b/compat/poll/poll.c\n> index 403eaa7..49541f1 100644\n> --- a/compat/poll/poll.c\n> +++ b/compat/poll/poll.c\n> @@ -24,7 +24,9 @@\n>  # pragma GCC diagnostic ignored \"-Wtype-limits\"\n>  #endif\n> \n> -#include <malloc.h>\n> +#if defined(WIN32)\n> +# include <malloc.h>\n> +#endif\n> \n>  #include <sys/types.h>\n> \n> @@ -48,7 +50,9 @@\n>  #else\n>  # include <sys/time.h>\n>  # include <sys/socket.h>\n> -# include <sys/select.h>\n> +# ifndef NO_SYS_SELECT_H\n> +#  include <sys/select.h>\n> +# endif\n>  # include <unistd.h>\n>  #endif\n> \n> --\n> 1.7.12\n\nHowever: this poll implementation, while compiling OK, doesn't work properly.\nBecause it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all\nkind if file descriptors, at least that is my understanding.\n\nHere on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a\nsocket to talk to, so the poll() just hangs/loops.\n\nAs git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo\n\nAny idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?\nThere 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\nhelp.\n\nBye, Jojo\n"},{"id":"198375","messageId":"CAE2SPAZnq1y7SuCAsS0YJ8wv6=L-QJiay03BerSZvgyqXyPX8w@mail.gmail.com","threadId":"31443","inReplyTo":"00c001cd8b59$028e41c0$07aac540$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Bastien ROUCARIES","fromEmail":"roucaries.bastien@gmail.com","sentAt":"2012-09-05T11:55:18Z","receivedAt":"2012-09-05T11:55:18Z","isPatch":false,"sender":{"key":"roucaries.bastien@gmail.com","avatar":null},"body":"On Wed, Sep 5, 2012 at 1:24 PM, Joachim Schmitz <jojo@schmitz-digital.de> wrote:\n>> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n>> Sent: Tuesday, September 04, 2012 1:49 PM\n>> To: 'Junio C Hamano'\n>> Cc: 'git@vger.kernel.org'; 'Erik Faye-Lund'\n>> Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n>>\n>> > From: Junio C Hamano [mailto:gitster@pobox.com]\n>> > Sent: Friday, August 24, 2012 9:47 PM\n>> > To: Joachim Schmitz\n>> > Cc: git@vger.kernel.org; 'Erik Faye-Lund'\n>> > Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n>> >\n>> > \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n>> >\n>> > > Different, but related question: would poll.[ch] be allowed to #include \"git-compat-util.h\"?\n>> >\n>> > Seeing other existing generic wrappers directly under compat/,\n>> > e.g. fopen.c, mkdtemp.c, doing so, I would say why not.\n>> >\n>> > Windows folks (I see Erik is already CC'ed, which is good ;-),\n>> > please work with Joachim to make sure such a move won't break your\n>> > builds.  I believe that it should just be the matter of updating a\n>> > couple of paths in the top-level Makefile.\n>>\n>> Haven't heard anything from the Windows folks yet.\n>>\n>> I'd prefer to move compat/win32/poll.[ch] into compat/poll.\n>> Then adjust a few paths in Makefile and that would be the 1st patch\n>>\n>> A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.\n>>\n>> diff --git a/compat/poll/poll.c b/compat/poll/poll.c\n>> index 403eaa7..49541f1 100644\n>> --- a/compat/poll/poll.c\n>> +++ b/compat/poll/poll.c\n>> @@ -24,7 +24,9 @@\n>>  # pragma GCC diagnostic ignored \"-Wtype-limits\"\n>>  #endif\n>>\n>> -#include <malloc.h>\n>> +#if defined(WIN32)\n>> +# include <malloc.h>\n>> +#endif\n>>\n>>  #include <sys/types.h>\n>>\n>> @@ -48,7 +50,9 @@\n>>  #else\n>>  # include <sys/time.h>\n>>  # include <sys/socket.h>\n>> -# include <sys/select.h>\n>> +# ifndef NO_SYS_SELECT_H\n>> +#  include <sys/select.h>\n>> +# endif\n>>  # include <unistd.h>\n>>  #endif\n>>\n>> --\n>> 1.7.12\n>\n> However: this poll implementation, while compiling OK, doesn't work properly.\n> Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all\n> kind if file descriptors, at least that is my understanding.\n>\n> Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a\n> socket to talk to, so the poll() just hangs/loops.\n>\n> As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo\n>\n> Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?\n> 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\n> help.\n\nCould you give more context ? Are you speaking about win32 or about HP non stop?\n\nIf so pipe are broken and unfixable under windows see\nhttp://www.mail-archive.com/bug-gnulib@gnu.org/msg23365.html\n\n> Bye, Jojo\n>\n>\n"},{"id":"198377","messageId":"00c601cd8b5e$8d22fec0$a768fc40$@schmitz-digital.de","threadId":"31443","inReplyTo":"CAE2SPAZnq1y7SuCAsS0YJ8wv6=L-QJiay03BerSZvgyqXyPX8w@mail.gmail.com","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-05T12:04:06Z","receivedAt":"2012-09-05T12:04:06Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Bastien ROUCARIES [mailto:roucaries.bastien@gmail.com]\n> Sent: Wednesday, September 05, 2012 1:55 PM\n> To: Joachim Schmitz\n> Cc: Junio C Hamano; Paolo Bonzini; bug-gnulib@gnu.org; git@vger.kernel.org; Erik Faye-Lund\n> Subject: Re: poll() emulation in git\n> \n> On Wed, Sep 5, 2012 at 1:24 PM, Joachim Schmitz <jojo@schmitz-digital.de> wrote:\n> >> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> >> Sent: Tuesday, September 04, 2012 1:49 PM\n> >> To: 'Junio C Hamano'\n> >> Cc: 'git@vger.kernel.org'; 'Erik Faye-Lund'\n> >> Subject: RE: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n> >>\n> >> > From: Junio C Hamano [mailto:gitster@pobox.com]\n> >> > Sent: Friday, August 24, 2012 9:47 PM\n> >> > To: Joachim Schmitz\n> >> > Cc: git@vger.kernel.org; 'Erik Faye-Lund'\n> >> > Subject: Re: [PATCH v2] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact\n> >> >\n> >> > \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> >> >\n> >> > > Different, but related question: would poll.[ch] be allowed to #include \"git-compat-util.h\"?\n> >> >\n> >> > Seeing other existing generic wrappers directly under compat/,\n> >> > e.g. fopen.c, mkdtemp.c, doing so, I would say why not.\n> >> >\n> >> > Windows folks (I see Erik is already CC'ed, which is good ;-),\n> >> > please work with Joachim to make sure such a move won't break your\n> >> > builds.  I believe that it should just be the matter of updating a\n> >> > couple of paths in the top-level Makefile.\n> >>\n> >> Haven't heard anything from the Windows folks yet.\n> >>\n> >> I'd prefer to move compat/win32/poll.[ch] into compat/poll.\n> >> Then adjust a few paths in Makefile and that would be the 1st patch\n> >>\n> >> A 2nd patch would be my already proposed ones that make this usable for others (me in this case ;-)), namely wrapping 2 #inludes.\n> >>\n> >> diff --git a/compat/poll/poll.c b/compat/poll/poll.c\n> >> index 403eaa7..49541f1 100644\n> >> --- a/compat/poll/poll.c\n> >> +++ b/compat/poll/poll.c\n> >> @@ -24,7 +24,9 @@\n> >>  # pragma GCC diagnostic ignored \"-Wtype-limits\"\n> >>  #endif\n> >>\n> >> -#include <malloc.h>\n> >> +#if defined(WIN32)\n> >> +# include <malloc.h>\n> >> +#endif\n> >>\n> >>  #include <sys/types.h>\n> >>\n> >> @@ -48,7 +50,9 @@\n> >>  #else\n> >>  # include <sys/time.h>\n> >>  # include <sys/socket.h>\n> >> -# include <sys/select.h>\n> >> +# ifndef NO_SYS_SELECT_H\n> >> +#  include <sys/select.h>\n> >> +# endif\n> >>  # include <unistd.h>\n> >>  #endif\n> >>\n> >> --\n> >> 1.7.12\n> >\n> > However: this poll implementation, while compiling OK, doesn't work properly.\n> > Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all\n> > kind if file descriptors, at least that is my understanding.\n> >\n> > Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a\n> > socket to talk to, so the poll() just hangs/loops.\n> >\n> > As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo\n> >\n> > Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?\n> > 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\n> > help.\n> \n> Could you give more context ? Are you speaking about win32 or about HP non stop?\n\nHP NonStop\n\n> If so pipe are broken and unfixable under windows see\n> http://www.mail-archive.com/bug-gnulib@gnu.org/msg23365.html\n\nBye, Jojo\n"},{"id":"198378","messageId":"50474001.5030407@gnu.org","threadId":"31443","inReplyTo":"00c001cd8b59$028e41c0$07aac540$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2012-09-05T12:05:21Z","receivedAt":"2012-09-05T12:05:21Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Il 05/09/2012 13:24, Joachim Schmitz ha scritto:\n> However: this poll implementation, while compiling OK, doesn't work properly.\n> Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on all\n> kind if file descriptors, at least that is my understanding.\n\nActually recv(...,MSG_PEEK) on most Unix variants works on non-sockets\ntoo.  The trick is taken from GNU Pth in turn.\n\n> Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a\n> socket to talk to, so the poll() just hangs/loops.\n\nDoes your system have a working FIONREAD ioctl for pipes?\n\n> As git's implementation is based on ('stolen' from?) gnulib's and still pretty similar, CC to the gnulib list and Paolo\n> \n> Any idea how this could get solved? I.e. how to implement a poll() that works on non-sockets too?\n> 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\n> help.\n\nPaolo\n"},{"id":"198379","messageId":"00cf01cd8b66$034793c0$09d6bb40$@schmitz-digital.de","threadId":"31443","inReplyTo":"50474001.5030407@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-05T12:57:31Z","receivedAt":"2012-09-05T12:57:31Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> Sent: Wednesday, September 05, 2012 2:05 PM\n> To: Joachim Schmitz\n> Cc: 'Junio C Hamano'; git@vger.kernel.org; 'Erik Faye-Lund'; bug-gnulib@gnu.org\n> Subject: Re: poll() emulation in git\n> \n> Il 05/09/2012 13:24, Joachim Schmitz ha scritto:\n> > However: this poll implementation, while compiling OK, doesn't work properly.\n> > Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works on\nall\n> > kind if file descriptors, at least that is my understanding.\n> \n> Actually recv(...,MSG_PEEK) on most Unix variants works on non-sockets\n> too.  The trick is taken from GNU Pth in turn.\n> \n> > Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of a\n> > socket to talk to, so the poll() just hangs/loops.\n> \n> Does your system have a working FIONREAD ioctl for pipes?\n\nIt does have FIONREAD ioctl. Whether it works properly is to be determined...\nI'll test if you could show me how?\n\n\nBye, Jojo\n"},{"id":"198380","messageId":"00d801cd8b6b$844bbcd0$8ce33670$@schmitz-digital.de","threadId":"31443","inReplyTo":"50474001.5030407@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-05T13:36:54Z","receivedAt":"2012-09-05T13:36:54Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> Sent: Wednesday, September 05, 2012 2:58 PM\n> To: 'Paolo Bonzini'\n> Cc: 'Junio C Hamano'; 'git@vger.kernel.org'; 'Erik Faye-Lund'; 'bug-gnulib@gnu.org'\n> Subject: RE: poll() emulation in git\n> \n> > From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> > Sent: Wednesday, September 05, 2012 2:05 PM\n> > To: Joachim Schmitz\n> > Cc: 'Junio C Hamano'; git@vger.kernel.org; 'Erik Faye-Lund'; bug-gnulib@gnu.org\n> > Subject: Re: poll() emulation in git\n> >\n> > Il 05/09/2012 13:24, Joachim Schmitz ha scritto:\n> > > However: this poll implementation, while compiling OK, doesn't work properly.\n> > > Because it uses recv(...,MSG_PEEK), it works on sockets only (returns ENOTSOCK on anything else), while the real poll() works\non all\n> > > kind if file descriptors, at least that is my understanding.\n> >\n> > Actually recv(...,MSG_PEEK) on most Unix variants works on non-sockets\n> > too.  The trick is taken from GNU Pth in turn.\n> >\n> > > Here on HP NonStop, when being connected via an non-interactive SSH, we get a set of pipes (stdin, stdout, stderr) instead of\na\n> > > socket to talk to, so the poll() just hangs/loops.\n> >\n> > Does your system have a working FIONREAD ioctl for pipes?\n> \n> It does have FIONREAD ioctl. Whether it works properly is to be determined...\n> I'll test if you could show me how?\n\nOh, 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).\n\nAnd <sys/ioctl.h> has\n/*\n * Normal IOCTL's supported by the socket interface\n */\n#define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */\n#define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */\n\nSo these seem to be supported on sockets only, I guess.\nAnd indeed the man pages for ioctl confirms:\n\n          Valid values for the request parameter for AF_INET or\n          AF_INET6 sockets are:\n\n\n          FIONREAD  Gets the number of bytes available for reading and\n                    stores it at the int pointed at by arg.\n\n\nSo not even AF_UNIX sockets, not to mention pipes...\n\nBye, Jojo\n"},{"id":"198388","messageId":"50476EFD.2000500@gnu.org","threadId":"31443","inReplyTo":"00d801cd8b6b$844bbcd0$8ce33670$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2012-09-05T15:25:49Z","receivedAt":"2012-09-05T15:25:49Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Il 05/09/2012 15:36, Joachim Schmitz ha scritto:\n>>> > > Does your system have a working FIONREAD ioctl for pipes?\n>> > \n>> > It does have FIONREAD ioctl. Whether it works properly is to be determined...\n>> > I'll test if you could show me how?\n> 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).\n> \n> And <sys/ioctl.h> has\n> /*\n>  * Normal IOCTL's supported by the socket interface\n>  */\n> #define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */\n> #define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */\n> \n> So these seem to be supported on sockets only, I guess.\n> And indeed the man pages for ioctl confirms:\n> \n>           Valid values for the request parameter for AF_INET or\n>           AF_INET6 sockets are:\n> \n> \n>           FIONREAD  Gets the number of bytes available for reading and\n>                     stores it at the int pointed at by arg.\n> \n> \n> So not even AF_UNIX sockets, not to mention pipes...\n\nSo there's no way you can support POLLHUP.  Your system is quite\ncrippled. :(\n\nPaolo\n"},{"id":"198441","messageId":"010301cd8c38$4256bb90$c70432b0$@schmitz-digital.de","threadId":"31443","inReplyTo":"50476EFD.2000500@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-06T14:02:30Z","receivedAt":"2012-09-06T14:02:30Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> Sent: Wednesday, September 05, 2012 5:26 PM\n> To: Joachim Schmitz\n> Cc: 'Junio C Hamano'; git@vger.kernel.org; 'Erik Faye-Lund'; bug-gnulib@gnu.org\n> Subject: Re: poll() emulation in git\n> \n> Il 05/09/2012 15:36, Joachim Schmitz ha scritto:\n> >>> > > Does your system have a working FIONREAD ioctl for pipes?\n> >> >\n> >> > It does have FIONREAD ioctl. Whether it works properly is to be determined...\n> >> > I'll test if you could show me how?\n> > 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).\n> >\n> > And <sys/ioctl.h> has\n> > /*\n> >  * Normal IOCTL's supported by the socket interface\n> >  */\n> > #define FIONREAD        _IOR(0, 8, _ioctl_int)       /* Num of bytes to read */\n> > #define FIONBIO         _IOW(0, 9, _ioctl_int)       /* Non-blocking I/O     */\n> >\n> > So these seem to be supported on sockets only, I guess.\n> > And indeed the man pages for ioctl confirms:\n> >\n> >           Valid values for the request parameter for AF_INET or\n> >           AF_INET6 sockets are:\n> >\n> >\n> >           FIONREAD  Gets the number of bytes available for reading and\n> >                     stores it at the int pointed at by arg.\n> >\n> >\n> > So not even AF_UNIX sockets, not to mention pipes...\n> \n> So there's no way you can support POLLHUP.  Your system is quite\n> crippled. :(\n\nUnfortunatly.\n\nBut is there something that could be done to make git work even without poll()?\nIt is used in 5 places:\n\n$ grep -n poll\\( *.c */*.c\ncredential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {\ndaemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {\nhelp.c:361:                     poll(NULL, 0, autocorrect * 100);\nupload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {\nbuiltin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {\n\nDon'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\nNOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead?\nSo I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.\n\nIn daemon.c it seems to be all sockets it polls on, so it should work on NonStop.\nSame in credential-cache--daemon.c\n\nRemains upload-pack.c and builtin/upload-archive.c\nIn both start_command() gathers the FDs to poll() on and that indeed works on pipes -> problem on NonStop!\n\nSeeing that in those cases xread() takes care of EAGAIN, I've now used 'brute force' in poll.c:\n\n...\n# else\n      char data[64];\n      r = recv (fd, data, sizeof (data), MSG_PEEK);\n      socket_errno = (r < 0) ? errno : 0;\n# endif\n      if (r == 0)\n        happened |= POLLHUP;\n\n      /* If the event happened on an unconnected server socket,\n         that's fine. */\n      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))\n        happened |= (POLLIN | POLLRDNORM) & sought;\n\n      /* Distinguish hung-up sockets from other errors.  */\n      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET\n               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)\n        happened |= POLLHUP;\n\n#ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */\n      else if (socket_errno == ENOTSOCK)\n        happened |= (POLLIN | POLLRDNORM) & sought;\n#endif\n      else\n        happened |= POLLERR;\n    }\n...\n\nWe 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\nNonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that).\nSomeone in for a cleaner way of managing this?\n\nBye, Jojo\n"},{"id":"198447","messageId":"5048B3D0.2070809@gnu.org","threadId":"31443","inReplyTo":"010301cd8c38$4256bb90$c70432b0$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2012-09-06T14:31:44Z","receivedAt":"2012-09-06T14:31:44Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Il 06/09/2012 16:02, Joachim Schmitz ha scritto:\n> \n> But is there something that could be done to make git work even without poll()?\n> It is used in 5 places:\n> \n> $ grep -n poll\\( *.c */*.c\n> credential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {\n> daemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {\n> help.c:361:                     poll(NULL, 0, autocorrect * 100);\n> upload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {\n> builtin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {\n> \n> 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\n> NOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead?\n> So I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.\n\nYes, it's an usleep(autocorrect * 100000) basically (poll takes\nmilliseconds, not micro).\n\n> ...\n> # else\n>       char data[64];\n>       r = recv (fd, data, sizeof (data), MSG_PEEK);\n>       socket_errno = (r < 0) ? errno : 0;\n> # endif\n>       if (r == 0)\n>         happened |= POLLHUP;\n> \n>       /* If the event happened on an unconnected server socket,\n>          that's fine. */\n>       else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))\n>         happened |= (POLLIN | POLLRDNORM) & sought;\n> \n>       /* Distinguish hung-up sockets from other errors.  */\n>       else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET\n>                || socket_errno == ECONNABORTED || socket_errno == ENETRESET)\n>         happened |= POLLHUP;\n> \n> #ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */\n>       else if (socket_errno == ENOTSOCK)\n>         happened |= (POLLIN | POLLRDNORM) & sought;\n> #endif\n>       else\n>         happened |= POLLERR;\n>     }\n> ...\n> \n> 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\n> NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that).\n> Someone in for a cleaner way of managing this?\n\nI suppose it works to always handle ENOTSOCK that way, even on\nnon-__TANDEM systems.\n\nPaolo\n"},{"id":"198449","messageId":"010a01cd8c3e$25609500$7021bf00$@schmitz-digital.de","threadId":"31443","inReplyTo":"5048B3D0.2070809@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-06T14:44:39Z","receivedAt":"2012-09-06T14:44:39Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> Sent: Thursday, September 06, 2012 4:32 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; 'Junio C Hamano'; 'Erik Faye-Lund'; bug-gnulib@gnu.org; rsbecker@nexbridge.com\n> Subject: Re: poll() emulation in git\n> \n> Il 06/09/2012 16:02, Joachim Schmitz ha scritto:\n> >\n> > But is there something that could be done to make git work even without poll()?\n> > It is used in 5 places:\n> >\n> > $ grep -n poll\\( *.c */*.c\n> > credential-cache--daemon.c:175: if (poll(&pfd, 1, 1000 * wakeup) < 0) {\n> > daemon.c:1018:          if (poll(pfd, socklist->nr, -1) < 0) {\n> > help.c:361:                     poll(NULL, 0, autocorrect * 100);\n> > upload-pack.c:232:              if (poll(pfd, pollsize, -1) < 0) {\n> > builtin/upload-archive.c:125:           if (poll(pfd, 2, -1) < 0) {\n> >\n> > 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\na\n> > NOP (at least in the poll() emulation)? Seems a usleep(autocorrect * 100) is meant to happen here instead?\n> > So I think here a poll() isn't needed at all. But also the 'broken' one shouldn't harm too much.\n> \n> Yes, it's an usleep(autocorrect * 100000) basically (poll takes\n> milliseconds, not micro).\n\nOK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:\n  /* EFAULT is not necessary to implement, but let's do it in the\n     simplest case. */\n  if (!pfd)\n    {\n      errno = EFAULT;\n      return -1;\n    }\n\npoll() is doing this before calling select(), so won't sleep.\nSo there's a bug in {gnulib|git}'s poll(), right?\n\n> > ...\n> > # else\n> >       char data[64];\n> >       r = recv (fd, data, sizeof (data), MSG_PEEK);\n> >       socket_errno = (r < 0) ? errno : 0;\n> > # endif\n> >       if (r == 0)\n> >         happened |= POLLHUP;\n> >\n> >       /* If the event happened on an unconnected server socket,\n> >          that's fine. */\n> >       else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))\n> >         happened |= (POLLIN | POLLRDNORM) & sought;\n> >\n> >       /* Distinguish hung-up sockets from other errors.  */\n> >       else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET\n> >                || socket_errno == ECONNABORTED || socket_errno == ENETRESET)\n> >         happened |= POLLHUP;\n> >\n> > #ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */\n> >       else if (socket_errno == ENOTSOCK)\n> >         happened |= (POLLIN | POLLRDNORM) & sought;\n> > #endif\n> >       else\n> >         happened |= POLLERR;\n> >     }\n> > ...\n> >\n> > 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\n> > NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that).\n> > Someone in for a cleaner way of managing this?\n> \n> I suppose it works to always handle ENOTSOCK that way, even on\n> non-__TANDEM systems.\n\nSo you think this is a clean way of dealing with it?\n\nBye, Jojo\n"},{"id":"198454","messageId":"5048BDF6.2000602@gnu.org","threadId":"31443","inReplyTo":"010a01cd8c3e$25609500$7021bf00$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2012-09-06T15:15:02Z","receivedAt":"2012-09-06T15:15:02Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Il 06/09/2012 16:44, Joachim Schmitz ha scritto:\n>> > Yes, it's an usleep(autocorrect * 100000) basically (poll takes\n>> > milliseconds, not micro).\n> OK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:\n>   /* EFAULT is not necessary to implement, but let's do it in the\n>      simplest case. */\n>   if (!pfd)\n>     {\n>       errno = EFAULT;\n>       return -1;\n>     }\n> \n> poll() is doing this before calling select(), so won't sleep.\n> So there's a bug in {gnulib|git}'s poll(), right?\n> \n\nYes, it should be \"if (!pfd && nfd)\".\n\nPaolo\n"},{"id":"198505","messageId":"000d01cd8cc9$c027a070$4076e150$@schmitz-digital.de","threadId":"31443","inReplyTo":"5048BDF6.2000602@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-07T07:23:59Z","receivedAt":"2012-09-07T07:23:59Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> Sent: Thursday, September 06, 2012 5:15 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; 'Junio C Hamano'; 'Erik Faye-Lund'; bug-gnulib@gnu.org; rsbecker@nexbridge.com\n> Subject: Re: poll() emulation in git\n> \n> Il 06/09/2012 16:44, Joachim Schmitz ha scritto:\n> >> > Yes, it's an usleep(autocorrect * 100000) basically (poll takes\n> >> > milliseconds, not micro).\n> > OK, it is _supposed_ to do this usleep(), but is does not, as poll() returns early with EFAULT in this case:\n> >   /* EFAULT is not necessary to implement, but let's do it in the\n> >      simplest case. */\n> >   if (!pfd)\n> >     {\n> >       errno = EFAULT;\n> >       return -1;\n> >     }\n> >\n> > poll() is doing this before calling select(), so won't sleep.\n> > So there's a bug in {gnulib|git}'s poll(), right?\n> >\n> \n> Yes, it should be \"if (!pfd && nfd)\".\n\nAre you going to fix this in gnulib?\n\nBye, Jojo\n"},{"id":"198506","messageId":"000e01cd8ccb$e20301b0$a6090510$@schmitz-digital.de","threadId":"31443","inReplyTo":"5048B3D0.2070809@gnu.org","subject":"RE: poll() emulation in git","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-07T07:39:15Z","receivedAt":"2012-09-07T07:39:15Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini\n> Sent: Thursday, September 06, 2012 4:32 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; 'Junio C Hamano'; 'Erik Faye-Lund'; bug-gnulib@gnu.org; rsbecker@nexbridge.com\n> Subject: Re: poll() emulation in git\n> \n> Il 06/09/2012 16:02, Joachim Schmitz ha scritto:\n> > ...\n> > # else\n> >       char data[64];\n> >       r = recv (fd, data, sizeof (data), MSG_PEEK);\n> >       socket_errno = (r < 0) ? errno : 0;\n> > # endif\n> >       if (r == 0)\n> >         happened |= POLLHUP;\n> >\n> >       /* If the event happened on an unconnected server socket,\n> >          that's fine. */\n> >       else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))\n> >         happened |= (POLLIN | POLLRDNORM) & sought;\n> >\n> >       /* Distinguish hung-up sockets from other errors.  */\n> >       else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET\n> >                || socket_errno == ECONNABORTED || socket_errno == ENETRESET)\n> >         happened |= POLLHUP;\n> >\n> > #ifdef __TANDEM /* as we can't recv(...,MSG_PEEK) on a non-socket */\n> >       else if (socket_errno == ENOTSOCK)\n> >         happened |= (POLLIN | POLLRDNORM) & sought;\n> > #endif\n> >       else\n> >         happened |= POLLERR;\n> >     }\n> > ...\n> >\n> > 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\n> > NonStop being the (ssh-)server, something that didn't work at all without that hack (and yes, I believe it is just that).\n> > Someone in for a cleaner way of managing this?\n> \n> I suppose it works to always handle ENOTSOCK that way, even on\n> non-__TANDEM systems.\n\nWill you be fixing this in gnulib? How?\n\nBye, Jojo\n"},{"id":"198510","messageId":"5049C11F.1080700@gnu.org","threadId":"31443","inReplyTo":"000e01cd8ccb$e20301b0$a6090510$@schmitz-digital.de","subject":"Re: poll() emulation in git","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2012-09-07T09:40:47Z","receivedAt":"2012-09-07T09:40:47Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Il 07/09/2012 09:39, Joachim Schmitz ha scritto:\n>> > I suppose it works to always handle ENOTSOCK that way, even on\n>> > non-__TANDEM systems.\n> Will you be fixing this in gnulib? How?\n\nI don't have access to the system, so it's best if you post the patches\nyourself to bug-gnulib and git mailing lists (separately, since the code\nis cross-pollinated but forked).\n\nPaolo\n"}]}