git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylvain Rabot <sylvain@abstraction.fr>
To: git@vger.kernel.org
Cc: Sylvain Rabot <sylvain@abstraction.fr>
Subject: [PATCH 2/4] gitweb: remove unnecessary test when closing file descriptor
Date: Thu, 30 Dec 2010 22:20:29 +0100	[thread overview]
Message-ID: <1293744031-17790-3-git-send-email-sylvain@abstraction.fr> (raw)
In-Reply-To: <1293744031-17790-1-git-send-email-sylvain@abstraction.fr>

it happens that closing file descriptor fails whereas
the blob is perfectly readable. According to perlman
the reasons could be:

   If the file handle came from a piped open, "close" will additionally
   return false if one of the other system calls involved fails, or if the
   program exits with non-zero status.  (If the only problem was that the
   program exited non-zero, $! will be set to 0.)  Closing a pipe also waits
   for the process executing on the pipe to complete, in case you want to
   look at the output of the pipe afterwards, and implicitly puts the exit
   status value of that command into $?.

   Prematurely closing the read end of a pipe (i.e. before the process writ-
   ing to it at the other end has closed it) will result in a SIGPIPE being
   delivered to the writer.  If the other end can't handle that, be sure to
   read all the data before closing the pipe.

In this case we don't mind that close fails.

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
---
 gitweb/gitweb.perl |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ea984b9..eae75ac 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3465,8 +3465,7 @@ sub run_highlighter {
 	my ($fd, $highlight, $syntax) = @_;
 	return $fd unless ($highlight && defined $syntax);
 
-	close $fd
-		or die_error(404, "Reading blob failed");
+	close $fd;
 	open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
 	          quote_command($highlight_bin).
 	          " --xhtml --fragment --syntax $syntax |"
-- 
1.7.3.4.523.g72f0d.dirty

  parent reply	other threads:[~2010-12-30 21:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-30 21:20 [PATCH 0/4 v4] minor gitweb modifications Sylvain Rabot
2010-12-30 21:20 ` [PATCH 1/4] gitweb: add extensions to highlight feature map Sylvain Rabot
2010-12-30 21:20 ` Sylvain Rabot [this message]
2011-01-05  0:15   ` [PATCH 2/4] gitweb: remove unnecessary test when closing file descriptor Junio C Hamano
2011-01-05  0:50     ` Jakub Narebski
2010-12-30 21:20 ` [PATCH 3/4] gitweb: add css class to remote url titles Sylvain Rabot
2010-12-30 21:20 ` [PATCH 4/4] gitweb: add vim modeline header which describes gitweb coding rule Sylvain Rabot
2011-01-01 10:41 ` [PATCH 0/4 v4] minor gitweb modifications Jonathan Nieder
2011-01-01 23:02   ` Jonathan Nieder
2011-01-02 16:27   ` Sylvain Rabot
2011-01-02 17:53     ` Jonathan Nieder

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=1293744031-17790-3-git-send-email-sylvain@abstraction.fr \
    --to=sylvain@abstraction.fr \
    --cc=git@vger.kernel.org \
    /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).