]> granicus.if.org Git - pgbouncer/commitdiff
takeover: wait for pidfile to go away
authorMarko Kreen <markokr@gmail.com>
Wed, 24 Feb 2016 18:12:28 +0000 (20:12 +0200)
committerMarko Kreen <markokr@gmail.com>
Wed, 24 Feb 2016 18:12:28 +0000 (20:12 +0200)
src/takeover.c

index 3209d54d2ba0a40c8c1ceb997fcc775454492866..f528681dbed3ee4fb61ac3b956868d7b47156c1e 100644 (file)
@@ -58,6 +58,18 @@ void takeover_finish(void)
        disconnect_server(old_bouncer, false, "disko over");
        old_bouncer = NULL;
 
+       if (cf_pidfile && cf_pidfile[0]) {
+               log_info("waiting for old pidfile to go away");
+               while (1) {
+                       struct stat st;
+                       if (stat(cf_pidfile, &st) < 0) {
+                               if (errno == ENOENT)
+                                       break;
+                       }
+                       usleep(USEC/10);
+               }
+       }
+
        log_info("old process killed, resuming work");
        resume_all();
 }