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

remove flux_msg_handler_t member from struct flux_msg_handler_spec #1135

Closed
morrone opened this issue Aug 3, 2017 · 3 comments
Closed

remove flux_msg_handler_t member from struct flux_msg_handler_spec #1135

morrone opened this issue Aug 3, 2017 · 3 comments
Assignees

Comments

@morrone
Copy link
Contributor

morrone commented Aug 3, 2017

The flux_msg_handler_t pointer in struct flux_msg_handler_spec (in src/common/libflux/dispatch.h) seems a little odd to me. I can only guess that the intent was to allow bulk registration of handlers, but still allow the code to individually stop and restart the handler later?

That seems a little a pretty unlikely use case to me. It also turns a simple one-way passing of information into a potentially slightly more complicated two-way passing of information using the same array.

A survey of the code shows that nowhere is this used in either flux core or flux sched.

I am going to suggest that if an application needs to stop and start a registered handler, it can just use the non-array form of the create/start/stop/destroy functions rather than the array form.

I propose that we simplify the struct flux_msg_handler_spec to eliminate the flux_msg_handler_t field.

@garlick
Copy link
Member

garlick commented Aug 3, 2017

Actually, it's used by flux_msg_handler_delvec() to destroy the handlers created by _addvec().

@morrone
Copy link
Contributor Author

morrone commented Aug 3, 2017

Ahhh, I see. I would propose that the flux_msg_handler_t array be broken out from the flux_msg_handler_spec. I image that flux_msg_handler_delvec() ignores everything but the flux_msg_handler_t field, which makes it a little strange to pass it all of that information. By breaking it apart, we have clear input and output variables.

So this:

struct flux_msg_handler_spec {
    int typemask;
    char *topic_glob;
    flux_msg_handler_f cb;
    uint32_t rolemask;
    flux_msg_handler_t *w;
};
#define FLUX_MSGHANDLER_TABLE_END { 0, NULL, NULL, 0, NULL }

int flux_msg_handler_addvec (flux_t *h, struct flux_msg_handler_spec tab[],
                             void *arg);
void flux_msg_handler_delvec (struct flux_msg_handler_spec tab[]);

would become something like this:

struct flux_msg_handler_spec {
    int typemask;
    char *topic_glob;
    flux_msg_handler_f cb;
    uint32_t rolemask;
};
#define FLUX_MSGHANDLER_TABLE_END { 0, NULL, NULL, 0, NULL }

int flux_msg_handler_addvec (flux_t *h, void *arg, const struct flux_msg_handler_spec tab[],
                                                  flux_msg_handler_t **msg_handlers);
void flux_msg_handler_delvec (struct flux_msg_handler_t **msg_handlers);

@garlick
Copy link
Member

garlick commented Aug 3, 2017

That sounds like a good cleanup. delvec would need a count argument too I guess...

@garlick garlick changed the title flux_msg_handler_t in struct flux_msg_handler_spec remove flux_msg_handler_t member from struct flux_msg_handler_spec Nov 7, 2017
@garlick garlick self-assigned this Nov 7, 2017
garlick added a commit to garlick/flux-core that referenced this issue Nov 7, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 7, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 8, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 8, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 9, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 10, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
garlick added a commit to garlick/flux-core that referenced this issue Nov 10, 2017
Problem: use of struct flux_msg_handler_spec for both
addvec and delvec functions is confusing.

Drop flux_msg_handler_t * member from struct flux_msg_handler_spec.
In flux_msg_handler_addvec(), make 'tab' parameter const (purely
input), and add an output parameter which is a NULL terminated
list of flux_msg_handler_t's.  The list of message handlers becomes
the sole input to flux_msg_handler_delvec.

Update users and tests.

Fixes flux-framework#1135.
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

No branches or pull requests

2 participants