mirror of
https://gitee.com/he3db/he3pg.git
synced 2024-12-02 04:07:34 +08:00
fix deadlock problem
This commit is contained in:
parent
369dcb62f5
commit
edc7caaef8
@ -300,17 +300,9 @@ SetupSecondBufferInTable(const SdPageKey *pk)
|
||||
|
||||
SdPageValue *pv;
|
||||
bool found;
|
||||
for(;;)
|
||||
{
|
||||
pv = (SdPageValue *)
|
||||
hash_search(SecondBufferHash, pk, HASH_ENTER_NULL, &found);
|
||||
if (pv)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pg_usleep(100000L);
|
||||
}
|
||||
|
||||
pv = (SdPageValue *)
|
||||
hash_search(SecondBufferHash, pk, HASH_ENTER_NULL, &found);
|
||||
|
||||
return pv;
|
||||
}
|
||||
@ -367,10 +359,19 @@ ReceivePageFromDataBuffer(PageKey *pk, uint8_t *buffer)
|
||||
uint32 newHash;
|
||||
newHash = SecondBufferHashCode(sk);
|
||||
partitionLock = SecondBufferMappingPartitionLock(newHash);
|
||||
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
|
||||
SdPageValue *sdPageValue = SetupSecondBufferInTable(sk);
|
||||
memcpy(sdPageValue->pagecontent, buffer,8192);
|
||||
LWLockRelease(partitionLock);
|
||||
SdPageValue *sdPageValue = NULL;
|
||||
while (sdPageValue == NULL)
|
||||
{
|
||||
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
|
||||
sdPageValue = SetupSecondBufferInTable(sk);
|
||||
if (sdPageValue == NULL)
|
||||
{
|
||||
LWLockRelease(partitionLock);
|
||||
continue;
|
||||
}
|
||||
memcpy(sdPageValue->pagecontent, buffer,8192);
|
||||
LWLockRelease(partitionLock);
|
||||
}
|
||||
|
||||
srand((int)clock());
|
||||
int index = rand()%SDNUM;
|
||||
|
Loading…
Reference in New Issue
Block a user