git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: Joachim Schmitz <jojo@schmitz-digital.de>
Cc: git@vger.kernel.org, 'Junio C Hamano' <gitster@pobox.com>,
	'Erik Faye-Lund' <kusmabite@gmail.com>,
	bug-gnulib@gnu.org, rsbecker@nexbridge.com
Subject: Re: poll() emulation in git
Date: Thu, 06 Sep 2012 16:31:44 +0200	[thread overview]
Message-ID: <5048B3D0.2070809@gnu.org> (raw)
In-Reply-To: <010301cd8c38$4256bb90$c70432b0$@schmitz-digital.de>

Il 06/09/2012 16:02, Joachim Schmitz ha scritto:
> 
> 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.

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

> ...
> # 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?

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

Paolo

  reply	other threads:[~2012-09-06 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 11:24 poll() emulation in git Joachim Schmitz
2012-09-05 11:55 ` Bastien ROUCARIES
2012-09-05 12:04   ` Joachim Schmitz
2012-09-05 12:05 ` Paolo Bonzini
2012-09-05 12:57   ` Joachim Schmitz
2012-09-05 13:36   ` Joachim Schmitz
2012-09-05 15:25     ` Paolo Bonzini
2012-09-06 14:02       ` Joachim Schmitz
2012-09-06 14:31         ` Paolo Bonzini [this message]
2012-09-06 14:44           ` Joachim Schmitz
2012-09-06 15:15             ` Paolo Bonzini
2012-09-07  7:23               ` Joachim Schmitz
2012-09-07  7:39           ` Joachim Schmitz
2012-09-07  9:40             ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5048B3D0.2070809@gnu.org \
    --to=bonzini@gnu.org \
    --cc=bug-gnulib@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jojo@schmitz-digital.de \
    --cc=kusmabite@gmail.com \
    --cc=rsbecker@nexbridge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).