mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/tw10169_optimize_dhcp_renew_rebind_timer' into 'master'
lwip: optimize dhcp renew/rebind timer This MR is used to replace MR581 since MR581 use a bad branch name. See merge request !585
This commit is contained in:
commit
74d0edec0f
@ -539,6 +539,8 @@ static void
|
|||||||
dhcp_t1_timeout(struct netif *netif)
|
dhcp_t1_timeout(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
|
int half_t2_timeout;
|
||||||
|
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_t1_timeout()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_t1_timeout()\n"));
|
||||||
if ((dhcp->state == DHCP_STATE_REQUESTING) || (dhcp->state == DHCP_STATE_BOUND) ||
|
if ((dhcp->state == DHCP_STATE_REQUESTING) || (dhcp->state == DHCP_STATE_BOUND) ||
|
||||||
(dhcp->state == DHCP_STATE_RENEWING)) {
|
(dhcp->state == DHCP_STATE_RENEWING)) {
|
||||||
@ -550,15 +552,16 @@ dhcp_t1_timeout(struct netif *netif)
|
|||||||
DHCP_STATE_RENEWING, not DHCP_STATE_BOUND */
|
DHCP_STATE_RENEWING, not DHCP_STATE_BOUND */
|
||||||
dhcp_renew(netif);
|
dhcp_renew(netif);
|
||||||
/* Calculate next timeout */
|
/* Calculate next timeout */
|
||||||
|
half_t2_timeout = (netif->dhcp->t2_timeout - dhcp->lease_used) / 2;
|
||||||
#if ESP_DHCP_TIMER
|
#if ESP_DHCP_TIMER
|
||||||
if (((netif->dhcp->t2_timeout - dhcp->lease_used) / 2) >= (60 + DHCP_COARSE_TIMER_SECS / 2) )
|
if (half_t2_timeout*DHCP_COARSE_TIMER_SECS >= 3)
|
||||||
{
|
{
|
||||||
netif->dhcp->t1_renew_time = (netif->dhcp->t2_timeout - dhcp->lease_used) / 2;
|
netif->dhcp->t1_renew_time = half_t2_timeout;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (((netif->dhcp->t2_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS))
|
if (half_t2_timeout >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS))
|
||||||
{
|
{
|
||||||
netif->dhcp->t1_renew_time = ((netif->dhcp->t2_timeout - dhcp->lease_used) / 2);
|
netif->dhcp->t1_renew_time = half_t2_timeout;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -573,6 +576,7 @@ static void
|
|||||||
dhcp_t2_timeout(struct netif *netif)
|
dhcp_t2_timeout(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct dhcp *dhcp = netif->dhcp;
|
struct dhcp *dhcp = netif->dhcp;
|
||||||
|
int half_t0_timeout;
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout()\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_t2_timeout()\n"));
|
||||||
if ((dhcp->state == DHCP_STATE_REQUESTING) || (dhcp->state == DHCP_STATE_BOUND) ||
|
if ((dhcp->state == DHCP_STATE_REQUESTING) || (dhcp->state == DHCP_STATE_BOUND) ||
|
||||||
(dhcp->state == DHCP_STATE_RENEWING) || (dhcp->state == DHCP_STATE_REBINDING)) {
|
(dhcp->state == DHCP_STATE_RENEWING) || (dhcp->state == DHCP_STATE_REBINDING)) {
|
||||||
@ -583,15 +587,16 @@ dhcp_t2_timeout(struct netif *netif)
|
|||||||
DHCP_STATE_REBINDING, not DHCP_STATE_BOUND */
|
DHCP_STATE_REBINDING, not DHCP_STATE_BOUND */
|
||||||
dhcp_rebind(netif);
|
dhcp_rebind(netif);
|
||||||
/* Calculate next timeout */
|
/* Calculate next timeout */
|
||||||
|
half_t0_timeout = (netif->dhcp->t0_timeout - dhcp->lease_used) / 2;
|
||||||
#if ESP_DHCP_TIMER
|
#if ESP_DHCP_TIMER
|
||||||
if (((netif->dhcp->t0_timeout - dhcp->lease_used) / 2) >= (60 + DHCP_COARSE_TIMER_SECS / 2))
|
if (half_t0_timeout*DHCP_COARSE_TIMER_SECS >= 3)
|
||||||
{
|
{
|
||||||
netif->dhcp->t2_rebind_time = ((netif->dhcp->t0_timeout - dhcp->lease_used) / 2);
|
netif->dhcp->t2_rebind_time = half_t0_timeout;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (((netif->dhcp->t0_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS))
|
if (half_t0_timeout >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS))
|
||||||
{
|
{
|
||||||
netif->dhcp->t2_rebind_time = ((netif->dhcp->t0_timeout - dhcp->lease_used) / 2);
|
netif->dhcp->t2_rebind_time = half_t0_timeout;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user