diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b2337adb..c599e3d6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,9 @@ receive queue is predicated on hardware support when this flag is not used. ### notify -The function `spdk_notify_get_types()` was renamed to `spdk_notify_foreach_type()`. -And update type name of callback accordingly. +The function `spdk_notify_get_types()` and `spdk_notify_get_events()` were +renamed to `spdk_notify_foreach_type()` and `spdk_notify_foreach_event()`, +respectively. And update type name of callback accordingly. ## v19.04: diff --git a/doc/notify.md b/doc/notify.md index 6e3c2d521..11afb0228 100644 --- a/doc/notify.md +++ b/doc/notify.md @@ -23,7 +23,7 @@ about notification. # Get new events {#notify_listen} -A consumer can get events by calling function `spdk_notify_get_events`. +A consumer can get events by calling function `spdk_notify_foreach_event`. The caller should specify last received event and the maximum number of invocations. There might be multiple consumers of each event. The event bus is implemented as a circular buffer, so older events may be overwritten by newer ones. diff --git a/include/spdk/notify.h b/include/spdk/notify.h index 75bcc18ed..fa9746503 100644 --- a/include/spdk/notify.h +++ b/include/spdk/notify.h @@ -65,8 +65,8 @@ struct spdk_notify_event { * \param ctx User context * \return Non zero to break iteration. */ -typedef int (*spdk_notify_get_event_cb)(uint64_t idx, const struct spdk_notify_event *event, - void *ctx); +typedef int (*spdk_notify_foreach_event_cb)(uint64_t idx, const struct spdk_notify_event *event, + void *ctx); /** * Register \c type as new notification type. @@ -116,8 +116,8 @@ uint64_t spdk_notify_send(const char *type, const char *ctx); * \param ctx User context * \return Number of user callback invocations */ -uint64_t spdk_notify_get_events(uint64_t start_idx, uint64_t max, spdk_notify_get_event_cb cb_fn, - void *ctx); +uint64_t spdk_notify_foreach_event(uint64_t start_idx, uint64_t max, + spdk_notify_foreach_event_cb cb_fn, void *ctx); #ifdef __cplusplus } diff --git a/lib/event/rpc/notify_rpc.c b/lib/event/rpc/notify_rpc.c index 59da0bc31..0ecce7413 100644 --- a/lib/event/rpc/notify_rpc.c +++ b/lib/event/rpc/notify_rpc.c @@ -121,7 +121,7 @@ spdk_rpc_get_notifications(struct spdk_jsonrpc_request *request, } spdk_json_write_array_begin(req.w); - spdk_notify_get_events(req.id, req.max, get_notifications_cb, &req); + spdk_notify_foreach_event(req.id, req.max, get_notifications_cb, &req); spdk_json_write_array_end(req.w); spdk_jsonrpc_end_result(request, req.w); diff --git a/lib/notify/notify.c b/lib/notify/notify.c index 5798d925f..5381d70ee 100644 --- a/lib/notify/notify.c +++ b/lib/notify/notify.c @@ -128,7 +128,8 @@ spdk_notify_send(const char *type, const char *ctx) } uint64_t -spdk_notify_get_events(uint64_t start_idx, uint64_t max, spdk_notify_get_event_cb cb_fn, void *ctx) +spdk_notify_foreach_event(uint64_t start_idx, uint64_t max, + spdk_notify_foreach_event_cb cb_fn, void *ctx) { uint64_t i; diff --git a/test/unit/lib/notify/notify.c/notify_ut.c b/test/unit/lib/notify/notify.c/notify_ut.c index fd834d54b..d0f55f7d7 100644 --- a/test/unit/lib/notify/notify.c/notify_ut.c +++ b/test/unit/lib/notify/notify.c/notify_ut.c @@ -68,14 +68,14 @@ notify(void) spdk_notify_send("two", "two_context"); event = NULL; - cnt = spdk_notify_get_events(0, 1, event_cb, &event); + cnt = spdk_notify_foreach_event(0, 1, event_cb, &event); SPDK_CU_ASSERT_FATAL(cnt == 1); SPDK_CU_ASSERT_FATAL(event != NULL); CU_ASSERT(strcmp(event->type, "one") == 0); CU_ASSERT(strcmp(event->ctx, "one_context") == 0); event = NULL; - cnt = spdk_notify_get_events(1, 1, event_cb, &event); + cnt = spdk_notify_foreach_event(1, 1, event_cb, &event); SPDK_CU_ASSERT_FATAL(cnt == 1); SPDK_CU_ASSERT_FATAL(event != NULL); CU_ASSERT(strcmp(event->type, "two") == 0); @@ -83,7 +83,7 @@ notify(void) /* This event should not exist yet */ event = NULL; - cnt = spdk_notify_get_events(2, 1, event_cb, &event); + cnt = spdk_notify_foreach_event(2, 1, event_cb, &event); CU_ASSERT(cnt == 0); CU_ASSERT(event == NULL);