]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Add ctdbd_init_async_connection()
authorVolker Lendecke <vl@samba.org>
Thu, 12 Mar 2020 15:05:58 +0000 (16:05 +0100)
committerRalph Boehme <slow@samba.org>
Tue, 28 Apr 2020 09:08:39 +0000 (09:08 +0000)
Prepare for ctdb_req_send/recv doing tevent_req based async ctdb
requests

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdbd_conn.c

index f6040ad833b25bb9acf3d38d0045d74ae49b4dfc..123294ff78262e42ce7950965d2eb33c3ab2bbdb 100644 (file)
@@ -34,6 +34,11 @@ struct messaging_rec;
 int ctdbd_init_connection(TALLOC_CTX *mem_ctx,
                          const char *sockname, int timeout,
                          struct ctdbd_connection **pconn);
+int ctdbd_init_async_connection(
+       TALLOC_CTX *mem_ctx,
+       const char *sockname,
+       int timeout,
+       struct ctdbd_connection **pconn);
 int ctdbd_reinit_connection(TALLOC_CTX *mem_ctx,
                            const char *sockname, int timeout,
                            struct ctdbd_connection *conn);
index 498f477a3be8cfde638e01be866408d4513dd903..35e5e34f49c65d1b2553462dc6b46964aac88869 100644 (file)
@@ -80,6 +80,11 @@ struct ctdbd_connection {
        /* Lists of pending async reads and writes */
        struct ctdb_pkt_recv_state *recv_list;
        struct ctdb_pkt_send_state *send_list;
+
+       /*
+        * Outgoing queue for writev_send of asynchronous ctdb requests
+        */
+       struct tevent_queue *outgoing;
 };
 
 static void ctdbd_async_socket_handler(struct tevent_context *ev,
@@ -572,6 +577,37 @@ int ctdbd_reinit_connection(TALLOC_CTX *mem_ctx,
        return 0;
 }
 
+int ctdbd_init_async_connection(
+       TALLOC_CTX *mem_ctx,
+       const char *sockname,
+       int timeout,
+       struct ctdbd_connection **pconn)
+{
+       struct ctdbd_connection *conn = NULL;
+       int ret;
+
+       ret = ctdbd_init_connection(mem_ctx, sockname, timeout, &conn);
+       if (ret != 0) {
+               return ret;
+       }
+
+       ret = set_blocking(conn->fd, false);
+       if (ret == -1) {
+               int err = errno;
+               TALLOC_FREE(conn);
+               return err;
+       }
+
+       conn->outgoing = tevent_queue_create(conn, "ctdb async outgoing");
+       if (conn->outgoing == NULL) {
+               TALLOC_FREE(conn);
+               return ENOMEM;
+       }
+
+       *pconn = conn;
+       return 0;
+}
+
 int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
 {
        return conn->fd;