VirtualBox

Changeset 49443 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 12, 2013 4:14:02 AM (11 years ago)
Author:
vboxsync
Message:

Don't schedule pxdns_timer() if we don't have any active requests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NAT/pxdns.c

    r49299 r49443  
    9494#define TIMEOUT 5
    9595    size_t timeout_slot;
     96    u32_t timeout_mask;
    9697    struct request *timeout_list[TIMEOUT];
    9798
     
    143144    struct request **pprev_timeout;
    144145    struct request *next_timeout;
     146
     147    /**
     148     * Slot in pxdns::timeout_list
     149     */
     150    size_t timeout_slot;
    145151
    146152    /**
     
    252258
    253259    pxdns->timeout_slot = 0;
     260    pxdns->timeout_mask = 0;
    254261
    255262    /* NB: assumes pollmgr thread is not running yet */
     
    258265        pollmgr_add(&pxdns->pmhdl6, pxdns->sock6, POLLIN);
    259266    }
    260 
    261     sys_timeout(1 * 1000, pxdns_timer, pxdns);
    262267
    263268    return ERR_OK;
     
    418423{
    419424    struct request **chain;
     425    u32_t omask;
    420426
    421427    LWIP_ASSERT1(req->pprev_timeout == NULL);
    422     chain = &pxdns->timeout_list[pxdns->timeout_slot];
     428
     429    req->timeout_slot = pxdns->timeout_slot;
     430    chain = &pxdns->timeout_list[req->timeout_slot];
    423431    if ((req->next_timeout = *chain) != NULL) {
    424432        (*chain)->pprev_timeout = &req->next_timeout;
     
    426434    *chain = req;
    427435    req->pprev_timeout = chain;
     436
     437    omask = pxdns->timeout_mask;
     438    pxdns->timeout_mask |= 1U << req->timeout_slot;
     439    if (omask == 0) {
     440        sys_timeout(1 * 1000, pxdns_timer, pxdns);
     441    }
    428442}
    429443
     
    448462{
    449463    LWIP_ASSERT1(req->pprev_timeout != NULL);
     464    LWIP_ASSERT1(req->timeout_slot < TIMEOUT);
    450465
    451466    if (req->next_timeout != NULL) {
     
    455470    req->pprev_timeout = NULL;
    456471    req->next_timeout = NULL;
     472
     473    if (pxdns->timeout_list[req->timeout_slot] == NULL) {
     474        pxdns->timeout_mask &= ~(1U << req->timeout_slot);
     475        /* may be on pollmgr thread so no sys_untimeout */
     476    }
    457477}
    458478
     
    526546    struct pxdns *pxdns = (struct pxdns *)arg;
    527547    struct request **chain, *req;
     548    u32_t mask;
    528549
    529550    sys_mutex_lock(&pxdns->lock);
     
    557578    }
    558579
     580    if (pxdns->timeout_list[pxdns->timeout_slot] == NULL) {
     581        pxdns->timeout_mask &= ~(1U << pxdns->timeout_slot);
     582    }
     583    else {
     584        pxdns->timeout_mask |= 1U << pxdns->timeout_slot;
     585    }
     586    mask = pxdns->timeout_mask;
     587
    559588    sys_mutex_unlock(&pxdns->lock);
    560589
    561     sys_timeout(1 * 1000, pxdns_timer, pxdns);
     590    if (mask != 0) {
     591        sys_timeout(1 * 1000, pxdns_timer, pxdns);
     592    }
    562593}
    563594
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette