From 9f5addd987861d0a3a1144d576221a7f93af0970 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 25 Feb 2015 22:21:32 +0530 Subject: features/changelog: Make use of IPC fop Translators which wish to send event notifications can send "down" an IPC FOP with op_type as GF_IPC_TARGET_CHANGELOG and xdata carrying event structures (changelog_event_t). Change-Id: I0e5f8c9170161c186f0e58d07105813e34e18786 BUG: 1170075 Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.org/9775 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/features/changelog/src/changelog.c | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'xlators/features/changelog') diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index e7d8522ae8c..bb9c51a2a0b 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -1712,6 +1712,51 @@ changelog_open (call_frame_t *frame, xlator_t *this, /* }}} */ +/* {{{ */ + + +/* }}} */ + +int32_t +_changelog_generic_dispatcher (dict_t *dict, + char *key, data_t *value, void *data) +{ + xlator_t *this = NULL; + changelog_priv_t *priv = NULL; + + this = data; + priv = this->private; + + changelog_dispatch_event (this, priv, (changelog_event_t *)value->data); + return 0; +} + +/** + * changelog ipc dispatches events, pointers of which are passed in + * @xdata. Dispatching is orderless (whatever order dict_foreach() + * traverses the dictionary). + */ +int32_t +changelog_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) +{ + if (op != GF_IPC_TARGET_CHANGELOG) + goto wind; + + /* it's for us, do the job */ + if (xdata) + (void) dict_foreach (xdata, + _changelog_generic_dispatcher, this); + + STACK_UNWIND_STRICT (ipc, frame, 0, 0, NULL); + return 0; + + wind: + STACK_WIND (frame, default_ipc_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->ipc, op, xdata); + return 0; +} + + /* {{{ */ int32_t @@ -2621,6 +2666,7 @@ struct xlator_fops fops = { .fsetxattr = changelog_fsetxattr, .removexattr = changelog_removexattr, .fremovexattr = changelog_fremovexattr, + .ipc = changelog_ipc, }; struct xlator_cbks cbks = { -- cgit