Fixed deadlock on sharedClient during shutdown
This commit is contained in:
parent
b3cdf34fbc
commit
9f9c67b07e
1 changed files with 25 additions and 22 deletions
|
@ -1141,38 +1141,41 @@ namespace IPC {
|
||||||
}
|
}
|
||||||
memset(empty, 0, payLen);
|
memset(empty, 0, payLen);
|
||||||
}
|
}
|
||||||
while (offsetOnPage == -1) {
|
uint32_t attempts = 0;
|
||||||
{
|
while (offsetOnPage == -1 && (++attempts) < 20) {
|
||||||
for (char i = 'A'; i <= 'Z'; i++) {
|
for (char i = 'A'; i <= 'Z'; i++) {
|
||||||
myPage.init(baseName.substr(1) + i, (4096 << (i - 'A')), false, false);
|
myPage.init(baseName.substr(1) + i, (4096 << (i - 'A')), false, false);
|
||||||
if (!myPage.mapped) {
|
if (!myPage.mapped) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
while (offset + payLen + (hasCounter ? 1 : 0) <= myPage.len) {
|
while (offset + payLen + (hasCounter ? 1 : 0) <= myPage.len) {
|
||||||
|
if ((hasCounter && myPage.mapped[offset] == 0) || (!hasCounter && !memcmp(myPage.mapped + offset, empty, payLen))) {
|
||||||
|
semGuard tmpGuard(&mySemaphore);
|
||||||
if ((hasCounter && myPage.mapped[offset] == 0) || (!hasCounter && !memcmp(myPage.mapped + offset, empty, payLen))) {
|
if ((hasCounter && myPage.mapped[offset] == 0) || (!hasCounter && !memcmp(myPage.mapped + offset, empty, payLen))) {
|
||||||
semGuard tmpGuard(&mySemaphore);
|
offsetOnPage = offset;
|
||||||
if ((hasCounter && myPage.mapped[offset] == 0) || (!hasCounter && !memcmp(myPage.mapped + offset, empty, payLen))) {
|
if (hasCounter) {
|
||||||
offsetOnPage = offset;
|
myPage.mapped[offset] = 1;
|
||||||
if (hasCounter) {
|
*((uint32_t *)(myPage.mapped + 1 + offset + len - 4)) = getpid();
|
||||||
myPage.mapped[offset] = 1;
|
HIGH_MSG("sharedClient received ID %d", offsetOnPage/(payLen+1));
|
||||||
*((uint32_t *)(myPage.mapped + 1 + offset + len - 4)) = getpid();
|
|
||||||
HIGH_MSG("sharedClient received ID %d", offsetOnPage/(payLen+1));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
offset += payLen + (hasCounter ? 1 : 0);
|
|
||||||
}
|
|
||||||
if (offsetOnPage != -1) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
offset += payLen + (hasCounter ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (offsetOnPage != -1) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (offsetOnPage == -1) {
|
if (offsetOnPage == -1) {
|
||||||
Util::wait(500);
|
Util::wait(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (offsetOnPage == -1){
|
||||||
|
FAIL_MSG("Could not register on page for %s", baseName.c_str());
|
||||||
|
myPage.close();
|
||||||
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
free(empty);
|
free(empty);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue