You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Andrew Stitcher <as...@apache.org> on 2021/03/02 22:44:03 UTC

Proton-c Heads up: Recent changes to the proactor raw connection API

I've just finished a recent round of improvements to the raw connection
API (these should hit release with proton-c 0.34).

The proactor raw connection API now supports 'half' closing:

This is equivalent to calling the BSD shutdown(fd, SHUT_RD) or
shutdown(fd, SHUT_WR). This adds 2 new API calls:

pn_raw_connection_read_close(connection);
pn_raw_connection_write_close(connection);

These have the expected semantics (or at least it's the obvious
semantics to me!)

---

The other API change is to introduce a new event specifically to tell
the application the drain all of its buffers from the raw connection in
preparation for the connection disconnecting and going away forwever. 

Previously this was done by overloading the meaning of the
PN_RAW_CONNECTION_READ and PN_RAW_CONNECTION_WRITTEN events, however
this was confusing and I got queries about this multiple times!

The new event is: PN_RAW_CONNECTION_DRAIN_BUFFERS.

As an interim backwards compatibility  measure, if the application
ignores the DRAIN_BUFFERS event and does not take its buffers back it
will also get the old READ and/or WRITTEN events too. If it still
ignores these events then the buffers will ultimately leak (but that
was previously true in any case!).

I plan that the backwards compatibility behaviour should go away as
soon as the dispatch router uses the new event as it is the major
(only?) user of the raw connection API.

[This whole process is necessary as the application has full control of
the raw connection buffers it gives to the proactor and so needs to
free them itself. The proactor can make no assumption that the buffers
could be freed using free() as they miay not come form malloc() etc. So
to avoid a memory leak the applicatino must take its buffer back before
the raw connection goes away.]

---

Questions? Brickbats, plaudits... to me.

Regards

Andrew



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