List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] html.c: die when write fails
@ 2013-05-18 14:57 john
  2013-05-18 15:05 ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: john @ 2013-05-18 14:57 UTC (permalink / raw)


If we fail to write HTML output once, there's no point carrying on so
just write a failure message once and die.  By using Git's die_errno
function we also let the user know in what way the write failed.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 html.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html.c b/html.c
index f7772dc..03277db 100644
--- a/html.c
+++ b/html.c
@@ -78,7 +78,7 @@ char *fmtalloc(const char *format, ...)
 void html_raw(const char *data, size_t size)
 {
 	if (write(htmlfd, data, size) != size)
-		fprintf(stderr, "[html.c] html output truncated.\n");
+		die_errno("write error on html output");
 }
 
 void html(const char *txt)
-- 
1.8.3.rc2.285.gfc18c2c



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] html.c: die when write fails
  2013-05-18 14:57 [PATCH] html.c: die when write fails john
@ 2013-05-18 15:05 ` Jason
  2013-05-18 15:17   ` john
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2013-05-18 15:05 UTC (permalink / raw)


It seems reasonable to die like this. However, if we're going to start
using git's die_errno, I'd also like to use that in other places
instead of die().


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] html.c: die when write fails
  2013-05-18 15:05 ` Jason
@ 2013-05-18 15:17   ` john
  0 siblings, 0 replies; 3+ messages in thread
From: john @ 2013-05-18 15:17 UTC (permalink / raw)


On Sat, May 18, 2013 at 05:05:21PM +0200, Jason A. Donenfeld wrote:
> It seems reasonable to die like this. However, if we're going to start
> using git's die_errno, I'd also like to use that in other places
> instead of die().

Yeah, there are probably a lot of places that would be helped by this.
This was just the one I noticed when I mis-clicked and then clicked
again aborting the first request, which caused a spew of "html output
truncated" messages as CGit carried on generating the page.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-18 15:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-18 14:57 [PATCH] html.c: die when write fails john
2013-05-18 15:05 ` Jason
2013-05-18 15:17   ` john

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).