=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/clientloop.c,v retrieving revision 1.248.2.1 retrieving revision 1.249 diff -u -r1.248.2.1 -r1.249 --- src/usr.bin/ssh/clientloop.c 2013/11/08 05:52:21 1.248.2.1 +++ src/usr.bin/ssh/clientloop.c 2013/05/16 02:00:34 1.249 @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.248.2.1 2013/11/08 05:52:21 djm Exp $ */ +/* $OpenBSD: clientloop.c,v 1.249 2013/05/16 02:00:34 dtucker Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -575,7 +575,7 @@ { struct timeval tv, *tvp; int timeout_secs; - time_t minwait_secs = 0; + time_t minwait_secs = 0, server_alive_time = 0, now = time(NULL); int ret; /* Add any selections by the channel mechanism. */ @@ -624,12 +624,16 @@ */ timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */ - if (options.server_alive_interval > 0 && compat20) + if (options.server_alive_interval > 0 && compat20) { timeout_secs = options.server_alive_interval; + server_alive_time = now + options.server_alive_interval; + } + if (options.rekey_interval > 0 && compat20 && !rekeying) + timeout_secs = MIN(timeout_secs, packet_get_rekey_timeout()); set_control_persist_exit_time(); if (control_persist_exit_time > 0) { timeout_secs = MIN(timeout_secs, - control_persist_exit_time - time(NULL)); + control_persist_exit_time - now); if (timeout_secs < 0) timeout_secs = 0; } @@ -661,8 +665,15 @@ snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno)); buffer_append(&stderr_buffer, buf, strlen(buf)); quit_pending = 1; - } else if (ret == 0) - server_alive_check(); + } else if (ret == 0) { + /* + * Timeout. Could have been either keepalive or rekeying. + * Keepalive we check here, rekeying is checked in clientloop. + */ + if (server_alive_time != 0 && server_alive_time <= time(NULL)) + server_alive_check(); + } + } static void @@ -819,7 +830,7 @@ client_expect_confirm(int id, const char *request, enum confirm_action action) { - struct channel_reply_ctx *cr = xcalloc(1, sizeof(*cr)); + struct channel_reply_ctx *cr = xmalloc(sizeof(*cr)); cr->request_type = request; cr->action = action; @@ -842,7 +853,7 @@ return; } - gc = xcalloc(1, sizeof(*gc)); + gc = xmalloc(sizeof(*gc)); gc->cb = cb; gc->ctx = ctx; gc->ref_count = 1; @@ -1417,7 +1428,7 @@ { struct escape_filter_ctx *ret; - ret = xcalloc(1, sizeof(*ret)); + ret = xmalloc(sizeof(*ret)); ret->escape_pending = 0; ret->escape_char = escape_char; return (void *)ret;