LibCTDB
[sahlberg/ctdb.git] / ib / ibwrapper.h
index 31f7a4f170b05977f0435ac714f87a6eb9518bd6..0b880b3aab7fb070e4a62a2dd7f2569a9a805ce8 100644 (file)
@@ -8,7 +8,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /* Server communication state */
@@ -107,8 +106,7 @@ struct ibw_ctx *ibw_init(struct ibw_initattr *attr, int nattr,
        void *ctx_userdata,
        ibw_connstate_fn_t ibw_connstate,
        ibw_receive_fn_t ibw_receive,
-       struct event_context *ectx,
-       int max_msg_size);
+       struct event_context *ectx);
 
 /*
  * Must be called in states of (IBWS_ERROR, IBWS_READY, IBWS_CONNECT_REQUEST)
@@ -154,6 +152,14 @@ int ibw_listen(struct ibw_ctx *ctx, int backlog);
  */
 int ibw_accept(struct ibw_ctx *ctx, struct ibw_conn *conn, void *conn_userdata);
 
+/*
+ * Create a new connection structure
+ * available for queueing ibw_send
+ *
+ * <parent> is needed to be notified by talloc destruct action.
+ */
+struct ibw_conn *ibw_conn_new(struct ibw_ctx *ctx, TALLOC_CTX *mem_ctx);
+
 /*
  * Needs a normal internet address here
  * can be called within IBWS_READY|IBWS_CONNECT_REQUEST
@@ -163,7 +169,7 @@ int ibw_accept(struct ibw_ctx *ctx, struct ibw_conn *conn, void *conn_userdata);
  * You have +1 waiting here: you will get ibw_conn (having the
  * same <conn_userdata> member) structure in ibw_connstate_fn_t.
  */
-int ibw_connect(struct ibw_ctx *ctx, struct sockaddr_in *serv_addr, void *conn_userdata);
+int ibw_connect(struct ibw_conn *conn, struct sockaddr_in *serv_addr, void *conn_userdata);
 
 /*
  * Sends out a disconnect request.
@@ -186,7 +192,7 @@ int ibw_disconnect(struct ibw_conn *conn);
  *
  * Returns 0 on success.
  */
-int ibw_alloc_send_buf(struct ibw_conn *conn, void **buf, void **key);
+int ibw_alloc_send_buf(struct ibw_conn *conn, void **buf, void **key, uint32_t len);
 
 /*
  * Send the message in one
@@ -196,7 +202,14 @@ int ibw_alloc_send_buf(struct ibw_conn *conn, void **buf, void **key);
  *
  * You mustn't use (buf, key) any more for sending.
  */
-int ibw_send(struct ibw_conn *conn, void *buf, void *key, int n);
+int ibw_send(struct ibw_conn *conn, void *buf, void *key, uint32_t len);
+
+/*
+ * Call this after ibw_alloc_send_buf
+ * when you won't call ibw_send for (buf, key)
+ * You mustn't use (buf, key) any more.
+ */
+int ibw_cancel_send_buf(struct ibw_conn *conn, void *buf, void *key);
 
 /*
  * Retrieves the last error