The branch, master has been updated via d905179 ctdb-client: Use ctdb_rec_buffer_init() to initialize ctdb_rec_buffer via a7d54bb ctdb-client: Add missing initialization for h->ev in transaction_start via 5d5d88e ctdb-client: Do not delete reqid explicitly via 8ca76ad ctdb-client: Add a disconnect callback for ctdb client via 555237f ctdb-client: Close ctdb socket connection when client context goes away via e59712b ctdb-client: Use ctdb_ltdb_header_extract() via 0ed60d7 ctdb-protocol: Fix marshaling of seqnum from 006d4c1 docs: Bump version up to 4.4.
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit d90517912712f2e8021733ecaabed903cb2d0aed Author: Amitay Isaacs <ami...@gmail.com> Date: Fri Nov 6 17:08:18 2015 +1100 ctdb-client: Use ctdb_rec_buffer_init() to initialize ctdb_rec_buffer ... instead of talloc_zero(). This sets the db_id correctly. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Martin Schwenke <mart...@samba.org> Autobuild-Date(master): Wed Jan 20 07:28:42 CET 2016 on sn-devel-144 commit a7d54bb2c15e280143455289236884be1a402dda Author: Amitay Isaacs <ami...@gmail.com> Date: Fri Nov 6 15:20:15 2015 +1100 ctdb-client: Add missing initialization for h->ev in transaction_start Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 5d5d88e0bb082cc82fab355b687b7cb34a8bd059 Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Nov 5 17:09:11 2015 +1100 ctdb-client: Do not delete reqid explicitly The reqid will be deleted when the client control state is freed. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 8ca76adaeaa284601424e2d3ec4cc4bd044ed0de Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Oct 14 15:36:55 2015 +1100 ctdb-client: Add a disconnect callback for ctdb client This allows the client code to optionally clean up and/or re-connect to CTDB daemon when it the daemon goes away. If no disconnect callback is registered and CTDB daemon goes away, then the client will terminate. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 555237f2a8bd42f7223397f73e62a2a3786484c5 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Oct 14 15:30:14 2015 +1100 ctdb-client: Close ctdb socket connection when client context goes away Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e59712b2c311c4d5fff82bc62f86a83ea4e86cbd Author: Amitay Isaacs <ami...@gmail.com> Date: Tue Nov 10 18:32:05 2015 +1100 ctdb-client: Use ctdb_ltdb_header_extract() Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 0ed60d757d3cb134eb74e559bc3288b44cf74a6f Author: Amitay Isaacs <ami...@gmail.com> Date: Thu Nov 26 13:50:14 2015 +1100 ctdb-protocol: Fix marshaling of seqnum Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> ----------------------------------------------------------------------- Summary of changes: ctdb/client/client.h | 6 ++++++ ctdb/client/client_connect.c | 30 +++++++++++++++++++++++++++++- ctdb/client/client_control.c | 1 - ctdb/client/client_db.c | 11 +++-------- ctdb/client/client_private.h | 3 +++ ctdb/protocol/protocol_control.c | 2 +- 6 files changed, 42 insertions(+), 11 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/client/client.h b/ctdb/client/client.h index 3a16069..bce0c6b 100644 --- a/ctdb/client/client.h +++ b/ctdb/client/client.h @@ -30,11 +30,17 @@ struct ctdb_client_context; struct ctdb_db_context; struct ctdb_record_handle; +typedef void (*ctdb_client_callback_func_t)(void *private_data); + /* from client/client_connect.c */ int ctdb_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *sockpath, struct ctdb_client_context **ret); +void ctdb_client_set_disconnect_callback(struct ctdb_client_context *client, + ctdb_client_callback_func_t func, + void *private_data); + uint32_t ctdb_client_pnn(struct ctdb_client_context *client); void ctdb_client_wait(struct tevent_context *ev, bool *done); diff --git a/ctdb/client/client_connect.c b/ctdb/client/client_connect.c index 0c92485..d433f7d 100644 --- a/ctdb/client/client_connect.c +++ b/ctdb/client/client_connect.c @@ -43,6 +43,8 @@ static int ctdb_client_connect(struct ctdb_client_context *client, struct tevent_context *ev, const char *sockpath); +static int ctdb_client_context_destructor(struct ctdb_client_context *client); + int ctdb_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *sockpath, struct ctdb_client_context **out) { @@ -78,10 +80,21 @@ int ctdb_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, return ret; } + talloc_set_destructor(client, ctdb_client_context_destructor); + *out = client; return 0; } +static int ctdb_client_context_destructor(struct ctdb_client_context *client) +{ + if (client->fd != -1) { + close(client->fd); + client->fd = -1; + } + return 0; +} + static void client_read_handler(uint8_t *buf, size_t buflen, void *private_data); static void client_dead_handler(void *private_data); @@ -193,12 +206,27 @@ static void client_dead_handler(void *private_data) { struct ctdb_client_context *client = talloc_get_type_abort( private_data, struct ctdb_client_context); + ctdb_client_callback_func_t callback = client->callback; + void *callback_data = client->private_data; - DEBUG(DEBUG_NOTICE, ("connection to daemon closed, exiting\n")); talloc_free(client); + if (callback != NULL) { + callback(callback_data); + return; + } + + DEBUG(DEBUG_NOTICE, ("connection to daemon closed, exiting\n")); exit(1); } +void ctdb_client_set_disconnect_callback(struct ctdb_client_context *client, + ctdb_client_callback_func_t callback, + void *private_data) +{ + client->callback = callback; + client->private_data = private_data; +} + uint32_t ctdb_client_pnn(struct ctdb_client_context *client) { return client->pnn; diff --git a/ctdb/client/client_control.c b/ctdb/client/client_control.c index 4249bfb..b25ff40 100644 --- a/ctdb/client/client_control.c +++ b/ctdb/client/client_control.c @@ -141,7 +141,6 @@ static void ctdb_client_control_done(struct tevent_req *subreq) /* Daemon will not reply, so we set status to 0 */ if (state->flags & CTDB_CTRL_FLAG_NOREPLY) { - reqid_remove(state->client->idr, state->reqid); state->reply->status = 0; tevent_req_done(req); } diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index 6af607a..287efd6 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -591,19 +591,13 @@ static int ctdb_db_traverse_handler(struct tdb_context *tdb, TDB_DATA key, if (state->extract_header) { struct ctdb_ltdb_header header; - size_t len; - ret = ctdb_ltdb_header_pull(data.dptr, data.dsize, &header); + ret = ctdb_ltdb_header_extract(&data, &header); if (ret != 0) { state->error = ret; return 1; } - len = ctdb_ltdb_header_len(&header); - - data.dptr += len; - data.dsize -= len; - ret = state->parser(0, &header, key, data, state->private_data); } else { ret = state->parser(0, NULL, key, data, state->private_data); @@ -1616,6 +1610,7 @@ struct tevent_req *ctdb_transaction_start_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + h->ev = ev; h->client = client; h->db = db; h->readonly = readonly; @@ -1629,7 +1624,7 @@ struct tevent_req *ctdb_transaction_start_send(TALLOC_CTX *mem_ctx, h->sid.unique_id = h->sid.task_id; h->sid.unique_id = (h->sid.unique_id << 32) | h->sid.pid; - h->recbuf = talloc_zero(h, struct ctdb_rec_buffer); + h->recbuf = ctdb_rec_buffer_init(h, db->db_id); if (tevent_req_nomem(h->recbuf, req)) { return tevent_req_post(req, ev); } diff --git a/ctdb/client/client_private.h b/ctdb/client/client_private.h index b1d8d4b..7ea9b12 100644 --- a/ctdb/client/client_private.h +++ b/ctdb/client/client_private.h @@ -21,6 +21,7 @@ #define __CTDB_CLIENT_PRIVATE_H__ #include "protocol/protocol.h" +#include "client/client.h" struct ctdb_db_context { struct ctdb_db_context *prev, *next; @@ -35,6 +36,8 @@ struct ctdb_client_context { struct reqid_context *idr; struct srvid_context *srv; struct comm_context *comm; + ctdb_client_callback_func_t callback; + void *private_data; int fd; uint32_t pnn; struct ctdb_db_context *db; diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c index 95edc1a..1c8364e 100644 --- a/ctdb/protocol/protocol_control.c +++ b/ctdb/protocol/protocol_control.c @@ -713,7 +713,7 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd, case CTDB_CONTROL_GET_DB_SEQNUM: u64 = cd->data.db_id; - ctdb_uint32_push(u64, buf); + ctdb_uint64_push(u64, buf); break; case CTDB_CONTROL_DB_SET_HEALTHY: -- Samba Shared Repository