4 Copyright (C) Andrew Tridgell 2006
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "lib/tdb/include/tdb.h"
24 #include "lib/events/events.h"
25 #include "lib/util/dlinklist.h"
26 #include "system/network.h"
27 #include "system/filesys.h"
28 #include "system/wait.h"
29 #include "../include/ctdb.h"
30 #include "../include/ctdb_private.h"
32 static void daemon_incoming_packet(void *, struct ctdb_req_header *);
35 handler for when a node changes its flags
37 static void flag_change_handler(struct ctdb_context *ctdb, uint64_t srvid,
38 TDB_DATA data, void *private_data)
40 struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)data.dptr;
42 if (data.dsize != sizeof(*c) || !ctdb_validate_vnn(ctdb, c->vnn)) {
43 DEBUG(0,(__location__ "Invalid data in ctdb_node_flag_change\n"));
47 if (!ctdb_validate_vnn(ctdb, c->vnn)) {
48 DEBUG(0,("Bad vnn %u in flag_change_handler\n", c->vnn));
52 /* don't get the disconnected flag from the other node */
53 ctdb->nodes[c->vnn]->flags =
54 (ctdb->nodes[c->vnn]->flags&NODE_FLAGS_DISCONNECTED)
55 | (c->flags & ~NODE_FLAGS_DISCONNECTED);
56 DEBUG(2,("Node flags for node %u are now 0x%x\n", c->vnn, ctdb->nodes[c->vnn]->flags));
59 /* called when the "startup" event script has finished */
60 static void ctdb_start_transport(struct ctdb_context *ctdb, int status, void *p)
63 DEBUG(0,("startup event failed!\n"));
64 ctdb_fatal(ctdb, "startup event script failed");
67 /* start the transport running */
68 if (ctdb->methods->start(ctdb) != 0) {
69 DEBUG(0,("transport failed to start!\n"));
70 ctdb_fatal(ctdb, "transport failed to start");
73 /* start the recovery daemon process */
74 if (ctdb_start_recoverd(ctdb) != 0) {
75 DEBUG(0,("Failed to start recovery daemon\n"));
79 /* a handler for when nodes are disabled/enabled */
80 ctdb_register_message_handler(ctdb, ctdb, CTDB_SRVID_NODE_FLAGS_CHANGED,
81 flag_change_handler, NULL);
83 /* start monitoring for dead nodes */
84 ctdb_start_monitoring(ctdb);
87 /* go into main ctdb loop */
88 static void ctdb_main_loop(struct ctdb_context *ctdb)
92 if (strcmp(ctdb->transport, "tcp") == 0) {
93 int ctdb_tcp_init(struct ctdb_context *);
94 ret = ctdb_tcp_init(ctdb);
97 if (strcmp(ctdb->transport, "ib") == 0) {
98 int ctdb_ibw_init(struct ctdb_context *);
99 ret = ctdb_ibw_init(ctdb);
103 DEBUG(0,("Failed to initialise transport '%s'\n", ctdb->transport));
107 /* initialise the transport */
108 if (ctdb->methods->initialise(ctdb) != 0) {
109 DEBUG(0,("transport failed to initialise!\n"));
110 ctdb_fatal(ctdb, "transport failed to initialise");
113 /* tell all other nodes we've just started up */
114 ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL,
115 0, CTDB_CONTROL_STARTUP, 0,
116 CTDB_CTRL_FLAG_NOREPLY,
117 tdb_null, NULL, NULL);
119 ret = ctdb_event_script_callback(ctdb, timeval_zero(), ctdb,
120 ctdb_start_transport, NULL, "startup");
122 DEBUG(0,("Failed startup event script\n"));
126 /* go into a wait loop to allow other nodes to complete */
127 event_loop_wait(ctdb->ev);
129 DEBUG(0,("event_loop_wait() returned. this should not happen\n"));
134 static void block_signal(int signum)
136 struct sigaction act;
138 memset(&act, 0, sizeof(act));
140 act.sa_handler = SIG_IGN;
141 sigemptyset(&act.sa_mask);
142 sigaddset(&act.sa_mask, signum);
143 sigaction(signum, &act, NULL);
148 send a packet to a client
150 static int daemon_queue_send(struct ctdb_client *client, struct ctdb_req_header *hdr)
152 client->ctdb->statistics.client_packets_sent++;
153 return ctdb_queue_send(client->queue, (uint8_t *)hdr, hdr->length);
157 message handler for when we are in daemon mode. This redirects the message
160 static void daemon_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
161 TDB_DATA data, void *private_data)
163 struct ctdb_client *client = talloc_get_type(private_data, struct ctdb_client);
164 struct ctdb_req_message *r;
167 /* construct a message to send to the client containing the data */
168 len = offsetof(struct ctdb_req_message, data) + data.dsize;
169 r = ctdbd_allocate_pkt(ctdb, ctdb, CTDB_REQ_MESSAGE,
170 len, struct ctdb_req_message);
171 CTDB_NO_MEMORY_VOID(ctdb, r);
173 talloc_set_name_const(r, "req_message packet");
176 r->datalen = data.dsize;
177 memcpy(&r->data[0], data.dptr, data.dsize);
179 daemon_queue_send(client, &r->hdr);
186 this is called when the ctdb daemon received a ctdb request to
187 set the srvid from the client
189 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid)
191 struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
193 if (client == NULL) {
194 DEBUG(0,("Bad client_id in daemon_request_register_message_handler\n"));
197 res = ctdb_register_message_handler(ctdb, client, srvid, daemon_message_handler, client);
199 DEBUG(0,(__location__ " Failed to register handler %llu in daemon\n",
200 (unsigned long long)srvid));
202 DEBUG(2,(__location__ " Registered message handler for srvid=%llu\n",
203 (unsigned long long)srvid));
209 this is called when the ctdb daemon received a ctdb request to
210 remove a srvid from the client
212 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid)
214 struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
215 if (client == NULL) {
216 DEBUG(0,("Bad client_id in daemon_request_deregister_message_handler\n"));
219 return ctdb_deregister_message_handler(ctdb, srvid, client);
224 destroy a ctdb_client
226 static int ctdb_client_destructor(struct ctdb_client *client)
228 ctdb_takeover_client_destructor_hook(client);
229 ctdb_reqid_remove(client->ctdb, client->client_id);
230 client->ctdb->statistics.num_clients--;
236 this is called when the ctdb daemon received a ctdb request message
237 from a local client over the unix domain socket
239 static void daemon_request_message_from_client(struct ctdb_client *client,
240 struct ctdb_req_message *c)
245 /* maybe the message is for another client on this node */
246 if (ctdb_get_vnn(client->ctdb)==c->hdr.destnode) {
247 ctdb_request_message(client->ctdb, (struct ctdb_req_header *)c);
251 /* its for a remote node */
252 data.dptr = &c->data[0];
253 data.dsize = c->datalen;
254 res = ctdb_daemon_send_message(client->ctdb, c->hdr.destnode,
257 DEBUG(0,(__location__ " Failed to send message to remote node %u\n",
263 struct daemon_call_state {
264 struct ctdb_client *client;
266 struct ctdb_call *call;
267 struct timeval start_time;
271 complete a call from a client
273 static void daemon_call_from_client_callback(struct ctdb_call_state *state)
275 struct daemon_call_state *dstate = talloc_get_type(state->async.private_data,
276 struct daemon_call_state);
277 struct ctdb_reply_call *r;
280 struct ctdb_client *client = dstate->client;
282 talloc_steal(client, dstate);
283 talloc_steal(dstate, dstate->call);
285 res = ctdb_daemon_call_recv(state, dstate->call);
287 DEBUG(0, (__location__ " ctdbd_call_recv() returned error\n"));
288 client->ctdb->statistics.pending_calls--;
289 ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
293 length = offsetof(struct ctdb_reply_call, data) + dstate->call->reply_data.dsize;
294 r = ctdbd_allocate_pkt(client->ctdb, dstate, CTDB_REPLY_CALL,
295 length, struct ctdb_reply_call);
297 DEBUG(0, (__location__ " Failed to allocate reply_call in ctdb daemon\n"));
298 client->ctdb->statistics.pending_calls--;
299 ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
302 r->hdr.reqid = dstate->reqid;
303 r->datalen = dstate->call->reply_data.dsize;
304 memcpy(&r->data[0], dstate->call->reply_data.dptr, r->datalen);
306 res = daemon_queue_send(client, &r->hdr);
308 DEBUG(0, (__location__ " Failed to queue packet from daemon to client\n"));
310 ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
312 client->ctdb->statistics.pending_calls--;
316 static void daemon_request_call_from_client(struct ctdb_client *client,
317 struct ctdb_req_call *c);
320 this is called when the ctdb daemon received a ctdb request call
321 from a local client over the unix domain socket
323 static void daemon_request_call_from_client(struct ctdb_client *client,
324 struct ctdb_req_call *c)
326 struct ctdb_call_state *state;
327 struct ctdb_db_context *ctdb_db;
328 struct daemon_call_state *dstate;
329 struct ctdb_call *call;
330 struct ctdb_ltdb_header header;
333 struct ctdb_context *ctdb = client->ctdb;
335 ctdb->statistics.total_calls++;
336 ctdb->statistics.pending_calls++;
338 ctdb_db = find_ctdb_db(client->ctdb, c->db_id);
340 DEBUG(0, (__location__ " Unknown database in request. db_id==0x%08x",
342 ctdb->statistics.pending_calls--;
347 key.dsize = c->keylen;
349 ret = ctdb_ltdb_lock_fetch_requeue(ctdb_db, key, &header,
350 (struct ctdb_req_header *)c, &data,
351 daemon_incoming_packet, client, True);
353 /* will retry later */
354 ctdb->statistics.pending_calls--;
359 DEBUG(0,(__location__ " Unable to fetch record\n"));
360 ctdb->statistics.pending_calls--;
364 dstate = talloc(client, struct daemon_call_state);
365 if (dstate == NULL) {
366 ctdb_ltdb_unlock(ctdb_db, key);
367 DEBUG(0,(__location__ " Unable to allocate dstate\n"));
368 ctdb->statistics.pending_calls--;
371 dstate->start_time = timeval_current();
372 dstate->client = client;
373 dstate->reqid = c->hdr.reqid;
374 talloc_steal(dstate, data.dptr);
376 call = dstate->call = talloc_zero(dstate, struct ctdb_call);
378 ctdb_ltdb_unlock(ctdb_db, key);
379 DEBUG(0,(__location__ " Unable to allocate call\n"));
380 ctdb->statistics.pending_calls--;
381 ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
385 call->call_id = c->callid;
387 call->call_data.dptr = c->data + c->keylen;
388 call->call_data.dsize = c->calldatalen;
389 call->flags = c->flags;
391 if (header.dmaster == ctdb->vnn) {
392 state = ctdb_call_local_send(ctdb_db, call, &header, &data);
394 state = ctdb_daemon_call_send_remote(ctdb_db, call, &header);
397 ctdb_ltdb_unlock(ctdb_db, key);
400 DEBUG(0,(__location__ " Unable to setup call send\n"));
401 ctdb->statistics.pending_calls--;
402 ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
405 talloc_steal(state, dstate);
406 talloc_steal(client, state);
408 state->async.fn = daemon_call_from_client_callback;
409 state->async.private_data = dstate;
413 static void daemon_request_control_from_client(struct ctdb_client *client,
414 struct ctdb_req_control *c);
416 /* data contains a packet from the client */
417 static void daemon_incoming_packet(void *p, struct ctdb_req_header *hdr)
419 struct ctdb_client *client = talloc_get_type(p, struct ctdb_client);
421 struct ctdb_context *ctdb = client->ctdb;
423 /* place the packet as a child of a tmp_ctx. We then use
424 talloc_free() below to free it. If any of the calls want
425 to keep it, then they will steal it somewhere else, and the
426 talloc_free() will be a no-op */
427 tmp_ctx = talloc_new(client);
428 talloc_steal(tmp_ctx, hdr);
430 if (hdr->ctdb_magic != CTDB_MAGIC) {
431 ctdb_set_error(client->ctdb, "Non CTDB packet rejected in daemon\n");
435 if (hdr->ctdb_version != CTDB_VERSION) {
436 ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version);
440 switch (hdr->operation) {
442 ctdb->statistics.client.req_call++;
443 daemon_request_call_from_client(client, (struct ctdb_req_call *)hdr);
446 case CTDB_REQ_MESSAGE:
447 ctdb->statistics.client.req_message++;
448 daemon_request_message_from_client(client, (struct ctdb_req_message *)hdr);
451 case CTDB_REQ_CONTROL:
452 ctdb->statistics.client.req_control++;
453 daemon_request_control_from_client(client, (struct ctdb_req_control *)hdr);
457 DEBUG(0,(__location__ " daemon: unrecognized operation %u\n",
462 talloc_free(tmp_ctx);
466 called when the daemon gets a incoming packet
468 static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args)
470 struct ctdb_client *client = talloc_get_type(args, struct ctdb_client);
471 struct ctdb_req_header *hdr;
478 client->ctdb->statistics.client_packets_recv++;
480 if (cnt < sizeof(*hdr)) {
481 ctdb_set_error(client->ctdb, "Bad packet length %u in daemon\n",
485 hdr = (struct ctdb_req_header *)data;
486 if (cnt != hdr->length) {
487 ctdb_set_error(client->ctdb, "Bad header length %u expected %u\n in daemon",
488 (unsigned)hdr->length, (unsigned)cnt);
492 if (hdr->ctdb_magic != CTDB_MAGIC) {
493 ctdb_set_error(client->ctdb, "Non CTDB packet rejected\n");
497 if (hdr->ctdb_version != CTDB_VERSION) {
498 ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version);
502 DEBUG(3,(__location__ " client request %u of type %u length %u from "
503 "node %u to %u\n", hdr->reqid, hdr->operation, hdr->length,
504 hdr->srcnode, hdr->destnode));
506 /* it is the responsibility of the incoming packet function to free 'data' */
507 daemon_incoming_packet(client, hdr);
510 static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
511 uint16_t flags, void *private_data)
513 struct sockaddr_in addr;
516 struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
517 struct ctdb_client *client;
519 memset(&addr, 0, sizeof(addr));
521 fd = accept(ctdb->daemon.sd, (struct sockaddr *)&addr, &len);
527 set_close_on_exec(fd);
529 client = talloc_zero(ctdb, struct ctdb_client);
532 client->client_id = ctdb_reqid_new(ctdb, client);
533 ctdb->statistics.num_clients++;
535 client->queue = ctdb_queue_setup(ctdb, client, fd, CTDB_DS_ALIGNMENT,
536 ctdb_daemon_read_cb, client);
538 talloc_set_destructor(client, ctdb_client_destructor);
544 create a unix domain socket and bind it
545 return a file descriptor open on the socket
547 static int ux_socket_bind(struct ctdb_context *ctdb)
549 struct sockaddr_un addr;
551 ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
552 if (ctdb->daemon.sd == -1) {
556 set_nonblocking(ctdb->daemon.sd);
557 set_close_on_exec(ctdb->daemon.sd);
560 /* AIX doesn't like this :( */
561 if (fchown(ctdb->daemon.sd, geteuid(), getegid()) != 0 ||
562 fchmod(ctdb->daemon.sd, 0700) != 0) {
563 DEBUG(0,("Unable to secure ctdb socket '%s', ctdb->daemon.name\n"));
568 set_nonblocking(ctdb->daemon.sd);
570 memset(&addr, 0, sizeof(addr));
571 addr.sun_family = AF_UNIX;
572 strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path));
574 if (bind(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
575 DEBUG(0,("Unable to bind on ctdb socket '%s'\n", ctdb->daemon.name));
578 if (listen(ctdb->daemon.sd, 10) != 0) {
579 DEBUG(0,("Unable to listen on ctdb socket '%s'\n", ctdb->daemon.name));
586 close(ctdb->daemon.sd);
587 ctdb->daemon.sd = -1;
592 delete the socket on exit - called on destruction of autofree context
594 static int unlink_destructor(const char *name)
602 start the protocol going as a daemon
604 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
607 struct fd_event *fde;
608 const char *domain_socket_name;
610 /* get rid of any old sockets */
611 unlink(ctdb->daemon.name);
613 /* create a unix domain stream socket to listen to */
614 res = ux_socket_bind(ctdb);
616 DEBUG(0,(__location__ " Failed to open CTDB unix domain socket\n"));
620 if (do_fork && fork()) {
624 tdb_reopen_all(False);
629 block_signal(SIGPIPE);
631 /* try to set us up as realtime */
632 ctdb_set_realtime(true);
634 /* ensure the socket is deleted on exit of the daemon */
635 domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name);
636 talloc_set_destructor(domain_socket_name, unlink_destructor);
638 ctdb->ev = event_context_init(NULL);
640 /* start frozen, then let the first election sort things out */
641 if (!ctdb_blocking_freeze(ctdb)) {
642 DEBUG(0,("Failed to get initial freeze\n"));
646 /* force initial recovery for election */
647 ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
649 /* now start accepting clients, only can do this once frozen */
650 fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd,
651 EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
652 ctdb_accept_client, ctdb);
654 ctdb_main_loop(ctdb);
660 allocate a packet for use in client<->daemon communication
662 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
664 enum ctdb_operation operation,
665 size_t length, size_t slength,
669 struct ctdb_req_header *hdr;
671 length = MAX(length, slength);
672 size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
674 hdr = (struct ctdb_req_header *)talloc_size(mem_ctx, size);
676 DEBUG(0,("Unable to allocate packet for operation %u of length %u\n",
677 operation, (unsigned)length));
680 talloc_set_name_const(hdr, type);
681 memset(hdr, 0, slength);
682 hdr->length = length;
683 hdr->operation = operation;
684 hdr->ctdb_magic = CTDB_MAGIC;
685 hdr->ctdb_version = CTDB_VERSION;
686 hdr->srcnode = ctdb->vnn;
688 hdr->generation = ctdb->vnn_map->generation;
696 allocate a packet for use in daemon<->daemon communication
698 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
700 enum ctdb_operation operation,
701 size_t length, size_t slength,
705 struct ctdb_req_header *hdr;
707 length = MAX(length, slength);
708 size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
710 hdr = (struct ctdb_req_header *)ctdb->methods->allocate_pkt(mem_ctx, size);
712 DEBUG(0,("Unable to allocate transport packet for operation %u of length %u\n",
713 operation, (unsigned)length));
716 talloc_set_name_const(hdr, type);
717 memset(hdr, 0, slength);
718 hdr->length = length;
719 hdr->operation = operation;
720 hdr->ctdb_magic = CTDB_MAGIC;
721 hdr->ctdb_version = CTDB_VERSION;
722 hdr->generation = ctdb->vnn_map->generation;
723 hdr->srcnode = ctdb->vnn;
728 struct daemon_control_state {
729 struct daemon_control_state *next, *prev;
730 struct ctdb_client *client;
731 struct ctdb_req_control *c;
733 struct ctdb_node *node;
737 callback when a control reply comes in
739 static void daemon_control_callback(struct ctdb_context *ctdb,
740 int32_t status, TDB_DATA data,
741 const char *errormsg,
744 struct daemon_control_state *state = talloc_get_type(private_data,
745 struct daemon_control_state);
746 struct ctdb_client *client = state->client;
747 struct ctdb_reply_control *r;
750 /* construct a message to send to the client containing the data */
751 len = offsetof(struct ctdb_reply_control, data) + data.dsize;
753 len += strlen(errormsg);
755 r = ctdbd_allocate_pkt(ctdb, state, CTDB_REPLY_CONTROL, len,
756 struct ctdb_reply_control);
757 CTDB_NO_MEMORY_VOID(ctdb, r);
759 r->hdr.reqid = state->reqid;
761 r->datalen = data.dsize;
763 memcpy(&r->data[0], data.dptr, data.dsize);
765 r->errorlen = strlen(errormsg);
766 memcpy(&r->data[r->datalen], errormsg, r->errorlen);
769 daemon_queue_send(client, &r->hdr);
775 fail all pending controls to a disconnected node
777 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node)
779 struct daemon_control_state *state;
780 while ((state = node->pending_controls)) {
781 DLIST_REMOVE(node->pending_controls, state);
782 daemon_control_callback(ctdb, (uint32_t)-1, tdb_null,
783 "node is disconnected", state);
788 destroy a daemon_control_state
790 static int daemon_control_destructor(struct daemon_control_state *state)
793 DLIST_REMOVE(state->node->pending_controls, state);
799 this is called when the ctdb daemon received a ctdb request control
800 from a local client over the unix domain socket
802 static void daemon_request_control_from_client(struct ctdb_client *client,
803 struct ctdb_req_control *c)
807 struct daemon_control_state *state;
808 TALLOC_CTX *tmp_ctx = talloc_new(client);
810 if (c->hdr.destnode == CTDB_CURRENT_NODE) {
811 c->hdr.destnode = client->ctdb->vnn;
814 state = talloc(client, struct daemon_control_state);
815 CTDB_NO_MEMORY_VOID(client->ctdb, state);
817 state->client = client;
818 state->c = talloc_steal(state, c);
819 state->reqid = c->hdr.reqid;
820 if (ctdb_validate_vnn(client->ctdb, c->hdr.destnode)) {
821 state->node = client->ctdb->nodes[c->hdr.destnode];
822 DLIST_ADD(state->node->pending_controls, state);
827 talloc_set_destructor(state, daemon_control_destructor);
829 if (c->flags & CTDB_CTRL_FLAG_NOREPLY) {
830 talloc_steal(tmp_ctx, state);
833 data.dptr = &c->data[0];
834 data.dsize = c->datalen;
835 res = ctdb_daemon_send_control(client->ctdb, c->hdr.destnode,
836 c->srvid, c->opcode, client->client_id,
838 data, daemon_control_callback,
841 DEBUG(0,(__location__ " Failed to send control to remote node %u\n",
845 talloc_free(tmp_ctx);
849 register a call function
851 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
852 ctdb_fn_t fn, int id)
854 struct ctdb_registered_call *call;
855 struct ctdb_db_context *ctdb_db;
857 ctdb_db = find_ctdb_db(ctdb, db_id);
858 if (ctdb_db == NULL) {
862 call = talloc(ctdb_db, struct ctdb_registered_call);
866 DLIST_ADD(ctdb_db->calls, call);