messages_ctdbd: autocreate a ctdb connection, this will fix segfaults in the client...
authorStefan Metzmacher <metze@samba.org>
Mon, 14 Apr 2008 23:18:50 +0000 (01:18 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2008 12:43:07 +0000 (14:43 +0200)
metze
(This used to be commit 6f67c4ddf8101b1d06889055e3767a6ce0db360c)

source3/lib/messages_ctdbd.c

index 0c8a2aa8e4404c9096969b53f64b78e3348fad78..a01c5e03a2dbb31f9b2903d35947a2a2d0a73c81 100644 (file)
@@ -40,6 +40,24 @@ static int global_ctdb_connection_pid;
 
 struct ctdbd_connection *messaging_ctdbd_connection(void)
 {
+       if (global_ctdb_connection_pid == 0 &&
+           global_ctdbd_connection == NULL) {
+               struct event_context *ev;
+               struct messaging_context *msg;
+
+               ev = event_context_init(NULL);
+               if (!msg) {
+                       DEBUG(0,("event_context_init failed\n"));
+               }
+
+               msg = messaging_init(NULL, procid_self(), ev);
+               if (!msg) {
+                       DEBUG(0,("messaging_init failed\n"));
+               }
+
+               db_tdb2_setup_messaging(msg, false);
+       }
+
        if (global_ctdb_connection_pid != getpid()) {
                DEBUG(0,("messaging_ctdbd_connection():"
                         "valid for pid[%d] but it's [%d]\n",