diff options
author | Volker Lendecke <vl@samba.org> | 2015-05-19 07:01:55 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2015-05-28 11:13:09 +0200 |
commit | 4d0572a2a467a4fbde394e73f6d8c565f67807d8 (patch) | |
tree | eeb8b438057de3b73bb0ef83bd8a202b3d6b393a /source3/lib | |
parent | cc51e85f0aa49aad529eca5711fdc34f95bfe6d8 (diff) | |
download | samba-4d0572a2a467a4fbde394e73f6d8c565f67807d8.tar.gz |
ctdbd_conn: Add callback fields for registered serverids
The idea is to move message handling out of ctdbd_conn
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/ctdbd_conn.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index f5044e1173e..cdec97863c6 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -32,12 +32,18 @@ #include "ctdb.h" #include "ctdb_private.h" +struct ctdbd_srvid_cb { + uint64_t srvid; + void (*cb)(struct ctdb_req_message *msg, void *private_data); + void *private_data; +}; + struct ctdbd_connection { struct messaging_context *msg_ctx; uint32_t reqid; uint32_t our_vnn; uint64_t rand_srvid; - uint64_t *srvids; + struct ctdbd_srvid_cb *callbacks; int fd; struct tevent_fd *fde; @@ -95,8 +101,8 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid) NTSTATUS status; int cstatus; - size_t num_srvids; - uint64_t *tmp; + size_t num_callbacks; + struct ctdbd_srvid_cb *tmp; status = ctdbd_control(conn, CTDB_CURRENT_NODE, CTDB_CONTROL_REGISTER_SRVID, srvid, 0, @@ -105,27 +111,30 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid) return status; } - num_srvids = talloc_array_length(conn->srvids); + num_callbacks = talloc_array_length(conn->callbacks); - tmp = talloc_realloc(conn, conn->srvids, uint64_t, - num_srvids + 1); + tmp = talloc_realloc(conn, conn->callbacks, struct ctdbd_srvid_cb, + num_callbacks + 1); if (tmp == NULL) { return NT_STATUS_NO_MEMORY; } - conn->srvids = tmp; + conn->callbacks = tmp; + + conn->callbacks[num_callbacks] = (struct ctdbd_srvid_cb) { + .srvid = srvid + }; - 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; + size_t i, num_callbacks; - num_srvids = talloc_array_length(conn->srvids); + num_callbacks = talloc_array_length(conn->callbacks); - for (i=0; i<num_srvids; i++) { - if (srvid == conn->srvids[i]) { + for (i=0; i<num_callbacks; i++) { + if (srvid == conn->callbacks[i].srvid) { return true; } } |