VirtualBox

Changeset 35922 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Feb 9, 2011 8:04:14 PM (14 years ago)
Author:
vboxsync
Message:

NAT: out-of-memory feedback (xTracker/5103)

Location:
trunk/src/VBox/Devices/Network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r35353 r35922  
    472472        {
    473473            RTMemFree(pSgBuf);
    474             /** @todo Implement the VERR_TRY_AGAIN semantics. */
    475             return VERR_NO_MEMORY;
     474            return VERR_TRY_AGAIN;
    476475        }
    477476    }
     
    487486            RTMemFree(pSgBuf->pvUser);
    488487            RTMemFree(pSgBuf);
    489             /** @todo Implement the VERR_TRY_AGAIN semantics. */
    490             return VERR_NO_MEMORY;
     488            return VERR_TRY_AGAIN;
    491489        }
    492490    }
     
    907905    AssertRC(rc);
    908906    drvNATUrgRecvWakeup(pThis->pDrvIns, pThis->pUrgRecvThread);
     907}
     908
     909/**
     910 * Function called by slirp to wake up device after VERR_TRY_AGAIN
     911 */
     912void slirp_output_pending(void *pvUser)
     913{
     914    PDRVNAT pThis = (PDRVNAT)pvUser;
     915    Assert(pThis);
     916    pThis->pIAboveNet->pfnXmitPending(pThis->pIAboveNet);
    909917}
    910918
  • trunk/src/VBox/Devices/Network/slirp/libslirp.h

    r35346 r35922  
    7070int slirp_can_output(void * pvUser);
    7171void slirp_output(void * pvUser, struct mbuf *m, const uint8_t *pkt, int pkt_len);
     72void slirp_output_pending(void * pvUser);
    7273void slirp_urg_output(void *pvUser, struct mbuf *, const uint8_t *pu8Buf, int cb);
    7374void slirp_post_sent(PNATState pData, void *pvArg);
  • trunk/src/VBox/Devices/Network/slirp/misc.c

    r35861 r35922  
    126126    uma_zone_t master_zone;
    127127    void *area;
     128    bool fPending;  /* has some sense only in case master_zone == NULL */
    128129};
    129130
     131static inline bool slirp_zone_has_pending(uma_zone_t zone)
     132{
     133    return (   zone->master_zone == NULL
     134            && zone->fPending);
     135}
     136
     137static inline void slirp_zone_check_and_send_pending(uma_zone_t zone)
     138{
     139    if (slirp_zone_has_pending(zone))
     140    {
     141        zone->fPending = false;
     142        slirp_output_pending(zone->pData->pvUser);
     143    }
     144}
    130145
    131146static void *slirp_uma_alloc(uma_zone_t zone,
     
    152167                LIST_REMOVE(it, list);
    153168                LIST_INSERT_HEAD(&zone->used_items, it, list);
     169                slirp_zone_check_and_send_pending(zone);
    154170                ret = (void *)&it[1];
    155171            }
    156172            else
    157173            {
     174                AssertMsgFailed(("NAT: item initialization failed for zone %s\n", zone->name));
    158175                ret = NULL;
    159176            }
     
    165182            /* We're on master zone and we cant allocate more */
    166183            Log2(("NAT: no room on %s zone\n", zone->name));
    167             AssertMsgFailed(("NAT: OOM!"));
     184            /* AssertMsgFailed(("NAT: OOM!")); */
     185            zone->fPending = true;
    168186            break;
    169187        }
     
    225243    LIST_INSERT_HEAD(&zone->free_items, it, list);
    226244    zone->cur_items--;
     245    slirp_zone_check_and_send_pending(zone);
    227246    RTCritSectLeave(&zone->csZone);
    228247}
     
    378397        master_zone->cur_items--;
    379398        RTCritSectLeave(&master_zone->csZone);
     399        slirp_zone_check_and_send_pending(master_zone);
    380400    }
    381401}
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r35346 r35922  
    992992                CONTINUE_NO_UNLOCK(udp);
    993993            }
    994             else
    995             {
    996                 do_slowtimo = 1; /* Let socket expire */
    997             }
    998994        }
    999995
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