Skip to content

Commit

Permalink
s3/lib/ctdbd_conn: assert hdr following read/recv
Browse files Browse the repository at this point in the history
ctdb_pkt_recv_recv() and ctdb_read_packet() give us a non-null hdr on
success, so drop the error path check in favour of an assert.

This fixes a regression in 3913b9a,
where tevent_req_error() may be skipped in the ctdbd_parse_done()
ctdb_pkt_recv_recv() error path.

Reported-by: Stefan Metzmacher <[email protected]>
Signed-off-by: David Disseldorp <[email protected]>
Reviewed-by: Noel Power <[email protected]>

Autobuild-User(master): Noel Power <[email protected]>
Autobuild-Date(master): Wed Sep  4 14:20:16 UTC 2019 on sn-devel-184
ddiss authored and Noel Power committed Sep 4, 2019
1 parent 1232671 commit 9173ae5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source3/lib/ctdbd_conn.c
Original file line number Diff line number Diff line change
@@ -404,11 +404,12 @@ static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
next_pkt:

ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr);
if (hdr == NULL || ret != 0) {
if (ret != 0) {
DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
cluster_fatal("failed to read data from ctdbd\n");
return -1;
}
SMB_ASSERT(hdr != NULL);

DEBUG(11, ("Received ctdb packet\n"));
ctdb_packet_dump(hdr);
@@ -605,6 +606,7 @@ void ctdbd_socket_readable(struct tevent_context *ev,
DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
cluster_fatal("failed to read data from ctdbd\n");
}
SMB_ASSERT(hdr != NULL);

ret = ctdb_handle_message(ev, conn, hdr);

@@ -1086,6 +1088,7 @@ int ctdbd_traverse(struct ctdbd_connection *conn, uint32_t db_id,
DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret));
cluster_fatal("failed to read data from ctdbd\n");
}
SMB_ASSERT(hdr != NULL);

if (hdr->operation != CTDB_REQ_MESSAGE) {
DEBUG(0, ("Got operation %u, expected a message\n",
@@ -1946,10 +1949,11 @@ static void ctdbd_parse_done(struct tevent_req *subreq)

ret = ctdb_pkt_recv_recv(subreq, state, &hdr);
TALLOC_FREE(subreq);
if ((hdr == NULL) || tevent_req_error(req, ret)) {
if (tevent_req_error(req, ret)) {
DBG_ERR("ctdb_pkt_recv_recv returned %s\n", strerror(ret));
return;
}
SMB_ASSERT(hdr != NULL);

if (hdr->operation != CTDB_REPLY_CALL) {
DBG_ERR("received invalid reply\n");

0 comments on commit 9173ae5

Please sign in to comment.