You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2021/03/02 04:24:36 UTC

[qpid-proton] 01/03: PROTON-2338: [proactor] Add prototypes for new raw connection half close operations

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit e482440730a47e737214b47ff46a5d309f28324a
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon Feb 1 20:39:06 2021 -0500

    PROTON-2338: [proactor] Add prototypes for new raw connection half close operations
    
    - Add stubs for libuv and win_iocp proactor implementations
---
 c/include/proton/raw_connection.h | 36 +++++++++++++++++++++++++++++++++++-
 c/src/proactor/libuv.c            |  2 ++
 c/src/proactor/win_iocp.cpp       |  2 ++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/c/include/proton/raw_connection.h b/c/include/proton/raw_connection.h
index 7be7e61..d19ff6d 100644
--- a/c/include/proton/raw_connection.h
+++ b/c/include/proton/raw_connection.h
@@ -91,7 +91,9 @@ PNP_EXTERN const struct pn_netaddr_t *pn_raw_connection_remote_addr(pn_raw_conne
 
 /**
  * Close a raw connection.
- * This will close the underlying socket and release all buffers held by the raw connection.
+ * This will flush any buffers to be written; close the underlying socket and release all buffers held by the
+ * raw connection.
+ *
  * It will cause @ref PN_RAW_CONNECTION_READ and @ref PN_RAW_CONNECTION_WRITTEN to be emitted so
  * the application can clean up buffers given to the raw connection. After that a
  * @ref PN_RAW_CONNECTION_DISCONNECTED event will be emitted to allow the application to clean up
@@ -101,6 +103,38 @@ PNP_EXTERN const struct pn_netaddr_t *pn_raw_connection_remote_addr(pn_raw_conne
 PNP_EXTERN void pn_raw_connection_close(pn_raw_connection_t *connection);
 
 /**
+ * Shutdown a raw connection for reading.
+ * This will close the underlying socket for reading and release all empty read buffers held by the raw connection.
+ *
+ * It will cause @ref PN_RAW_CONNECTION_READ to be emitted so the application can clean up buffers given to the raw
+ * connection. Note that these buffers may still also contain data read from the socket but not yet consumed by the
+ * application.
+ *
+ * If @ref pn_raw_connection_write_close() has already been called then @ref PN_RAW_CONNECTION_DISCONNECTED will then
+ * also be emitted.
+ *
+ * In order to fully close a raw connection the application will need to either call @ref pn_raw_connection_close()
+ * or @ref pn_raw_connection_write_close() after it calls @ref pn_raw_connection_read_close().
+ */
+PNP_EXTERN void pn_raw_connection_read_close(pn_raw_connection_t *connection);
+
+/**
+ * Shutdown a raw connection for writing.
+ * This will flush any buffers to be written to the socket; close the underlying socket for writing and release all
+ * write buffers held by the raw connection.
+ *
+ * It will cause @ref PN_RAW_CONNECTION_WRITTEN to be emitted so the application can clean up write buffers given to
+ * the raw connection.
+ *
+ * If @ref pn_raw_connection_read_close() has already been called then @ref PN_RAW_CONNECTION_DISCONNECTED will then
+ * also be emitted.
+ *
+ * In order to fully close a raw connection the application will need to either call @ref pn_raw_connection_close()
+ * or @ref pn_raw_connection_read_close() after it calls @ref pn_raw_connection_write_close().
+ */
+PNP_EXTERN void pn_raw_connection_write_close(pn_raw_connection_t *connection);
+
+/**
  * Query the raw connection for how many more read buffers it can be given
  */
 PNP_EXTERN size_t pn_raw_connection_read_buffers_capacity(pn_raw_connection_t *connection);
diff --git a/c/src/proactor/libuv.c b/c/src/proactor/libuv.c
index b06b1eb..3e50685 100644
--- a/c/src/proactor/libuv.c
+++ b/c/src/proactor/libuv.c
@@ -1367,5 +1367,7 @@ void pn_proactor_raw_connect(pn_proactor_t *p, pn_raw_connection_t *rc, const ch
 void pn_listener_raw_accept(pn_listener_t *l, pn_raw_connection_t *rc) {}
 void pn_raw_connection_wake(pn_raw_connection_t *conn) {}
 void pn_raw_connection_close(pn_raw_connection_t *conn) {}
+void pn_raw_connection_read_close(pn_raw_connection_t *conn) {}
+void pn_raw_connection_write_close(pn_raw_connection_t *conn) {}
 const struct pn_netaddr_t *pn_raw_connection_local_addr(pn_raw_connection_t *connection) { return NULL; }
 const struct pn_netaddr_t *pn_raw_connection_remote_addr(pn_raw_connection_t *connection) { return NULL; }
diff --git a/c/src/proactor/win_iocp.cpp b/c/src/proactor/win_iocp.cpp
index a71947a..51512bd 100644
--- a/c/src/proactor/win_iocp.cpp
+++ b/c/src/proactor/win_iocp.cpp
@@ -3427,5 +3427,7 @@ void pn_proactor_raw_connect(pn_proactor_t *p, pn_raw_connection_t *rc, const ch
 void pn_listener_raw_accept(pn_listener_t *l, pn_raw_connection_t *rc) {}
 void pn_raw_connection_wake(pn_raw_connection_t *conn) {}
 void pn_raw_connection_close(pn_raw_connection_t *conn) {}
+void pn_raw_connection_read_close(pn_raw_connection_t *conn) {}
+void pn_raw_connection_write_close(pn_raw_connection_t *conn) {}
 const struct pn_netaddr_t *pn_raw_connection_local_addr(pn_raw_connection_t *connection) { return NULL; }
 const struct pn_netaddr_t *pn_raw_connection_remote_addr(pn_raw_connection_t *connection) { return NULL; }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org