From cbf5ef6680cfa231168eed0b7be5b21081098116 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 31 Jul 2010 21:48:48 +0200 Subject: [PATCH] Allow empty /dev/stdin For example: PAGER=elinks git diff shows nothing, when repo is not dirty. --- src/protocol/file/file.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/protocol/file/file.c b/src/protocol/file/file.c index 843d9824..b35b77ce 100644 --- a/src/protocol/file/file.c +++ b/src/protocol/file/file.c @@ -207,6 +207,16 @@ list_directory(struct connection *conn, unsigned char *dirpath, return connection_state(S_OK); } +static void +check_if_closed(struct socket *socket, struct read_buffer *rb) +{ + if (socket->state == SOCKET_CLOSED) { + abort_connection(socket->conn, connection_state(S_OK)); + return; + } + http_got_header(socket, rb); +} + static void read_from_stdin(struct connection *conn) { @@ -222,7 +232,7 @@ read_from_stdin(struct connection *conn) conn->socket->state = SOCKET_END_ONCLOSE; read_from_socket(conn->socket, rb, connection_state(S_SENT), - http_got_header); + check_if_closed); } /* To reduce redundant error handling code [calls to abort_connection()]