Changeset 28520 in vbox for trunk/src/VBox/Devices/Network/slirp
- Timestamp:
- Apr 20, 2010 1:36:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/misc.c
r28502 r28520 208 208 struct item *it; 209 209 uma_zone_t zone; 210 uma_zone_t master_zone; 210 211 Assert(item); 211 212 it = &((struct item *)item)[-1]; … … 217 218 Assert(zone->magic == ZONE_MAGIC); 218 219 LIST_REMOVE(it, list); 220 if (zone->pfFini) 221 { 222 zone->pfFini(zone->pData, item, zone->size); 223 } 224 if (zone->pfDtor) 225 { 226 zone->pfDtor(zone->pData, item, zone->size, NULL); 227 } 219 228 LIST_INSERT_HEAD(&zone->free_items, it, list); 220 229 zone->cur_items--; … … 245 254 { 246 255 uma_zone_t zone; 247 #if 0248 if (master->pfAlloc != NULL)249 zone = (uma_zone_t)master->pfAlloc(master, sizeof(struct uma_zone), NULL, 0);250 #endif251 256 Assert(master); 252 257 zone = RTMemAllocZ(sizeof(struct uma_zone)); … … 335 340 struct item *it; 336 341 Assert(zone->magic == ZONE_MAGIC); 337 if (zone->pfFree == NULL) 338 return; 339 342 Assert((zone->pfFree)); 340 343 Assert((mem)); 344 341 345 RTCritSectEnter(&zone->csZone); 342 346 it = &((struct item *)mem)[-1]; 343 if (it->magic != ITEM_MAGIC) 344 { 345 Log(("NAT:UMA: %p seems to be allocated on heap ... freeing\n", mem)); 346 RTMemFree(mem); 347 Assert((it->magic == ITEM_MAGIC)); 348 Assert((zone->magic == ZONE_MAGIC && zone == it->zone)); 349 350 zone->pfFree(mem, 0, 0); 351 RTCritSectLeave(&zone->csZone); 352 } 353 354 int uma_zone_exhausted_nolock(uma_zone_t zone) 355 { 356 int fExhausted; 357 RTCritSectEnter(&zone->csZone); 358 fExhausted = (zone->cur_items == zone->max_items); 359 RTCritSectLeave(&zone->csZone); 360 return fExhausted; 361 } 362 363 void zone_drain(uma_zone_t zone) 364 { 365 struct item *it; 366 uma_zone_t master_zone; 367 /* vvl: Huh? What to do with zone which hasn't got backstore ? */ 368 Assert((zone->master_zone)); 369 master_zone = zone->master_zone; 370 while(!LIST_EMPTY(&zone->free_items)) 371 { 372 it = LIST_FIRST(&zone->free_items); 373 RTCritSectEnter(&zone->csZone); 374 LIST_REMOVE(it, list); 375 zone->max_items--; 347 376 RTCritSectLeave(&zone->csZone); 348 return; 349 } 350 Assert((zone->magic == ZONE_MAGIC && zone == it->zone)); 351 352 if (zone->pfDtor) 353 zone->pfDtor(zone->pData, mem, zone->size, flags); 354 zone->pfFree(mem, 0, 0); 355 RTCritSectLeave(&zone->csZone); 356 } 357 358 int uma_zone_exhausted_nolock(uma_zone_t zone) 359 { 360 return 0; 361 } 362 363 void zone_drain(uma_zone_t zone) 364 { 377 it->zone = master_zone; 378 RTCritSectEnter(&master_zone->csZone); 379 LIST_INSERT_HEAD(&master_zone->free_items, it, list); 380 master_zone->cur_items--; 381 RTCritSectLeave(&master_zone->csZone); 382 } 365 383 } 366 384
Note:
See TracChangeset
for help on using the changeset viewer.