From: Volker Lendecke Date: Fri, 21 Nov 2014 15:20:10 +0000 (+0100) Subject: ctdbd_conn: Accept msgs to all registered srvids X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=6a3db15810a01dc51faf39ea355525bc4c598758;p=obnox%2Fsamba%2Fsamba-obnox.git ctdbd_conn: Accept msgs to all registered srvids Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index a26f4102368..5dc007bf5cb 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -54,6 +54,7 @@ struct ctdbd_connection { uint32_t reqid; uint32_t our_vnn; uint64_t rand_srvid; + uint64_t *srvids; int fd; struct tevent_fd *fde; @@ -109,10 +110,43 @@ static void ctdb_packet_dump(struct ctdb_req_header *hdr) NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid) { + NTSTATUS status; int cstatus; - return ctdbd_control(conn, CTDB_CURRENT_NODE, - CTDB_CONTROL_REGISTER_SRVID, srvid, 0, - tdb_null, NULL, NULL, &cstatus); + size_t num_srvids; + uint64_t *tmp; + + status = ctdbd_control(conn, CTDB_CURRENT_NODE, + CTDB_CONTROL_REGISTER_SRVID, srvid, 0, + tdb_null, NULL, NULL, &cstatus); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + num_srvids = talloc_array_length(conn->srvids); + + tmp = talloc_realloc(conn, conn->srvids, uint64_t, + num_srvids + 1); + if (tmp == NULL) { + return NT_STATUS_NO_MEMORY; + } + conn->srvids = tmp; + + conn->srvids[num_srvids] = srvid; + return NT_STATUS_OK; +} + +static bool ctdb_is_our_srvid(struct ctdbd_connection *conn, uint64_t srvid) +{ + size_t i, num_srvids; + + num_srvids = talloc_array_length(conn->srvids); + + for (i=0; isrvids[i]) { + return true; + } + } + return false; } /* @@ -661,8 +695,7 @@ static NTSTATUS ctdb_handle_message(struct messaging_context *msg_ctx, return NT_STATUS_OK; } - /* only messages to our pid or the broadcast are valid here */ - if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) { + if (!ctdb_is_our_srvid(conn, msg->srvid)) { DEBUG(0,("Got unexpected message with srvid=%llu\n", (unsigned long long)msg->srvid)); return NT_STATUS_OK;