Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libflux/msg_handler: improve lookup of message handlers for RPCs #1807

Merged
merged 8 commits into from Nov 7, 2018

Conversation

garlick
Copy link
Member

@garlick garlick commented Nov 7, 2018

As discussed in #1804, this PR simplifies the mechanism used to look up message handlers (by integer matchtag) for received request messages. The current mechanism is hand-coded table lookup. The replacement is zhashx_t, a well tested container.

There is some additional cleanup of errno handling and handling of invalid arguments.

A trivial test was added to ensure invalid arguments cause functions to fail with EINVAL.

Also I tossed in @grondo's build system fix to AM_TESTS_ENVIRONMENT usage suggested in #1803.

Instead of maintaining an array indexed by matchtag
to quickly locate message handlers for RPCs, use a
zhashx configured to use matchtags as hash keys.

This should scale just as well with less complexity.
Problem: flux_msg_handler_delvec() calls functions
like free() which might overwrite errno.

Save and restore errno inside the function, and then
remove save/restore in flux_msg_handler_addvec()
error path.
Save/restore errno in internal free_msg_handler(), then
eliminate awkward errno preserving code in flux_msg_handler_create()
error paths.
Problem: flux_msg_handler_destroy() calls functions that
might overwrite errno.

Save/restore errno.
Problem: flux_msg_handler_create() segfaults on a NULL
flux_t handle.

Add an EINVAL check.
Problem: flux_dispatch_requeue() segfaults on a NULL argument.

Return EINVAL flux_t argument is NULL
@codecov-io
Copy link

Codecov Report

Merging #1807 into master will increase coverage by 0.02%.
The diff coverage is 92.68%.

@@            Coverage Diff             @@
##           master    #1807      +/-   ##
==========================================
+ Coverage   79.65%   79.68%   +0.02%     
==========================================
  Files         187      187              
  Lines       34599    34575      -24     
==========================================
- Hits        27561    27552       -9     
+ Misses       7038     7023      -15
Impacted Files Coverage Δ
src/common/libflux/msg_handler.c 90.23% <92.68%> (+4.16%) ⬆️
src/common/libflux/message.c 81.39% <0%> (ø) ⬆️
src/cmd/flux-module.c 85.88% <0%> (+0.3%) ⬆️

@grondo grondo merged commit 3040798 into flux-framework:master Nov 7, 2018
@grondo
Copy link
Contributor

grondo commented Nov 7, 2018

Nice improvement!

@garlick
Copy link
Member Author

garlick commented Nov 7, 2018

Thanks!

@garlick garlick deleted the dispatch_fastpath branch November 7, 2018 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants