summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/serverloop.c b/serverloop.c
index 1bc5d8b75..79bdf77ba 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -259,20 +259,15 @@ process_input(fd_set * readset)
259 if (len == 0) { 259 if (len == 0) {
260 verbose("Connection closed by remote host."); 260 verbose("Connection closed by remote host.");
261 fatal_cleanup(); 261 fatal_cleanup();
262 } else if (len < 0) {
263 if (errno != EINTR && errno != EAGAIN) {
264 verbose("Read error from remote host: %.100s", strerror(errno));
265 fatal_cleanup();
266 }
267 } else {
268 /* Buffer any received data. */
269 packet_process_incoming(buf, len);
262 } 270 }
263 /*
264 * There is a kernel bug on Solaris that causes select to
265 * sometimes wake up even though there is no data available.
266 */
267 if (len < 0 && errno == EAGAIN)
268 len = 0;
269
270 if (len < 0) {
271 verbose("Read error from remote host: %.100s", strerror(errno));
272 fatal_cleanup();
273 }
274 /* Buffer any received data. */
275 packet_process_incoming(buf, len);
276 } 271 }
277 if (compat20) 272 if (compat20)
278 return; 273 return;
@@ -280,9 +275,11 @@ process_input(fd_set * readset)
280 /* Read and buffer any available stdout data from the program. */ 275 /* Read and buffer any available stdout data from the program. */
281 if (!fdout_eof && FD_ISSET(fdout, readset)) { 276 if (!fdout_eof && FD_ISSET(fdout, readset)) {
282 len = read(fdout, buf, sizeof(buf)); 277 len = read(fdout, buf, sizeof(buf));
283 if (len <= 0) 278 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
279 /* do nothing */
280 } else if (len <= 0) {
284 fdout_eof = 1; 281 fdout_eof = 1;
285 else { 282 } else {
286 buffer_append(&stdout_buffer, buf, len); 283 buffer_append(&stdout_buffer, buf, len);
287 fdout_bytes += len; 284 fdout_bytes += len;
288 } 285 }
@@ -290,10 +287,13 @@ process_input(fd_set * readset)
290 /* Read and buffer any available stderr data from the program. */ 287 /* Read and buffer any available stderr data from the program. */
291 if (!fderr_eof && FD_ISSET(fderr, readset)) { 288 if (!fderr_eof && FD_ISSET(fderr, readset)) {
292 len = read(fderr, buf, sizeof(buf)); 289 len = read(fderr, buf, sizeof(buf));
293 if (len <= 0) 290 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
291 /* do nothing */
292 } else if (len <= 0) {
294 fderr_eof = 1; 293 fderr_eof = 1;
295 else 294 } else {
296 buffer_append(&stderr_buffer, buf, len); 295 buffer_append(&stderr_buffer, buf, len);
296 }
297 } 297 }
298} 298}
299 299
@@ -309,7 +309,9 @@ process_output(fd_set * writeset)
309 if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) { 309 if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
310 len = write(fdin, buffer_ptr(&stdin_buffer), 310 len = write(fdin, buffer_ptr(&stdin_buffer),
311 buffer_len(&stdin_buffer)); 311 buffer_len(&stdin_buffer));
312 if (len <= 0) { 312 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
313 /* do nothing */
314 } else if (len <= 0) {
313#ifdef USE_PIPES 315#ifdef USE_PIPES
314 close(fdin); 316 close(fdin);
315#else 317#else
@@ -396,6 +398,12 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
396 fdin = fdin_arg; 398 fdin = fdin_arg;
397 fdout = fdout_arg; 399 fdout = fdout_arg;
398 fderr = fderr_arg; 400 fderr = fderr_arg;
401
402 /* nonblocking IO */
403 set_nonblock(fdin);
404 set_nonblock(fdout);
405 set_nonblock(fderr);
406
399 connection_in = packet_get_connection_in(); 407 connection_in = packet_get_connection_in();
400 connection_out = packet_get_connection_out(); 408 connection_out = packet_get_connection_out();
401 409