The branch, master has been updated
       via  12b187f971d857353403393a9850503e0e558672 (commit)
      from  862526e558099fad4c8259cb88da9b776aa7f80d (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 12b187f971d857353403393a9850503e0e558672
Author: Ronnie Sahlberg <ronniesahlb...@gmail.com>
Date:   Thu Nov 26 12:08:35 2009 +1100

    change the lock wait child handling to use a pipe isntead of a socketpair
    
    remove a stray alarm(30) that caused databases to be unlocked after 30 
seconds.

-----------------------------------------------------------------------

Summary of changes:
 server/ctdb_freeze.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index 36d033d..0a0ac92 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -177,8 +177,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct 
ctdb_context *ctdb, ui
        h->ctdb     = ctdb;
        h->priority = priority;
 
-       /* use socketpair() instead of pipe() so we have bi-directional fds */
-       if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) {
+       if (pipe(fd) == -1) {
                DEBUG(DEBUG_ERR,("Failed to create pipe for 
ctdb_freeze_lock\n"));
                talloc_free(h);
                return NULL;
@@ -193,40 +192,39 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct 
ctdb_context *ctdb, ui
 
        if (h->child == 0) {
                int ret;
-               int count = 0;
+
                /* in the child */
                close(fd[0]);
+
                ret = ctdb_lock_all_databases(ctdb, priority);
                if (ret != 0) {
                        _exit(0);
                }
 
-               alarm(30);
-
-               while (count++ < 30) {
-                       ret = write(fd[1], &ret, sizeof(ret));
-                       if (ret == sizeof(ret)) {
-                               break;
-                       }
+               ret = write(fd[1], &ret, sizeof(ret));
+               if (ret != sizeof(ret)) {
                        DEBUG(DEBUG_ERR, (__location__ " Failed to write to 
socket from freeze child. ret:%d errno:%u\n", ret, errno));
-                       sleep (1);
-               }
-               if (count >= 30) {
-                       DEBUG(DEBUG_ERR, (__location__ " Failed to write to 
socket from freeze child. Aborting freeze child\n"));
-                       _exit(0);
+                       _exit(1);
                }
 
-               /* the read here means we will die if the parent exits */
-               read(fd[1], &ret, sizeof(ret));
-               _exit(0);
+               while (1) {
+                       sleep(1);
+                       if (kill(ctdb->ctdbd_pid, 0) != 0) {
+                               DEBUG(DEBUG_ERR,("Parent died. Exiting lock 
wait child\n"));
+
+                               _exit(0);
+                       }
+               }
        }
 
        talloc_set_destructor(h, ctdb_freeze_handle_destructor);
 
        close(fd[1]);
+       set_close_on_exec(fd[0]);
 
        h->fd = fd[0];
 
+
        fde = event_add_fd(ctdb->ev, h, h->fd, 
EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
                           ctdb_freeze_lock_handler, h);
        if (fde == NULL) {


-- 
CTDB repository

Reply via email to