occasionally leads to problems if an immediate send on the socket
causes a context switch and the client exiting before the daemon. We
now exit the client when the daemon goes away.
(This used to be ctdb commit
b7bed0088e700f25105ceea63640b38804f51e4d)
state->state = CTDB_FETCH_LOCK_DONE;
}
-/*
- called in the client when we receive a CTDB_REPLY_SHUTDOWN from the daemon
-
- This packet comes in response to a CTDB_REQ_SHUTDOWN request packet. It
- contains any reply data from the call
-*/
-void ctdb_reply_shutdown(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
-{
- talloc_free(ctdb);
-
- exit(10);
-}
-
/*
this is called in the client, when data comes in from the daemon
*/
tmp_ctx = talloc_new(ctdb);
talloc_steal(tmp_ctx, hdr);
+ if (cnt == 0) {
+ DEBUG(2,("Daemon has exited - shutting down client\n"));
+ exit(0);
+ }
+
if (cnt < sizeof(*hdr)) {
- ctdb_set_error(ctdb, "Bad packet length %d in client\n", cnt);
- exit(1); /* XXX - temporary for debugging */
+ DEBUG(0,("Bad packet length %d in client\n", cnt));
goto done;
}
if (cnt != hdr->length) {
ctdb_reply_fetch_lock(ctdb, hdr);
break;
- case CTDB_REPLY_SHUTDOWN:
- ctdb_reply_shutdown(ctdb, hdr);
- break;
-
default:
DEBUG(0,("bogus operation code:%d\n",hdr->operation));
}
static void daemon_request_shutdown(struct ctdb_client *client,
struct ctdb_req_shutdown *f)
{
- struct ctdb_reply_shutdown rs;
struct ctdb_context *ctdb = talloc_get_type(client->ctdb, struct ctdb_context);
int len;
uint32_t node;
event_loop_once(ctdb->ev);
}
- /* send a shutdown reply back to the client */
- len = sizeof(struct ctdb_reply_shutdown);
- ZERO_STRUCT(rs);
- rs.hdr.length = len;
- rs.hdr.ctdb_magic = CTDB_MAGIC;
- rs.hdr.ctdb_version = CTDB_VERSION;
- rs.hdr.operation = CTDB_REPLY_SHUTDOWN;
- ctdb_queue_send(client->queue, (uint8_t *)&(rs.hdr), rs.hdr.length);
- /* XXX we should wait here until the packet has been sent to the client */
-
/* all daemons have requested to finish - we now exit */
DEBUG(1,("All daemons finished - exiting\n"));
_exit(0);
CTDB_REPLY_CONNECT_WAIT = 1002,
CTDB_REQ_FETCH_LOCK = 1003,
CTDB_REPLY_FETCH_LOCK = 1004,
- CTDB_REQ_SHUTDOWN = 1005,
- CTDB_REPLY_SHUTDOWN = 1006,
+ CTDB_REQ_SHUTDOWN = 1005
};
#define CTDB_MAGIC 0x43544442 /* CTDB */