enbd 2.4.32/kernel 2.6.12.3 pid file problem
"u.schmeling" <[email protected]>
| Newsgroups | gmane.linux.enbd.general |
|---|---|
| Message-ID | <[email protected]> |
Maybe this problem is not really related to the above combination.
When starting a client I get:
nbd/pidfile 8854: <# 140> lockpidfile returning err -16 for lock attempt
enbd-client 8854: <#4257> main There is already a enbd-client running.
Check in /var/run/enbd-client-1.pid!
Ok so far, I remove that file ( /var/run/enbd-client-1.pid) and start
again:
and I get the above problem again, checking the contents of the pidfile
for several starts shows a changing process ID.
Looks like a race condition in the pidfile cycle?
The following workaround will temporarly solve the problem:
// PTB *re*check our pidfile with our pid inside after fork
static int
myckpidfile(struct nbd_pidfile * self) {
int otherpid;
int mypid = getpid();
int myppid = getppid();
sleep(2);
^^^^^^^^^
otherpid = readpidfile(self);
if (otherpid == -1 || otherpid == mypid || otherpid == myppid) {
return 0;
}
if (kill (otherpid, 0) < 0) {
return 0;
}
// PTB bad news, pidfile contains valid other pid
return -EBUSY;
}
regards Uwe