--- openssh-2.5.1p1-orig/clientloop.c Thu Feb 15 03:12:08 2001 +++ openssh-2.5.1p1/clientloop.c Mon Feb 19 23:17:41 2001 @@ -366,6 +366,9 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp) { + struct timeval tv = {0}; + tv.tv_sec = 180; /* Send a noop message every three minutes as a keepalive. */ + /* Add any selections by the channel mechanism. */ channel_prepare_select(readsetp, writesetp, maxfdp); @@ -404,7 +407,8 @@ * SSH_MSG_IGNORE packet when the timeout expires. */ - if (select((*maxfdp)+1, *readsetp, *writesetp, NULL, NULL) < 0) { + switch (select((*maxfdp)+1, *readsetp, *writesetp, NULL, &tv)) { + case -1: { char buf[100]; /* @@ -422,7 +426,21 @@ buffer_append(&stderr_buffer, buf, strlen(buf)); stderr_bytes += strlen(buf); quit_pending = 1; - } + + } + break; + + case 0: + /* Send a keepalive packet (not SSH_MSG_IGNORE as this crashes + * some servers...). + */ + packet_start(SSH_MSG_NONE); + packet_send(); + break; + + default: + break; + } } void