Changeset 28034 in vbox
- Timestamp:
- Apr 7, 2010 8:38:00 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bsd/kern/kern_mbuf.c
r27869 r28034 313 313 NULL, NULL, 314 314 MSIZE - 1, UMA_ZONE_MAXBUCKET); 315 if (nmbclusters > 0) 316 uma_zone_set_max(zone_mbuf, nmbclusters); 315 317 316 318 zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, -
trunk/src/VBox/Devices/Network/slirp/misc.c
r27571 r28034 144 144 LIST_HEAD(RT_NOTHING, item) free_items; 145 145 uma_zone_t master_zone; 146 void *area; 146 147 }; 147 148 … … 151 152 { 152 153 struct item *it; 154 uint8_t *sub_area; 155 int cChunk; 156 int i; 153 157 RTCritSectEnter(&zone->csZone); 158 free_list_check: 154 159 if (!LIST_EMPTY(&zone->free_items)) 155 160 { 156 /* 157 * @todo (r=vvl) here should be some 158 * accounting of extra items in case 159 * breakthrough barrier 160 */ 161 if (LIST_EMPTY(&zone->free_items)) 162 { 163 RTCritSectLeave(&zone->csZone); 164 return NULL; 165 } 161 zone->cur_items++; 166 162 it = LIST_FIRST(&zone->free_items); 167 163 LIST_REMOVE(it, list); 168 164 LIST_INSERT_HEAD(&zone->used_items, it, list); 169 goto allocated; 170 } 171 172 /*@todo 'Z' should be depend on flag */ 173 it = RTMemAllocZ(sizeof(struct item) + zone->size); 174 if (it == NULL) 175 { 176 Log(("NAT: uma no memory")); 165 if (zone->pfInit) 166 zone->pfInit(zone->pData, (void *)&it[1], zone->size, M_DONTWAIT); 167 RTCritSectLeave(&zone->csZone); 168 return (void *)&it[1]; 169 } 170 171 if (zone->master_zone == NULL) 172 { 173 /* We're on master zone and we cant allocate more */ 174 Log2(("NAT: no room on %s zone\n", zone->name)); 177 175 RTCritSectLeave(&zone->csZone); 178 176 return NULL; 179 177 } 178 179 /* we're on sub-zone we need get chunk of master zone and split 180 * it for sub-zone conforming chunks. 181 */ 182 sub_area = slirp_uma_alloc(zone->master_zone, zone->master_zone->size, NULL, 0); 183 if (sub_area == NULL) 184 { 185 /*No room on master*/ 186 Log2(("NAT: no room on %s zone for %s zone\n", zone->master_zone->name, zone->name)); 187 RTCritSectLeave(&zone->csZone); 188 return NULL; 189 } 190 zone->max_items ++; 191 it = &((struct item *)sub_area)[-1]; 192 /*@todo '+ zone->size' should be depend on flag */ 193 memset(it, 0, sizeof(struct item)); 194 it->zone = zone; 180 195 it->magic = ITEM_MAGIC; 181 LIST_INSERT_HEAD(&zone->used_items, it, list); 182 zone->cur_items++; 183 it->zone = zone; 196 LIST_INSERT_HEAD(&zone->free_items, it, list); 184 197 if (zone->cur_items >= zone->max_items) 185 198 LogRel(("NAT: zone(%s) has reached it maximum\n", zone->name)); 186 187 allocated: 188 if (zone->pfInit) 189 zone->pfInit(zone->pData, (void *)&it[1], zone->size, M_DONTWAIT); 190 RTCritSectLeave(&zone->csZone); 191 return (void *)&it[1]; 199 goto free_list_check; 200 192 201 } 193 202 … … 211 220 ctor_t ctor, dtor_t dtor, zinit_t init, zfini_t fini, int flags1, int flags2) 212 221 { 213 uma_zone_t zone = RTMemAllocZ(sizeof(struct uma_zone) + size);222 uma_zone_t zone = RTMemAllocZ(sizeof(struct uma_zone)); 214 223 Assert((pData)); 215 224 zone->magic = ZONE_MAGIC; … … 235 244 zone = (uma_zone_t)master->pfAlloc(master, sizeof(struct uma_zone), NULL, 0); 236 245 #endif 246 Assert(master); 237 247 zone = RTMemAllocZ(sizeof(struct uma_zone)); 238 248 if (zone == NULL) … … 250 260 zone->pfFree = slirp_uma_free; 251 261 zone->size = master->size; 262 zone->master_zone = master; 252 263 RTCritSectInit(&zone->csZone); 253 264 return zone; … … 256 267 void uma_zone_set_max(uma_zone_t zone, int max) 257 268 { 269 int i = 0; 270 struct item *it; 258 271 zone->max_items = max; 272 zone->area = RTMemAllocZ(max * (sizeof(struct item) + zone->size)); 273 for (; i < max; ++i) 274 { 275 it = (struct item *)(((uint8_t *)zone->area) + i*(sizeof(struct item) + zone->size)); 276 it->magic = ITEM_MAGIC; 277 it->zone = zone; 278 LIST_INSERT_HEAD(&zone->free_items, it, list); 279 } 280 259 281 } 260 282 … … 378 400 RTCritSectEnter(&zone->csZone); 379 401 LogRel(("NAT: zone(nm:%s, used:%d)\n", zone->name, zone->cur_items)); 380 /* freeing */ 381 while (!LIST_EMPTY(&zone->free_items)) 382 { 383 it = LIST_FIRST(&zone->free_items); 384 LIST_REMOVE(it, list); 385 RTMemFree(it); 386 } 387 while (zone->master_zone != NULL && !LIST_EMPTY(&zone->used_items)) 388 { 389 it = LIST_FIRST(&zone->used_items); 390 LIST_REMOVE(it, list); 391 RTMemFree(it); 392 } 402 if (zone->master_zone) 403 RTMemFree(zone->area); 393 404 RTCritSectLeave(&zone->csZone); 394 405 RTCritSectDelete(&zone->csZone); -
trunk/src/VBox/Devices/Network/slirp/socket.c
r27976 r28034 199 199 DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); 200 200 #else 201 nn = recv(so->s, iov[0].iov_base, iov[0].iov_len, 0);201 nn = recv(so->s, iov[0].iov_base, iov[0].iov_len, (so->so_tcpcb->t_force? MSG_OOB:0)); 202 202 #endif 203 203 if (nn <= 0) 204 204 { 205 #ifdef RT_OS_WINDOWS206 205 /* 207 206 * Special case for WSAEnumNetworkEvents: If we receive 0 bytes that … … 213 212 int status, ignored; 214 213 unsigned long pending = 0; 215 status = WSAIoctl(so->s, FIONREAD, NULL, 0, &pending, sizeof(unsigned long), &ignored, NULL, NULL);214 status = ioctl(so->s, FIONREAD, &pending); 216 215 if (status < 0) 217 LogRel(("NAT:error in WSAIoctl: %d\n", WSAGetLastError()));216 LogRel(("NAT:error in WSAIoctl: %d\n", errno)); 218 217 if (nn == 0 && (pending != 0)) 219 218 { … … 222 221 return 0; 223 222 } 224 #endif225 223 if ( nn < 0 226 224 && ( errno == EINTR … … 306 304 { 307 305 struct tcpcb *tp = sototcpcb(so); 306 ssize_t ret; 308 307 309 308 DEBUG_CALL("sorecvoob"); … … 318 317 * urgent data. 319 318 */ 320 soread(pData, so);319 ret = soread(pData, so); 321 320 tp->snd_up = tp->snd_una + so->so_snd.sb_cc; 322 321 tp->t_force = 1;
Note:
See TracChangeset
for help on using the changeset viewer.