implement matchtag protocol enhancement #123
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows clients to assign a unique integer 'matchtag' to a request which will be echoed back in the corresponding response. This makes it easier for a client to manage multiple outstanding requests.
The
flux_t
handle implements a "tag pool". Unique matchtags can be obtained usingflux_matchtag_alloc()
and retired usingflux_matchtag_free()
.flux_json_rpc()
hides tag management from callers.flux_response_recvmsg()
now has amatchtag
argument and will manage the requeuing of messages that come in but do not match the requested tag. Alternatively, calling it with a matchtag of 0 disables tag matching.flux_json_request()
also has amatchtag
argument.The previous method of matching on topic strings limited concurrency since at most one request per topic string could be outstanding. This was especially problematic in situations where a request generated an unknown number of replies, such as with
kvs_watch()
.The integer matchtag scheme was borrowed from the 9P protocol in Plan 9. One difference is 9P uses a 16-bit tag value while I went with an 8-bit one. Easy to change that later if we need more concurrency, but 255 outstanding requests per handle should get us pretty far for now and allows a trivial tagpool implementation.