Mercurial > dropbear
comparison common-session.c @ 1143:924ff1b959a2
only update keepalive timeout post-auth (when keepalives are sent)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 07 Aug 2015 21:02:49 +0800 |
parents | f6d3a16ecc71 |
children | a550e1e2e2a9 |
comparison
equal
deleted
inserted
replaced
1142:20b9baf6d451 | 1143:924ff1b959a2 |
---|---|
531 dropbear_close("Idle timeout"); | 531 dropbear_close("Idle timeout"); |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 static void update_timeout(long limit, long now, long last_event, long * timeout) { | 535 static void update_timeout(long limit, long now, long last_event, long * timeout) { |
536 TRACE(("update_timeout limit %ld, now %ld, last %ld, timeout %ld", | 536 TRACE2(("update_timeout limit %ld, now %ld, last %ld, timeout %ld", |
537 limit, now, last_event, *timeout)) | 537 limit, now, last_event, *timeout)) |
538 if (last_event > 0 && limit > 0) { | 538 if (last_event > 0 && limit > 0) { |
539 *timeout = MIN(*timeout, last_event+limit-now); | 539 *timeout = MIN(*timeout, last_event+limit-now); |
540 TRACE(("update to %ld", *timeout)) | 540 TRACE2(("new timeout %ld", *timeout)) |
541 } | 541 } |
542 } | 542 } |
543 | 543 |
544 static long select_timeout() { | 544 static long select_timeout() { |
545 /* determine the minimum timeout that might be required, so | 545 /* determine the minimum timeout that might be required, so |
552 if (ses.authstate.authdone != 1 && IS_DROPBEAR_SERVER) { | 552 if (ses.authstate.authdone != 1 && IS_DROPBEAR_SERVER) { |
553 /* AUTH_TIMEOUT is only relevant before authdone */ | 553 /* AUTH_TIMEOUT is only relevant before authdone */ |
554 update_timeout(AUTH_TIMEOUT, now, ses.connect_time, &timeout); | 554 update_timeout(AUTH_TIMEOUT, now, ses.connect_time, &timeout); |
555 } | 555 } |
556 | 556 |
557 update_timeout(opts.keepalive_secs, now, | 557 if (ses.authstate.authdone) { |
558 MAX(ses.last_packet_time_keepalive_recv, ses.last_packet_time_keepalive_sent), | 558 update_timeout(opts.keepalive_secs, now, |
559 &timeout); | 559 MAX(ses.last_packet_time_keepalive_recv, ses.last_packet_time_keepalive_sent), |
560 &timeout); | |
561 } | |
560 | 562 |
561 update_timeout(opts.idle_timeout_secs, now, ses.last_packet_time_idle, | 563 update_timeout(opts.idle_timeout_secs, now, ses.last_packet_time_idle, |
562 &timeout); | 564 &timeout); |
563 | |
564 TRACE(("timeout %ld", timeout)) | |
565 | 565 |
566 /* clamp negative timeouts to zero - event has already triggered */ | 566 /* clamp negative timeouts to zero - event has already triggered */ |
567 return MAX(timeout, 0); | 567 return MAX(timeout, 0); |
568 } | 568 } |
569 | 569 |