From d8d3fa7f696c03ecd58960ea9029ae9733fb9ced Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 19 Dec 1995 10:40:07 +0000 Subject: allow at most 256K of data to be queued --- gnu/usr.bin/cvs/src/server.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'gnu/usr.bin') diff --git a/gnu/usr.bin/cvs/src/server.c b/gnu/usr.bin/cvs/src/server.c index ebdefbb90d5..9053f6c5013 100644 --- a/gnu/usr.bin/cvs/src/server.c +++ b/gnu/usr.bin/cvs/src/server.c @@ -1094,6 +1094,7 @@ static void buf_output PROTO((struct buffer *, const char *, int)); static void buf_output0 PROTO((struct buffer *, const char *)); static inline void buf_append_char PROTO((struct buffer *, int)); static int buf_send_output PROTO((struct buffer *)); +static int buf_len PROTO((struct buffer *)); static int set_nonblock PROTO((struct buffer *)); static int set_block PROTO((struct buffer *)); static int buf_send_counted PROTO((struct buffer *)); @@ -1255,6 +1256,29 @@ buf_append_char (buf, ch) } } +/* + * Count how many bytes are in the buffer + */ + +static int +buf_len (buf) + struct buffer *buf; +{ + struct buffer_data *data; + int count = 0; + + if (! buf->output) + abort (); + + for (data = buf->data; data; data = data->next) + { + count += data->size; + } + + return (count); +} + + /* * Send all the output we've been saving up. Returns 0 for success or * errno code. If the buffer has been set to be nonblocking, this @@ -2141,7 +2165,7 @@ do_cvs_command (command) FD_ZERO (&writefds); if (! buf_empty_p (&outbuf)) FD_SET (STDOUT_FILENO, &writefds); - if (stdout_pipe[0] >= 0) + if (stdout_pipe[0] >= 0 && buf_len (&outbuf) < 256*1024) { FD_SET (stdout_pipe[0], &readfds); } -- cgit v1.2.3