This is an automated email from the ASF dual-hosted git repository. cliffjansen pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push: new b69fc15c7 PROTON-2633: epoll proactor write flush functionality b69fc15c7 is described below commit b69fc15c7d5eff72872706c2093ca149786c9a7a Author: Clifford Jansen <cliffjan...@apache.org> AuthorDate: Sun Oct 30 23:54:47 2022 -0700 PROTON-2633: epoll proactor write flush functionality --- c/include/proton/proactor.h | 16 ++++++++++++++++ c/src/proactor/epoll.c | 10 ++++++++++ c/src/proactor/libuv.c | 3 +++ c/src/proactor/win_iocp.cpp | 3 +++ 4 files changed, 32 insertions(+) diff --git a/c/include/proton/proactor.h b/c/include/proton/proactor.h index 93b9c894b..1d7ff6c8c 100644 --- a/c/include/proton/proactor.h +++ b/c/include/proton/proactor.h @@ -292,6 +292,22 @@ PNP_EXTERN void pn_proactor_release_connection(pn_connection_t *connection); */ PNP_EXTERN void pn_connection_wake(pn_connection_t *connection); +/** + * **Unsettled API** Send available AMQP protocol frames to the remote peer. + * + * Generate as many currently availabe AMQP frames for @p connection that can be sent on + * the network to the remote peer without blocking. May help reduce latency, at the expense of + * extra processing overhead, for event handlers that spend a long time processing a + * single event batch. Has little effect if called soon before a call to + * pn_proactor_done(). + * + * @note **Not thread-safe**. Call this function from a connection + * event handler. + * + * @note If @p connection does not belong to a proactor, this call does nothing. + */ +PNP_EXTERN void pn_connection_write_flush(pn_connection_t *connection); + /** * Return the proactor associated with a connection. * diff --git a/c/src/proactor/epoll.c b/c/src/proactor/epoll.c index 35a728984..e78b91f67 100644 --- a/c/src/proactor/epoll.c +++ b/c/src/proactor/epoll.c @@ -2946,3 +2946,13 @@ int64_t pn_proactor_now_64(void) { clock_gettime(CLOCK_MONOTONIC, &t); return ((int64_t)t.tv_sec) * 1000 + t.tv_nsec / 1000000; } + +void pn_connection_write_flush(pn_connection_t *c) { + pconnection_t *pc = get_pconnection(c); + if (pc) { + // Assume can write and have frames to write. Booleans will be correctly re-evaluated in write_flush(). + pc->write_blocked = false; + pc->output_drained = false; + write_flush(pc); // May generate transport event. + } +} diff --git a/c/src/proactor/libuv.c b/c/src/proactor/libuv.c index 9179823a0..aebd4a238 100644 --- a/c/src/proactor/libuv.c +++ b/c/src/proactor/libuv.c @@ -1368,6 +1368,9 @@ int64_t pn_proactor_now_64(void) { return uv_hrtime() / 1000000; // uv_hrtime returns time in nanoseconds } +// Empty stub for pending write flush functionality. +void pn_connection_write_flush(pn_connection_t *connection) {} + // Empty stubs for raw connection code pn_raw_connection_t *pn_raw_connection(void) { return NULL; } void pn_proactor_raw_connect(pn_proactor_t *p, pn_raw_connection_t *rc, const char *addr) {} diff --git a/c/src/proactor/win_iocp.cpp b/c/src/proactor/win_iocp.cpp index 7e7f1378d..4293d4464 100644 --- a/c/src/proactor/win_iocp.cpp +++ b/c/src/proactor/win_iocp.cpp @@ -3421,6 +3421,9 @@ int64_t pn_proactor_now_64(void) { return GetTickCount64(); } +// Empty stub for pending write flush functionality. +void pn_connection_write_flush(pn_connection_t *connection) {} + // Empty stubs for raw connection code pn_raw_connection_t *pn_raw_connection(void) { return NULL; } void pn_proactor_raw_connect(pn_proactor_t *p, pn_raw_connection_t *rc, const char *addr) {} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org