Revision 20532f97
b/xseg/peers/user/cached.c | ||
---|---|---|
587 | 587 |
char name[XSEG_MAX_TARGETLEN + 1]; |
588 | 588 |
char *target; |
589 | 589 |
int r = -1; |
590 |
xcache_handler h = NoEntry; |
|
590 |
xcache_handler h = NoEntry, nh;
|
|
591 | 591 |
|
592 | 592 |
XSEGLOG2(&lc, I, "Started\n"); |
593 | 593 |
|
... | ... | |
603 | 603 |
XSEGLOG2(&lc, E, "Could not allocate cache entry"); |
604 | 604 |
goto out; |
605 | 605 |
} |
606 |
r = xcache_insert(cached->cache, h);
|
|
607 |
if (r < 0){
|
|
606 |
nh = xcache_insert(cached->cache, h);
|
|
607 |
if (nh == NoEntry){
|
|
608 | 608 |
xcache_put(cached->cache, h); |
609 | 609 |
XSEGLOG2(&lc, E, "Could not insert cache entry"); |
610 | 610 |
goto out; |
611 | 611 |
} |
612 |
if (nh != h){ |
|
613 |
/* if insert returns another cache entry than the one we |
|
614 |
* allocated and requested to be inserted, then |
|
615 |
* someone else beat us to the insertion of a cache |
|
616 |
* entry assocciated with the same name. Use this cache |
|
617 |
* entry instead and put the one we allocated. |
|
618 |
*/ |
|
619 |
xcache_put(cached->cache, h); |
|
620 |
h = nh; |
|
621 |
} |
|
612 | 622 |
} |
613 | 623 |
|
614 | 624 |
ce = (struct ce *)get_cache_entry(cached->cache, h); |
Also available in: Unified diff