50.samba run the smbcontrol in the background. no need to block waiting for it.
[sahlberg/ctdb.git] / server / ctdb_server.c
index 77928ea3404b43e16bc78534bce7b994841e84c0..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"
@@ -102,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
 */
@@ -355,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:
@@ -463,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)
@@ -566,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", 
@@ -583,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");
        }
 }