Re: enbd 2.4.32/kernel 2.6.12.3 pid file problem

"Peter T. Breuer" <[email protected]>
Newsgroups gmane.linux.enbd.general
Message-ID <[email protected]>
"Also sprach u.schmeling:"
> Maybe this problem is not really related to the above combination.

It possibly is. In 2.6 the child runs first on UP after fork. In 2.4 it
is the parent that runs first after fork.

> 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:

OK.

> 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?

I'll have to study the logic in the code.

> 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;
> }

Thanks. I'll look at it.

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.