mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
simpler shutdown process. The reply is not actually needed, and
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)
This commit is contained in:
parent
0029883c0b
commit
ddf430b2f2
@ -92,19 +92,6 @@ void ctdb_reply_fetch_lock(struct ctdb_context *ctdb, struct ctdb_req_header *hd
|
||||
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
|
||||
*/
|
||||
@ -121,9 +108,13 @@ static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args)
|
||||
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) {
|
||||
@ -159,10 +150,6 @@ static void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args)
|
||||
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));
|
||||
}
|
||||
|
@ -197,7 +197,6 @@ static void daemon_fetch_lock_complete(struct ctdb_call_state *state)
|
||||
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;
|
||||
@ -240,16 +239,6 @@ static void daemon_request_shutdown(struct ctdb_client *client,
|
||||
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);
|
||||
|
@ -222,8 +222,7 @@ enum ctdb_operation {
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user