From f2d13d0ea9debbf350185ecd6774ba4af6eb7eba Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Apr 2007 12:49:10 +0200 Subject: [PATCH 1/2] Fix uninitialized variable warnings (This used to be ctdb commit b84f97adfd25b2fbfab1c7964b68931643e8029c) --- ctdb/common/ctdb_call.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ctdb/common/ctdb_call.c b/ctdb/common/ctdb_call.c index f0fef644560..35ccc4bf0ec 100644 --- a/ctdb/common/ctdb_call.c +++ b/ctdb/common/ctdb_call.c @@ -248,7 +248,9 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr } } if (!ctdb_db) { - ctdb_send_error(ctdb, hdr, ret, "Unknown database in request. db_id==0x%08x",c->db_id); + ctdb_send_error(ctdb, hdr, -1, + "Unknown database in request. db_id==0x%08x", + c->db_id); return; } @@ -315,7 +317,9 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) } } if (!ctdb_db) { - ctdb_send_error(ctdb, hdr, ret, "Unknown database in request. db_id==0x%08x",c->db_id); + ctdb_send_error(ctdb, hdr, -1, + "Unknown database in request. db_id==0x%08x", + c->db_id); return; } From 6f2b236909774da14ebbb8038cc308f3afae1ad5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Apr 2007 13:17:36 +0200 Subject: [PATCH 2/2] Handle a client that exited correctly: We need to ignore SIGPIPE and when the read returns 0 bytes this means the client has exited. Close the connection then. (This used to be ctdb commit bd10f4e62146493848258df8a3dc3b9222337a12) --- ctdb/common/ctdb_daemon.c | 5 +++++ ctdb/direct/ctdbd.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ctdb/common/ctdb_daemon.c b/ctdb/common/ctdb_daemon.c index 6e9fbedb2fa..72ab7ed0b10 100644 --- a/ctdb/common/ctdb_daemon.c +++ b/ctdb/common/ctdb_daemon.c @@ -283,6 +283,11 @@ static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args) struct ctdb_client *client = talloc_get_type(args, struct ctdb_client); struct ctdb_req_header *hdr; + if (cnt == 0) { + talloc_free(client); + return; + } + if (cnt < sizeof(*hdr)) { ctdb_set_error(client->ctdb, "Bad packet length %d\n", cnt); return; diff --git a/ctdb/direct/ctdbd.c b/ctdb/direct/ctdbd.c index 8a99c0ab012..727ca1d4a60 100644 --- a/ctdb/direct/ctdbd.c +++ b/ctdb/direct/ctdbd.c @@ -22,6 +22,19 @@ #include "lib/events/events.h" #include "system/filesys.h" #include "popt.h" +#include + +static void block_signal(int signum) +{ + struct sigaction act; + + memset(&act, 0, sizeof(act)); + + act.sa_handler = SIG_IGN; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, signum); + sigaction(signum, &act, NULL); +} /* @@ -75,6 +88,8 @@ int main(int argc, const char *argv[]) exit(1); } + block_signal(SIGPIPE); + ev = event_context_init(NULL); /* initialise ctdb */