/*! Manage the statistics timer. * If the time is 0 the timer will be killed. * If the value is other than 0 then: * If the timer is pending it will be modified * else it will be set */ ci_inline void ci_tcp_stats_handle_timer(ci_netif* ni, ci_tcp_state* ts, ci_iptime_t timeout) { ci_ip_timer* it; ci_assert( ni && ts ); it = &ts->stats_tid; LOG_STATS( ci_log( "%s( %p, %p, %d)", __FUNCTION__, ni, ts, (int)timeout)); if( ci_ip_timer_pending(ni, it ) ) { if( timeout == 0 ) ci_ip_timer_clear(ni, it ); else ci_ip_timer_modify(ni, it, ci_tcp_time_now(ni)+timeout); } else { if( timeout != 0 ) ci_ip_timer_set(ni, it, ci_tcp_time_now(ni)+timeout); } }
static void ci_tcp_listen_timer_set(ci_netif* ni, ci_tcp_socket_listen* tls, ci_iptime_t timeout) { int i; if( ! ci_ip_timer_pending(ni, &tls->listenq_tid) ) { ci_ip_timer_set(ni, &tls->listenq_tid, timeout); return; } for( i = 0; i <= CI_CFG_TCP_SYNACK_RETRANS_MAX; i++ ) { ci_tcp_state_synrecv* tsr = ci_tcp_link2synrecv(ci_ni_dllist_start(ni, &tls->listenq[i])); if( TIME_LT(tsr->timeout, timeout) ) return; } ci_ip_timer_modify(ni, &tls->listenq_tid, timeout); }