50.samba run the smbcontrol in the background. no need to block waiting for it.
[sahlberg/ctdb.git] / server / ctdb_server.c
index 59ed37c6008b97a71eb3d8e635a8f744f0b97b1d..3aae28e33ed25b2702c403a35c64dd6100ff21fa 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -61,6 +61,17 @@ int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip)
 */
 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file)
 {
+       if (ctdb->recovery_lock_file != NULL) {
+               talloc_free(ctdb->recovery_lock_file);
+               ctdb->recovery_lock_file = NULL;
+       }
+
+       if (file == NULL) {
+               DEBUG(DEBUG_ALERT,("Recovery lock file set to \"\". Disabling recovery lock checking\n"));
+               ctdb->tunable.verify_recovery_lock = 0;
+               return 0;
+       }
+
        ctdb->recovery_lock_file = talloc_strdup(ctdb, file);
        CTDB_NO_MEMORY(ctdb, ctdb->recovery_lock_file);
 
@@ -91,6 +102,18 @@ int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir)
        return 0;
 }
 
+/*
+  set the directory for internal state databases
+*/
+int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir)
+{
+       ctdb->db_directory_state = talloc_strdup(ctdb, dir);
+       if (ctdb->db_directory_state == NULL) {
+               return -1;
+       }
+       return 0;
+}
+
 /*
   add a node to the list of nodes
 */
@@ -131,6 +154,11 @@ static int ctdb_add_node(struct ctdb_context *ctdb, char *nstr)
                        DEBUG(DEBUG_INFO, ("This node is configured to start in DISABLED state\n"));
                        node->flags |= NODE_FLAGS_DISABLED;
                }
+               /* do we start out in STOPPED mode? */
+               if (ctdb->start_as_stopped != 0) {
+                       DEBUG(DEBUG_INFO, ("This node is configured to start in STOPPED state\n"));
+                       node->flags |= NODE_FLAGS_STOPPED;
+               }
        }
 
        ctdb->num_nodes++;
@@ -339,47 +367,47 @@ void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 
        switch (hdr->operation) {
        case CTDB_REQ_CALL:
-               ctdb->statistics.node.req_call++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_call);
                ctdb_request_call(ctdb, hdr);
                break;
 
        case CTDB_REPLY_CALL:
-               ctdb->statistics.node.reply_call++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_call);
                ctdb_reply_call(ctdb, hdr);
                break;
 
        case CTDB_REPLY_ERROR:
-               ctdb->statistics.node.reply_error++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_error);
                ctdb_reply_error(ctdb, hdr);
                break;
 
        case CTDB_REQ_DMASTER:
-               ctdb->statistics.node.req_dmaster++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_dmaster);
                ctdb_request_dmaster(ctdb, hdr);
                break;
 
        case CTDB_REPLY_DMASTER:
-               ctdb->statistics.node.reply_dmaster++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_dmaster);
                ctdb_reply_dmaster(ctdb, hdr);
                break;
 
        case CTDB_REQ_MESSAGE:
-               ctdb->statistics.node.req_message++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_message);
                ctdb_request_message(ctdb, hdr);
                break;
 
        case CTDB_REQ_CONTROL:
-               ctdb->statistics.node.req_control++;
+               CTDB_INCREMENT_STAT(ctdb, node.req_control);
                ctdb_request_control(ctdb, hdr);
                break;
 
        case CTDB_REPLY_CONTROL:
-               ctdb->statistics.node.reply_control++;
+               CTDB_INCREMENT_STAT(ctdb, node.reply_control);
                ctdb_reply_control(ctdb, hdr);
                break;
 
        case CTDB_REQ_KEEPALIVE:
-               ctdb->statistics.keepalive_packets_recv++;
+               CTDB_INCREMENT_STAT(ctdb, keepalive_packets_recv);
                break;
 
        default:
@@ -447,7 +475,7 @@ struct queue_next {
 
 
 /*
-  trigered when a deferred packet is due
+  triggered when a deferred packet is due
  */
 static void queue_next_trigger(struct event_context *ev, struct timed_event *te, 
                               struct timeval t, void *private_data)
@@ -550,7 +578,7 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                return;
        }
 
-       ctdb->statistics.node_packets_sent++;
+       CTDB_INCREMENT_STAT(ctdb, node_packets_sent);
 
        if (!ctdb_validate_pnn(ctdb, hdr->destnode)) {
                DEBUG(DEBUG_CRIT,(__location__ " cant send to node %u that does not exist\n", 
@@ -567,16 +595,18 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 
        if (node->pnn == ctdb->pnn) {
                ctdb_defer_packet(ctdb, hdr);
-       } else {
-               if (ctdb->methods == NULL) {
-                       DEBUG(DEBUG_ALERT, (__location__ " Can not queue packet. Transport is DOWN\n"));
-                       return;
-               }
+               return;
+       }
 
-               node->tx_cnt++;
-               if (ctdb->methods->queue_pkt(node, (uint8_t *)hdr, hdr->length) != 0) {
-                       ctdb_fatal(ctdb, "Unable to queue packet\n");
-               }
+       if (ctdb->methods == NULL) {
+               DEBUG(DEBUG_ALERT, (__location__ " Can not queue packet. "
+                                   "Transport is DOWN\n"));
+               return;
+       }
+
+       node->tx_cnt++;
+       if (ctdb->methods->queue_pkt(node, (uint8_t *)hdr, hdr->length) != 0) {
+               ctdb_fatal(ctdb, "Unable to queue packet\n");
        }
 }