lib: Fix a typo
[samba.git] / source3 / lib / ctdbd_conn.c
index fe4e0bc07b3fafb1bcee3a8b471e6bc4bf4cf15e..9832dfae7b42a2254ced1c09927989fb523ea106 100644 (file)
@@ -179,7 +179,8 @@ int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid,
        return 0;
 }
 
-static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
+static int ctdbd_msg_call_back(struct tevent_context *ev,
+                              struct ctdbd_connection *conn,
                               struct ctdb_req_message_old *msg)
 {
        uint32_t msg_len;
@@ -206,7 +207,7 @@ static int ctdbd_msg_call_back(struct ctdbd_connection *conn,
                if ((cb->srvid == msg->srvid) && (cb->cb != NULL)) {
                        int ret;
 
-                       ret = cb->cb(NULL,
+                       ret = cb->cb(ev,
                                     msg->hdr.srcnode, msg->hdr.destnode,
                                     msg->srvid, msg->data, msg->datalen,
                                     cb->private_data);
@@ -414,7 +415,7 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
        if (hdr->operation == CTDB_REQ_MESSAGE) {
                struct ctdb_req_message_old *msg = (struct ctdb_req_message_old *)hdr;
 
-               ret = ctdbd_msg_call_back(conn, msg);
+               ret = ctdbd_msg_call_back(NULL, conn, msg);
                if (ret != 0) {
                        TALLOC_FREE(hdr);
                        return ret;
@@ -573,7 +574,8 @@ int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
 /*
  * Packet handler to receive and handle a ctdb message
  */
-static int ctdb_handle_message(struct ctdbd_connection *conn,
+static int ctdb_handle_message(struct tevent_context *ev,
+                              struct ctdbd_connection *conn,
                               struct ctdb_req_header *hdr)
 {
        struct ctdb_req_message_old *msg;
@@ -586,12 +588,13 @@ static int ctdb_handle_message(struct ctdbd_connection *conn,
 
        msg = (struct ctdb_req_message_old *)hdr;
 
-       ctdbd_msg_call_back(conn, msg);
+       ctdbd_msg_call_back(ev, conn, msg);
 
        return 0;
 }
 
-void ctdbd_socket_readable(struct ctdbd_connection *conn)
+void ctdbd_socket_readable(struct tevent_context *ev,
+                          struct ctdbd_connection *conn)
 {
        struct ctdb_req_header *hdr = NULL;
        int ret;
@@ -602,7 +605,7 @@ void ctdbd_socket_readable(struct ctdbd_connection *conn)
                cluster_fatal("ctdbd died\n");
        }
 
-       ret = ctdb_handle_message(conn, hdr);
+       ret = ctdb_handle_message(ev, conn, hdr);
 
        TALLOC_FREE(hdr);
 
@@ -778,14 +781,30 @@ static int ctdbd_control(struct ctdbd_connection *conn,
 /*
  * see if a remote process exists
  */
-bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
+bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
+                         pid_t pid, uint64_t unique_id)
 {
+       uint8_t buf[sizeof(pid)+sizeof(unique_id)];
        int32_t cstatus = 0;
        int ret;
 
-       ret = ctdbd_control(conn, vnn, CTDB_CONTROL_PROCESS_EXISTS, 0, 0,
-                           (TDB_DATA) { .dptr = (uint8_t *)&pid,
-                                        .dsize = sizeof(pid) },
+       if (unique_id == SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
+               ret = ctdbd_control(conn, vnn, CTDB_CONTROL_PROCESS_EXISTS,
+                                   0, 0,
+                                   (TDB_DATA) { .dptr = (uint8_t *)&pid,
+                                                   .dsize = sizeof(pid) },
+                                   NULL, NULL, &cstatus);
+               if (ret != 0) {
+                       return false;
+               }
+               return (cstatus == 0);
+       }
+
+       memcpy(buf, &pid, sizeof(pid));
+       memcpy(buf+sizeof(pid), &unique_id, sizeof(unique_id));
+
+       ret = ctdbd_control(conn, vnn, CTDB_CONTROL_CHECK_PID_SRVID, 0, 0,
+                           (TDB_DATA) { .dptr = buf, .dsize = sizeof(buf) },
                            NULL, NULL, &cstatus);
        if (ret != 0) {
                return false;
@@ -1352,7 +1371,7 @@ static struct tevent_req *ctdb_pkt_send_send(TALLOC_CTX *mem_ctx,
        }
 
        /*
-        * Attempt a direct write. If this returns short, shedule the
+        * Attempt a direct write. If this returns short, schedule the
         * remaining data as an async write, otherwise we're already done.
         */