The branch, master has been updated via 539125c ctdbd_conn: Move release_ip handling into process.c via 5523394 ctdbd_conn: Do an early return from ctdb_read_req via 41b4139 ctdbd_conn: Return early from ctdbd_msg_call_back via db1bee9 ctdbd_conn: Make register_with_ctdbd use an int-returning callback via eca508f ctdbd_conn: Convert ctdb_read_req to return 0/errno via 177b6a4 ctdbd_conn: Convert ctdb_handle_message to return 0/errno via 9bb10ca ctdbd_conn: Make ctdb_read_packet return 0/errno via 0b9a8a0 ctdbd_conn: Rename "ret"->"ok" via 4496845 ctdbd_conn: Fix a memleak from 452e698 lib/util/charset: reduce loglevel for push_ucs2_talloc error
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 539125c99dfe03aeac5b324106273d8dc10bd7f9 Author: Volker Lendecke <v...@samba.org> Date: Tue Jun 23 19:07:44 2015 +0200 ctdbd_conn: Move release_ip handling into process.c Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Tue Jul 14 09:56:25 CEST 2015 on sn-devel-104 commit 55233940c67a1854e4354766451023a3724c7967 Author: Volker Lendecke <v...@samba.org> Date: Tue Jun 23 17:04:59 2015 +0200 ctdbd_conn: Do an early return from ctdb_read_req Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 41b413916b52943c95fb751dec5e8ac297e19922 Author: Volker Lendecke <v...@samba.org> Date: Tue Jun 23 16:59:00 2015 +0200 ctdbd_conn: Return early from ctdbd_msg_call_back ... if the callback returns != 0 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit db1bee97f28ab57868aae6512d6d39e08450b6c3 Author: Volker Lendecke <v...@samba.org> Date: Tue Jun 23 16:55:09 2015 +0200 ctdbd_conn: Make register_with_ctdbd use an int-returning callback This will allow an early return from ctdbd_msg_call_back so that we can also handle CTDB_SRVID_RELEASE_IP via register_with_ctdbd. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit eca508f3c821a73ab08c079ba3ca3522363ad59f Author: Volker Lendecke <v...@samba.org> Date: Fri Jun 19 11:47:01 2015 +0200 ctdbd_conn: Convert ctdb_read_req to return 0/errno Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 177b6a4571cce9a9f3b4b3c87b3479b6e955a8ba Author: Volker Lendecke <v...@samba.org> Date: Fri Jun 19 11:47:01 2015 +0200 ctdbd_conn: Convert ctdb_handle_message to return 0/errno Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9bb10caff832b7f8313bf322ce85dabf64ed38e2 Author: Volker Lendecke <v...@samba.org> Date: Sat Jul 11 12:23:22 2015 +0200 ctdbd_conn: Make ctdb_read_packet return 0/errno A little less dependencies Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 0b9a8a042f621e60f4279cdd6a0cadff41b88e28 Author: Volker Lendecke <v...@samba.org> Date: Sat Jul 11 12:21:55 2015 +0200 ctdbd_conn: Rename "ret"->"ok" We'll need "ret" soon Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 44968456cb7ec96fb3268cda1175da29f37e8a07 Author: Volker Lendecke <v...@samba.org> Date: Wed Jul 1 17:00:43 2015 +0200 ctdbd_conn: Fix a memleak Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/ctdbd_conn.h | 14 +-- source3/lib/ctdb_dummy.c | 14 +-- source3/lib/ctdbd_conn.c | 213 +++++++++++++++++------------------------ source3/lib/messages_ctdbd.c | 8 +- source3/smbd/notifyd/notifyd.c | 30 +++--- source3/smbd/process.c | 23 ++++- source3/smbd/server.c | 4 +- 7 files changed, 147 insertions(+), 159 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index 6cf123f..b60a0e5 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -75,8 +75,10 @@ NTSTATUS ctdbd_traverse(uint32_t db_id, NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, const struct sockaddr_storage *server, const struct sockaddr_storage *client, - bool (*release_ip_handler)(const char *ip_addr, - void *private_data), + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data), void *private_data); NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode, @@ -89,10 +91,10 @@ NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn); struct ctdb_req_message; NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, - void (*cb)(uint32_t src_vnn, uint32_t dst_vnn, - uint64_t dst_srvid, - const uint8_t *msg, size_t msglen, - void *private_data), + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data), void *private_data); NTSTATUS ctdbd_probe(void); diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c index b4300c1..df05de7 100644 --- a/source3/lib/ctdb_dummy.c +++ b/source3/lib/ctdb_dummy.c @@ -37,10 +37,10 @@ NTSTATUS ctdbd_messaging_send_iov(struct ctdbd_connection *conn, } NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, - void (*cb)(uint32_t src_vnn, uint32_t dst_vnn, - uint64_t dst_srvid, - const uint8_t *msg, size_t msglen, - void *private_data), + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data), void *private_data) { return NT_STATUS_NOT_IMPLEMENTED; @@ -49,8 +49,10 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, const struct sockaddr_storage *_server, const struct sockaddr_storage *_client, - bool (*release_ip_handler)(const char *ip_addr, - void *private_data), + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data), void *private_data) { return NT_STATUS_NOT_IMPLEMENTED; diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index fae086a..1acce12 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -35,10 +35,10 @@ struct ctdbd_srvid_cb { uint64_t srvid; - void (*cb)(uint32_t src_vnn, uint32_t dst_vnn, - uint64_t dst_srvid, - const uint8_t *msg, size_t msglen, - void *private_data); + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data); void *private_data; }; @@ -50,9 +50,6 @@ struct ctdbd_connection { struct ctdbd_srvid_cb *callbacks; int fd; struct tevent_fd *fde; - - bool (*release_ip_handler)(const char *ip_addr, void *private_data); - void *release_ip_priv; }; static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn) @@ -101,10 +98,10 @@ static void ctdb_packet_dump(struct ctdb_req_header *hdr) * Register a srvid with ctdbd */ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, - void (*cb)(uint32_t src_vnn, uint32_t dst_vnn, - uint64_t dst_srvid, - const uint8_t *msg, size_t msglen, - void *private_data), + int (*cb)(uint32_t src_vnn, uint32_t dst_vnn, + uint64_t dst_srvid, + const uint8_t *msg, size_t msglen, + void *private_data), void *private_data) { @@ -136,8 +133,8 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, return NT_STATUS_OK; } -static void ctdbd_msg_call_back(struct ctdbd_connection *conn, - struct ctdb_req_message *msg) +static int ctdbd_msg_call_back(struct ctdbd_connection *conn, + struct ctdb_req_message *msg) { size_t msg_len; size_t i, num_callbacks; @@ -146,14 +143,14 @@ static void ctdbd_msg_call_back(struct ctdbd_connection *conn, if (msg_len < offsetof(struct ctdb_req_message, data)) { DEBUG(10, ("%s: len %u too small\n", __func__, (unsigned)msg_len)); - return; + return 0; } msg_len -= offsetof(struct ctdb_req_message, data); if (msg_len < msg->datalen) { DEBUG(10, ("%s: msg_len=%u < msg->datalen=%u\n", __func__, (unsigned)msg_len, (unsigned)msg->datalen)); - return; + return 0; } num_callbacks = talloc_array_length(conn->callbacks); @@ -162,11 +159,17 @@ static void ctdbd_msg_call_back(struct ctdbd_connection *conn, struct ctdbd_srvid_cb *cb = &conn->callbacks[i]; if ((cb->srvid == msg->srvid) && (cb->cb != NULL)) { - cb->cb(msg->hdr.srcnode, msg->hdr.destnode, - msg->srvid, msg->data, msg->datalen, - cb->private_data); + int ret; + + ret = cb->cb(msg->hdr.srcnode, msg->hdr.destnode, + msg->srvid, msg->data, msg->datalen, + cb->private_data); + if (ret != 0) { + return ret; + } } } + return 0; } /* @@ -301,8 +304,8 @@ static int ctdbd_connect(int *pfd) return 0; } -static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx, - struct ctdb_req_header **result) +static int ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx, + struct ctdb_req_header **result) { int timeout = lp_ctdb_timeout(); struct ctdb_req_header *req; @@ -317,31 +320,31 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx, if (timeout != -1) { ret = poll_one_fd(fd, POLLIN, timeout, &revents); if (ret == -1) { - return map_nt_error_from_unix(errno); + return errno; } if (ret == 0) { - return NT_STATUS_IO_TIMEOUT; + return ETIMEDOUT; } if (ret != 1) { - return NT_STATUS_UNEXPECTED_IO_ERROR; + return EIO; } } nread = read_data(fd, &msglen, sizeof(msglen)); if (nread == -1) { - return map_nt_error_from_unix(errno); + return errno; } if (nread == 0) { - return NT_STATUS_UNEXPECTED_IO_ERROR; + return EIO; } if (msglen < sizeof(struct ctdb_req_header)) { - return NT_STATUS_UNEXPECTED_IO_ERROR; + return EIO; } req = talloc_size(mem_ctx, msglen); if (req == NULL) { - return NT_STATUS_NO_MEMORY; + return ENOMEM; } talloc_set_name_const(req, "struct ctdb_req_header"); @@ -350,14 +353,14 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx, nread = read_data(fd, ((char *)req) + sizeof(msglen), msglen - sizeof(msglen)); if (nread == -1) { - return map_nt_error_from_unix(errno); + return errno; } if (nread == 0) { - return NT_STATUS_UNEXPECTED_IO_ERROR; + return EIO; } *result = req; - return NT_STATUS_OK; + return 0; } /* @@ -365,18 +368,17 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx, * messages that might come in between. */ -static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, - TALLOC_CTX *mem_ctx, - struct ctdb_req_header **result) +static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, + TALLOC_CTX *mem_ctx, struct ctdb_req_header **result) { struct ctdb_req_header *hdr; - NTSTATUS status; + int ret; next_pkt: - status = ctdb_read_packet(conn->fd, mem_ctx, &hdr); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ctdb_read_packet failed: %s\n", nt_errstr(status))); + ret = ctdb_read_packet(conn->fd, mem_ctx, &hdr); + if (ret != 0) { + DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret))); cluster_fatal("ctdbd died\n"); } @@ -390,34 +392,16 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, DEBUG(1, ("Got a message without having a msg ctx, " "dropping msg %llu\n", (long long unsigned)msg->srvid)); + TALLOC_FREE(hdr); goto next_pkt; } - if ((conn->release_ip_handler != NULL) - && (msg->srvid == CTDB_SRVID_RELEASE_IP)) { - bool ret; - - /* must be dispatched immediately */ - DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n")); - ret = conn->release_ip_handler((const char *)msg->data, - conn->release_ip_priv); + ret = ctdbd_msg_call_back(conn, msg); + if (ret != 0) { TALLOC_FREE(hdr); - - if (ret) { - /* - * We need to release the ip, - * so return an error to the upper layers. - * - * We make sure we don't trigger this again. - */ - conn->release_ip_handler = NULL; - conn->release_ip_priv = NULL; - return NT_STATUS_ADDRESS_CLOSED; - } - goto next_pkt; + return ret; } - ctdbd_msg_call_back(conn, msg); TALLOC_FREE(hdr); goto next_pkt; } @@ -432,7 +416,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, *result = talloc_move(mem_ctx, &hdr); - return NT_STATUS_OK; + return 0; } static int ctdbd_connection_destructor(struct ctdbd_connection *c) @@ -538,42 +522,22 @@ int ctdbd_conn_get_fd(struct ctdbd_connection *conn) /* * Packet handler to receive and handle a ctdb message */ -static NTSTATUS ctdb_handle_message(struct ctdbd_connection *conn, - struct ctdb_req_header *hdr) +static int ctdb_handle_message(struct ctdbd_connection *conn, + struct ctdb_req_header *hdr) { struct ctdb_req_message *msg; if (hdr->operation != CTDB_REQ_MESSAGE) { DEBUG(0, ("Received async msg of type %u, discarding\n", hdr->operation)); - return NT_STATUS_INVALID_PARAMETER; + return EINVAL; } msg = (struct ctdb_req_message *)hdr; - if ((conn->release_ip_handler != NULL) - && (msg->srvid == CTDB_SRVID_RELEASE_IP)) { - bool ret; - - /* must be dispatched immediately */ - DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n")); - ret = conn->release_ip_handler((const char *)msg->data, - conn->release_ip_priv); - if (ret) { - /* - * We need to release the ip. - * - * We make sure we don't trigger this again. - */ - conn->release_ip_handler = NULL; - conn->release_ip_priv = NULL; - } - return NT_STATUS_OK; - } - ctdbd_msg_call_back(conn, msg); - return NT_STATUS_OK; + return 0; } /* @@ -588,21 +552,21 @@ static void ctdbd_socket_handler(struct tevent_context *event_ctx, struct ctdbd_connection *conn = talloc_get_type_abort( private_data, struct ctdbd_connection); struct ctdb_req_header *hdr = NULL; - NTSTATUS status; + int ret; - status = ctdb_read_packet(conn->fd, talloc_tos(), &hdr); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ctdb_read_packet failed: %s\n", nt_errstr(status))); + ret = ctdb_read_packet(conn->fd, talloc_tos(), &hdr); + if (ret != 0) { + DEBUG(0, ("ctdb_read_packet failed: %s\n", strerror(ret))); cluster_fatal("ctdbd died\n"); } - status = ctdb_handle_message(conn, hdr); + ret = ctdb_handle_message(conn, hdr); TALLOC_FREE(hdr); - if (!NT_STATUS_IS_OK(status)) { + if (ret != 0) { DEBUG(10, ("could not handle incoming message: %s\n", - nt_errstr(status))); + strerror(ret))); } } @@ -684,6 +648,7 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn, struct iovec iov[2]; ssize_t nwritten; NTSTATUS status; + int ret; if (conn == NULL) { status = ctdbd_init_connection(NULL, &new_conn); @@ -731,10 +696,10 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn, return NT_STATUS_OK; } - status = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("ctdb_read_req failed: %s\n", nt_errstr(status))); + ret = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr); + if (ret != 0) { + DEBUG(10, ("ctdb_read_req failed: %s\n", strerror(ret))); + status = map_nt_error_from_unix(ret); goto fail; } @@ -788,7 +753,6 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn, { TALLOC_CTX *frame = talloc_stackframe(); int i, num_received; - NTSTATUS status; uint32_t *reqids; bool result = false; @@ -840,7 +804,6 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn, nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov)); if (nwritten == -1) { - status = map_nt_error_from_unix(errno); DEBUG(10, ("write_data_iov failed: %s\n", strerror(errno))); goto fail; @@ -853,11 +816,12 @@ bool ctdb_processes_exist(struct ctdbd_connection *conn, struct ctdb_req_header *hdr; struct ctdb_reply_control *reply; uint32_t reqid; + int ret; - status = ctdb_read_req(conn, 0, talloc_tos(), &hdr); - if (!NT_STATUS_IS_OK(status)) { + ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr); + if (ret != 0) { DEBUG(10, ("ctdb_read_req failed: %s\n", - nt_errstr(status))); + strerror(ret))); goto fail; } @@ -992,7 +956,6 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, bool *results) { unsigned i, num_received; - NTSTATUS status; struct ctdb_vnn_list *vnns = NULL; unsigned num_vnns; @@ -1037,7 +1000,6 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov)); if (nwritten == -1) { - status = map_nt_error_from_unix(errno); DEBUG(10, ("write_data_iov failed: %s\n", strerror(errno))); goto fail; @@ -1052,11 +1014,12 @@ bool ctdb_serverids_exist(struct ctdbd_connection *conn, struct ctdb_vnn_list *vnn; uint32_t reqid; uint8_t *reply_data; + int ret; - status = ctdb_read_req(conn, 0, talloc_tos(), &hdr); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("ctdb_read_req failed: %s\n", - nt_errstr(status))); + ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr); + if (ret != 0) { + DEBUG(10, ("ctdb_read_req failed: %s\n", + strerror(ret))); goto fail; } @@ -1224,6 +1187,7 @@ NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, struct iovec iov[2]; ssize_t nwritten; NTSTATUS status; + int ret; ZERO_STRUCT(req); @@ -1251,10 +1215,10 @@ NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id, cluster_fatal("cluster dispatch daemon msg write error\n"); } - status = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ctdb_read_req failed: %s\n", nt_errstr(status))); + ret = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr); + if (ret != 0) { + DEBUG(10, ("ctdb_read_req failed: %s\n", strerror(ret))); + status = map_nt_error_from_unix(ret); goto fail; } @@ -1287,6 +1251,7 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id, ssize_t nwritten; NTSTATUS status; uint32_t flags; + int ret; flags = local_copy ? CTDB_WANT_READONLY : 0; @@ -1313,10 +1278,10 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id, cluster_fatal("cluster dispatch daemon msg write error\n"); } - status = ctdb_read_req(conn, req.hdr.reqid, NULL, &hdr); - - if (!NT_STATUS_IS_OK(status)) { -- Samba Shared Repository