mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Make the call to free the request explicit in the callback
instead of implicit (This used to be ctdb commit 573e4e2d2bd09dd9579150cce926de774a0b609c)
This commit is contained in:
parent
e999119d40
commit
f94291c37d
@ -26,13 +26,13 @@
|
||||
#include <tdb.h>
|
||||
|
||||
/* All *_send() functions are guaranteed to be non-blocking and fully
|
||||
* asynchronous. The non-_send variants are synchronous. */
|
||||
* asynchronous. The non-_send variants are synchronous.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Connect to ctdb using the specified domain socket.
|
||||
* Returns a ctdb context if successful or NULL.
|
||||
*
|
||||
* Use ctdb_free() to release the returned ctdb_connection when finished.
|
||||
*/
|
||||
struct ctdb_connection *ctdb_connect(const char *addr);
|
||||
|
||||
@ -48,7 +48,8 @@ void ctdb_request_free(struct ctdb_request *req);
|
||||
|
||||
/*
|
||||
* Callback for completed requests: it would normally unpack the request
|
||||
* using ctdb_*_recv(). You must free the request using ctdb_request_free().
|
||||
* using ctdb_*_recv().
|
||||
* You must free the request using ctdb_request_free().
|
||||
*
|
||||
* Note that due to macro magic, your callback doesn't have to take void *,
|
||||
* it can take a type which matches the actual private parameter.
|
||||
|
@ -75,6 +75,7 @@ static void set_pnn(struct ctdb_connection *ctdb,
|
||||
/* FIXME: Report error. */
|
||||
ctdb->broken = true;
|
||||
}
|
||||
ctdb_request_free(req);
|
||||
}
|
||||
|
||||
struct ctdb_connection *ctdb_connect(const char *addr)
|
||||
@ -240,7 +241,6 @@ static void handle_incoming(struct ctdb_connection *ctdb, struct io_elem *in)
|
||||
DLIST_REMOVE(ctdb->doneq, i);
|
||||
i->reply = in;
|
||||
i->callback(ctdb, i, i->priv_data);
|
||||
ctdb_request_free(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ static void pnn_cb(struct ctdb_connection *ctdb,
|
||||
uint32_t pnn;
|
||||
|
||||
status = ctdb_getpnn_recv(req, &pnn);
|
||||
ctdb_request_free(req);
|
||||
if (status != 0) {
|
||||
printf("Error reading PNN\n");
|
||||
return;
|
||||
@ -64,6 +65,7 @@ static void rm_cb(struct ctdb_connection *ctdb,
|
||||
uint32_t rm;
|
||||
|
||||
status = ctdb_getrecmaster_recv(req, &rm);
|
||||
ctdb_request_free(req);
|
||||
if (status != 0) {
|
||||
printf("Error reading RECMASTER\n");
|
||||
return;
|
||||
@ -118,6 +120,7 @@ void message_handler_cb(struct ctdb_connection *ctdb,
|
||||
if (ctdb_set_message_handler_recv(ctdb, req) != 0) {
|
||||
err(1, "registering message");
|
||||
}
|
||||
ctdb_request_free(req);
|
||||
printf("Message handler registered\n");
|
||||
registered = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user