Skip to content
  • Eric Wong's avatar
    xwrite: poll on non-blocking FDs · ef1cf016
    Eric Wong authored and Junio C Hamano's avatar Junio C Hamano committed
    write(2) can hit the same EAGAIN/EWOULDBLOCK errors as read(2),
    so busy-looping on a non-blocking FD is a waste of resources.
    
    Currently, I do not know of a way for this happen:
    
    * the NonBlocking directive in systemd does not apply to stdin,
      stdout, or stderr.
    
    * xinetd provides no way to set the non-blocking flag at all
    
    But theoretically, it's possible a careless C10K HTTP server
    could use pipe2(..., O_NONBLOCK) to setup a pipe for
    git-http-backend with only the intent to use non-blocking reads;
    but accidentally leave non-blocking set on the write end passed
    as stdout to git-upload-pack.
    
    Followup-to: 1079c4be
    
     ("xread: poll on non blocking fds")
    
    Signed-off-by: default avatarEric Wong <e@80x24.org>
    Reviewed-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    ef1cf016