jjzhang / booth

The Booth Cluster Ticket Manager
GNU General Public License v2.0
16 stars 37 forks source link

Fixed:Multiple booth daemons error #34

Closed seinocluster2 closed 12 years ago

seinocluster2 commented 12 years ago

I fixed multiple booth of error message.

Currently, the following error message is output when multiple booth started.

ERROR: failed to bind socket Address already in use or ERROR: bind error -1: Address already in use (98)

So I check the lock of pid file before socket is opened.

jjzhang commented 12 years ago

But there is still a small window where check_lockfile() has been passed but before lockfile(), some other process has run lockfile() first, and this process will get this error.

How about leaving the setup_config as it is, and move setup_timer(), setup_transport(), setup_ticket() and setup_listener() back to loop() function? In this way, these setup's would be protected by lockfile().

seinocluster2 commented 12 years ago

Thanks a comment. I want to fix it.

seinocluster2 commented 12 years ago

I update the pull request. I divide the process to get the lock-file from the process to write the lock-file. we firstly get the lock in do_server().

jjzhang commented 12 years ago

Oh, thanks for the updating. What I meant to say in the last comment is some patch like below;) Could you give it a try to see if it works for you?;)

Reported-by: Yuich SEINO seino.cluster2@gmail.com

Signed-off-by: Jiaju Zhang jjzhang@suse.de

src/main.c | 26 ++++++-------------------- 1 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/src/main.c b/src/main.c index 8e51007..4736a93 100644 --- a/src/main.c +++ b/src/main.c @@ -447,14 +447,12 @@ static int setup_timer(void) return timerlist_init(); }

-static int setup(int type) +static int loop(void) {

- int rv;

- goto fail;

- return 0;

-fail:

- int rv, i;

     while (1) {
             rv = poll(pollfd, client_maxi + 1, poll_timeout);
             if (rv == -1 && errno == EINTR)

@@ -947,7 +933,7 @@ static int do_server(int type) int fd = -1; int rv = -1;

jjzhang commented 12 years ago

Oh, thanks for the updating. What I meant to say in the last comment is some patch like below;) Could you give it a try to see if it works for you?;)

Reported-by: Yuich SEINO seino.cluster2@gmail.com

Signed-off-by: Jiaju Zhang jjzhang@suse.de

src/main.c | 26 ++++++-------------------- 1 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/src/main.c b/src/main.c index 8e51007..4736a93 100644 --- a/src/main.c +++ b/src/main.c @@ -447,14 +447,12 @@ static int setup_timer(void) return timerlist_init(); }

-static int setup(int type) +static int loop(void) {

- int rv;

- goto fail;

- return 0;

-fail:

- int rv, i;

     while (1) {
             rv = poll(pollfd, client_maxi + 1, poll_timeout);
             if (rv == -1 && errno == EINTR)

@@ -947,7 +933,7 @@ static int do_server(int type) int fd = -1; int rv = -1;

jjzhang commented 12 years ago

Oh, github seems not to be suitable for attaching patches. I'll send a separate email to you which attaches the patch.