Closed seinocluster2 closed 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().
Thanks a comment. I want to fix it.
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().
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
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) {
rv = setup_timer();
if (rv < 0)
goto fail;
@@ -472,18 +470,6 @@ static int setup(int type) goto fail; client_add(rv, process_listener, NULL);
-fail:
-static int loop(void) -{
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;
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
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) {
rv = setup_timer();
if (rv < 0)
goto fail;
@@ -472,18 +470,6 @@ static int setup(int type) goto fail; client_add(rv, process_listener, NULL);
-fail:
-static int loop(void) -{
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;
Oh, github seems not to be suitable for attaching patches. I'll send a separate email to you which attaches the patch.
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.