Skip to content

Commit

Permalink
libflux/message: name route functions consistently
Browse files Browse the repository at this point in the history
Problem: The naming of the flux msg route functions was inconsistent,
with some prefixing the action with "get" while others not.  Some stating
the "action" before "route" and others not.

Solution: Make the function names consistent.  Specifically, the following
functions have been renamed.

flux_msg_enable_route -> flux_msg_route_enable
flux_msg_disable_route -> flux_msg_route_disable
flux_msg_clear_route -> flux_msg_route_clear
flux_msg_push_route -> flux_msg_route_push
flux_msg_delete_route_last -> flux_msg_route_delete_last
flux_msg_get_route_first -> flux_msg_route_first
flux_msg_get_route_last -> flux_msg_route_last
flux_msg_get_route_count -> flux_msg_route_count
flux_msg_get_route_string -> flux_msg_route_string
flux_msg_match_route_first -> flux_msg_route_match_first

Some internal functions were renamed as well for consistency.

Update all callers appropriately.
  • Loading branch information
chu11 committed Jul 7, 2021
1 parent 5640268 commit 469e720
Show file tree
Hide file tree
Showing 34 changed files with 238 additions and 238 deletions.
14 changes: 7 additions & 7 deletions src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ static void broker_disconnect_cb (flux_t *h, flux_msg_handler_t *mh,
{
const char *sender;

if ((sender = flux_msg_get_route_first (msg)))
if ((sender = flux_msg_route_first (msg)))
exec_terminate_subprocesses_by_uuid (h, sender);
/* no response */
}
Expand All @@ -1095,7 +1095,7 @@ static void broker_sub_cb (flux_t *h, flux_msg_handler_t *mh,

if (flux_request_unpack (msg, NULL, "{ s:s }", "topic", &topic) < 0)
goto error;
if (!(uuid = flux_msg_get_route_first (msg))) {
if (!(uuid = flux_msg_route_first (msg))) {
errno = EPROTO;
goto error;
}
Expand All @@ -1122,7 +1122,7 @@ static void broker_unsub_cb (flux_t *h, flux_msg_handler_t *mh,

if (flux_request_unpack (msg, NULL, "{ s:s }", "topic", &topic) < 0)
goto error;
if (!(uuid = flux_msg_get_route_first (msg))) {
if (!(uuid = flux_msg_route_first (msg))) {
errno = EPROTO;
goto error;
}
Expand Down Expand Up @@ -1182,7 +1182,7 @@ static void service_add_cb (flux_t *h, flux_msg_handler_t *w,
goto error;
if (service_allow (cred, name) < 0)
goto error;
if (!(sender = flux_msg_get_route_first (msg))) {
if (!(sender = flux_msg_route_first (msg))) {
errno = EPROTO;
goto error;
}
Expand Down Expand Up @@ -1214,7 +1214,7 @@ static void service_remove_cb (flux_t *h, flux_msg_handler_t *w,
goto error;
if (service_allow (cred, name) < 0)
goto error;
if (!(sender = flux_msg_get_route_first (msg))) {
if (!(sender = flux_msg_route_first (msg))) {
errno = EPROTO;
goto error;
}
Expand Down Expand Up @@ -1468,7 +1468,7 @@ static void module_cb (module_t *p, void *arg)
(void)broker_response_sendmsg (ctx, msg);
break;
case FLUX_MSGTYPE_REQUEST:
count = flux_msg_get_route_count (msg);
count = flux_msg_route_count (msg);
/* Requests originated by the broker module will have a route
* count of 1. Ensure that, when the module is unloaded, a
* disconnect message is sent to all services used by broker module.
Expand Down Expand Up @@ -1693,7 +1693,7 @@ static int broker_response_sendmsg (broker_ctx_t *ctx, const flux_msg_t *msg)
int rc;
const char *uuid;

if (!(uuid = flux_msg_get_route_last (msg)))
if (!(uuid = flux_msg_route_last (msg)))
rc = flux_requeue (ctx->h, msg, FLUX_RQ_TAIL);
else if (overlay_uuid_is_parent (ctx->overlay, uuid))
rc = overlay_sendmsg (ctx->overlay, msg, OVERLAY_UPSTREAM);
Expand Down
4 changes: 2 additions & 2 deletions src/broker/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static int cmp_sender (const flux_msg_t *msg, const char *uuid)
{
const char *sender;

if (!(sender = flux_msg_get_route_first (msg)))
if (!(sender = flux_msg_route_first (msg)))
return 0;
if (!sender || strcmp (sender, uuid) != 0)
return 0;
Expand All @@ -614,7 +614,7 @@ static void disconnect_request_cb (flux_t *h, flux_msg_handler_t *mh,
zlist_t *tmp = NULL;

assert (logbuf->magic == LOGBUF_MAGIC);
if (!(sender = flux_msg_get_route_first (msg)))
if (!(sender = flux_msg_route_first (msg)))
goto done;
msgp = zlist_first (logbuf->followers);
while (msgp) {
Expand Down
10 changes: 5 additions & 5 deletions src/broker/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ flux_msg_t *module_recvmsg (module_t *p)
goto error;
switch (type) {
case FLUX_MSGTYPE_RESPONSE:
if (flux_msg_delete_route_last (msg) < 0)
if (flux_msg_route_delete_last (msg) < 0)
goto error;
break;
case FLUX_MSGTYPE_REQUEST:
case FLUX_MSGTYPE_EVENT:
if (flux_msg_push_route (msg, p->uuid_str) < 0)
if (flux_msg_route_push (msg, p->uuid_str) < 0)
goto error;
break;
default:
Expand Down Expand Up @@ -312,7 +312,7 @@ int module_sendmsg (module_t *p, const flux_msg_t *msg)
case FLUX_MSGTYPE_REQUEST: { /* simulate DEALER socket */
if (!(cpy = flux_msg_copy (msg, true)))
goto done;
if (flux_msg_push_route (cpy, p->modhash->uuid_str) < 0)
if (flux_msg_route_push (cpy, p->modhash->uuid_str) < 0)
goto done;
if (flux_msg_sendzsock (p->sock, cpy) < 0)
goto done;
Expand All @@ -321,7 +321,7 @@ int module_sendmsg (module_t *p, const flux_msg_t *msg)
case FLUX_MSGTYPE_RESPONSE: { /* simulate ROUTER socket */
if (!(cpy = flux_msg_copy (msg, true)))
goto done;
if (flux_msg_delete_route_last (cpy) < 0)
if (flux_msg_route_delete_last (cpy) < 0)
goto done;
if (flux_msg_sendzsock (p->sock, cpy) < 0)
goto done;
Expand All @@ -345,7 +345,7 @@ int module_response_sendmsg (modhash_t *mh, const flux_msg_t *msg)

if (!msg)
return 0;
if (!(uuid = flux_msg_get_route_last (msg))) {
if (!(uuid = flux_msg_route_last (msg))) {
errno = EPROTO;
return -1;
}
Expand Down
22 changes: 11 additions & 11 deletions src/broker/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static int overlay_keepalive_parent (struct overlay *ov, int status)
if (ov->parent.zsock) {
if (!(msg = flux_keepalive_encode (0, status)))
return -1;
flux_msg_enable_route (msg);
flux_msg_route_enable (msg);
if (overlay_sendmsg_parent (ov, msg) < 0)
goto error;
flux_msg_destroy (msg);
Expand Down Expand Up @@ -405,9 +405,9 @@ int overlay_sendmsg (struct overlay *ov,
}
if (!(cpy = flux_msg_copy (msg, true)))
goto error;
if (flux_msg_push_route (cpy, ov->uuid) < 0)
if (flux_msg_route_push (cpy, ov->uuid) < 0)
goto error;
if (flux_msg_push_route (cpy, child->uuid) < 0)
if (flux_msg_route_push (cpy, child->uuid) < 0)
goto error;
msg = cpy;
where = OVERLAY_DOWNSTREAM;
Expand All @@ -430,7 +430,7 @@ int overlay_sendmsg (struct overlay *ov,
*/
if (where == OVERLAY_ANY) {
if (ov->rank > 0
&& (uuid = flux_msg_get_route_last (msg)) != NULL
&& (uuid = flux_msg_route_last (msg)) != NULL
&& !strcmp (uuid, ov->parent.uuid))
where = OVERLAY_UPSTREAM;
else
Expand All @@ -453,7 +453,7 @@ int overlay_sendmsg (struct overlay *ov,
if (!(flags & FLUX_MSGFLAG_ROUTE)) {
if (!(cpy = flux_msg_copy (msg, true)))
goto error;
flux_msg_enable_route (cpy);
flux_msg_route_enable (cpy);
msg = cpy;
}
if (overlay_sendmsg_parent (ov, msg) < 0)
Expand Down Expand Up @@ -511,8 +511,8 @@ static int overlay_mcast_child_one (struct overlay *ov,

if (!(cpy = flux_msg_copy (msg, true)))
return -1;
flux_msg_enable_route (cpy);
if (flux_msg_push_route (cpy, child->uuid) < 0)
flux_msg_route_enable (cpy);
if (flux_msg_route_push (cpy, child->uuid) < 0)
goto done;
if (overlay_sendmsg_child (ov, cpy) < 0)
goto done;
Expand Down Expand Up @@ -568,7 +568,7 @@ static void child_cb (flux_reactor_t *r, flux_watcher_t *w,
if (!(msg = flux_msg_recvzsock (ov->bind_zsock)))
return;
if (flux_msg_get_type (msg, &type) < 0
|| !(sender = flux_msg_get_route_last (msg)))
|| !(sender = flux_msg_route_last (msg)))
goto drop;
if (!(child = child_lookup (ov, sender)) || !child->connected) {
if (type == FLUX_MSGTYPE_REQUEST
Expand Down Expand Up @@ -597,8 +597,8 @@ static void child_cb (flux_reactor_t *r, flux_watcher_t *w,
* were a request, but the effect we want for responses is to have
* a route popped off at each router hop.
*/
(void)flux_msg_delete_route_last (msg); // child id from ROUTER
(void)flux_msg_delete_route_last (msg); // my id
(void)flux_msg_route_delete_last (msg); // child id from ROUTER
(void)flux_msg_route_delete_last (msg); // my id
break;
case FLUX_MSGTYPE_EVENT:
break;
Expand Down Expand Up @@ -640,7 +640,7 @@ static void parent_cb (flux_reactor_t *r, flux_watcher_t *w,
goto handled;
}
if (type == FLUX_MSGTYPE_EVENT)
flux_msg_disable_route (msg);
flux_msg_route_disable (msg);
ov->recv_cb (msg, OVERLAY_UPSTREAM, ov->recv_arg);
handled:
flux_msg_destroy (msg);
Expand Down
4 changes: 2 additions & 2 deletions src/broker/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void ping_request_cb (flux_t *h, flux_msg_handler_t *mh,
* That identity is passed in to ping_initialize() as the uuid.
* Tack it onto the route string.
*/
if (!(route_str = flux_msg_get_route_string (msg)))
if (!(route_str = flux_msg_route_string (msg)))
goto error;
new_size = strlen (route_str) + strlen (p->uuid) + 2;
if (!(new_str = realloc (route_str, new_size)))
Expand Down Expand Up @@ -120,7 +120,7 @@ int ping_initialize (flux_t *h, const char *service, const char *uuid)
goto error;
/* The uuid is tacked onto the route string constructed for
* ping responses. Truncate the uuid to 8 chars to match policy
* of flux_msg_get_route_string().
* of flux_msg_route_string().
*/
if (!(p->uuid = strdup (uuid)))
goto error;
Expand Down
2 changes: 1 addition & 1 deletion src/broker/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int publisher_send (struct publisher *pub, const flux_msg_t *msg)

if (!(cpy = flux_msg_copy (msg, true)))
return -1;
flux_msg_disable_route (cpy);
flux_msg_route_disable (cpy);
if (flux_msg_set_seq (cpy, ++pub->seq) < 0)
goto error_restore_seq;
send_event (pub, cpy);
Expand Down
16 changes: 8 additions & 8 deletions src/broker/test/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void trio (flux_t *h)
"%s: request was received by overlay", ctx[0]->name);
ok (flux_msg_get_topic (rmsg, &topic) == 0 && !strcmp (topic, "meep"),
"%s: received message has expected topic", ctx[0]->name);
ok ((sender = flux_msg_get_route_first (rmsg)) != NULL
ok ((sender = flux_msg_route_first (rmsg)) != NULL
&& !strcmp (sender, ctx[1]->uuid),
"%s: received message sender is rank 1", ctx[0]->name);

Expand All @@ -330,16 +330,16 @@ void trio (flux_t *h)
"%s: request was received by overlay", ctx[1]->name);
ok (flux_msg_get_topic (rmsg, &topic) == 0 && !strcmp (topic, "errr"),
"%s: request has expected topic", ctx[1]->name);
ok ((sender = flux_msg_get_route_first (rmsg)) != NULL
ok ((sender = flux_msg_route_first (rmsg)) != NULL
&& !strcmp (sender, ctx[0]->uuid),
"%s: request sender is rank 0", ctx[1]->name);

/* Response 1->0
*/
if (!(msg = flux_response_encode ("m000", NULL)))
BAIL_OUT ("flux_response_encode failed");
if (flux_msg_push_route (msg, ctx[0]->uuid) < 0)
BAIL_OUT ("flux_msg_push_route failed");
if (flux_msg_route_push (msg, ctx[0]->uuid) < 0)
BAIL_OUT ("flux_msg_route_push failed");
ok (overlay_sendmsg (ctx[1]->ov, msg, OVERLAY_ANY) == 0,
"%s: overlay_sendmsg response where=ANY works", ctx[1]->name);
flux_msg_decref (msg);
Expand All @@ -349,7 +349,7 @@ void trio (flux_t *h)
"%s: response was received by overlay", ctx[0]->name);
ok (flux_msg_get_topic (rmsg, &topic) == 0 && !strcmp (topic, "m000"),
"%s: received message has expected topic", ctx[0]->name);
ok (flux_msg_get_route_count (rmsg) == 0,
ok (flux_msg_route_count (rmsg) == 0,
"%s: received message has no routes", ctx[0]->name);

/* Event 1->0
Expand All @@ -371,8 +371,8 @@ void trio (flux_t *h)
*/
if (!(msg = flux_response_encode ("moop", NULL)))
BAIL_OUT ("flux_response_encode failed");
if (flux_msg_push_route (msg, ctx[1]->uuid) < 0)
BAIL_OUT ("flux_msg_push_route failed");
if (flux_msg_route_push (msg, ctx[1]->uuid) < 0)
BAIL_OUT ("flux_msg_route_push failed");
ok (overlay_sendmsg (ctx[0]->ov, msg, OVERLAY_ANY) == 0,
"%s: overlay_sendmsg response where=ANY works", ctx[0]->name);
flux_msg_decref (msg);
Expand All @@ -382,7 +382,7 @@ void trio (flux_t *h)
"%s: response was received by overlay", ctx[1]->name);
ok (flux_msg_get_topic (rmsg, &topic) == 0 && !strcmp (topic, "moop"),
"%s: response has expected topic", ctx[1]->name);
ok (flux_msg_get_route_count (rmsg) == 0,
ok (flux_msg_route_count (rmsg) == 0,
"%s: response has no routes", ctx[1]->name);

/* Event 0->1
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/flux-start.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ void disconnect_cb (flux_t *h,
{
const char *uuid;

if (!(uuid = flux_msg_get_route_first (msg)))
if (!(uuid = flux_msg_route_first (msg)))
return;
if (ctx.verbose >= 1)
log_msg ("disconnect from %.5s", uuid);
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/disconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool flux_disconnect_match (const flux_msg_t *msg1, const flux_msg_t *msg2)
struct flux_msg_cred cred;
uint32_t userid;

if (!flux_msg_match_route_first (msg1, msg2))
if (!flux_msg_route_match_first (msg1, msg2))
return false;

if (flux_msg_get_cred (msg1, &cred) < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static flux_msg_t *flux_event_create (const char *topic)
goto error;
if (flux_msg_set_topic (msg, topic) < 0)
goto error;
flux_msg_enable_route (msg);
flux_msg_route_enable (msg);
return msg;
error:
flux_msg_destroy (msg);
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ flux_msg_t *flux_recv (flux_t *h, struct flux_match match, int flags)
cali_begin_string (h->prof.msg_match_glob,
match.topic_glob ? match.topic_glob : "NONE");
const char *sender;
sender = flux_msg_get_route_first (msg);
sender = flux_msg_route_first (msg);
if (sender)
cali_begin_string (h->prof.msg_sender, sender);
profiling_msg_snapshot (h, msg, flags, "recv");
Expand Down

0 comments on commit 469e720

Please sign in to comment.