diff mbox series

[03/24] kernel-shark: Restore the counting of event handlers

Message ID 20210201172358.175407-4-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series Complete the KernelShark v2 transformation | expand

Commit Message

Yordan Karadzhov Feb. 1, 2021, 5:23 p.m. UTC
The number of the event handlers, successfully registered by the
plugins is supposed to be counted and returned by the functions
kshark_handle_dpi() and kshark_handle_all_dpis(). Although this is
not used by the GUI, we want the API to support this feature. In
this patch we fix a regression that was introduced during the
transformation of the API for KernelShark v2.0.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/libkshark-plugin.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/src/libkshark-plugin.c b/src/libkshark-plugin.c
index 74a5862..b85d0e9 100644
--- a/src/libkshark-plugin.c
+++ b/src/libkshark-plugin.c
@@ -457,7 +457,6 @@  kshark_register_input(struct kshark_context *kshark_ctx,
 	input->interface = plugin;
 	input->next = kshark_ctx->inputs;
 	kshark_ctx->inputs = input;
-
 	return input;
 
  conflict:
@@ -635,7 +634,7 @@  void kshark_unregister_plugin_from_stream(struct kshark_data_stream *stream,
 	}
 }
 
-static void plugin_init(struct kshark_data_stream *stream,
+static int plugin_init(struct kshark_data_stream *stream,
 			struct kshark_dpi_list *plugin)
 {
 	int handler_count = plugin->interface->init(stream);
@@ -660,13 +659,18 @@  static void plugin_init(struct kshark_data_stream *stream,
 		plugin->status |= KSHARK_PLUGIN_FAILED;
 		plugin->status &= ~KSHARK_PLUGIN_LOADED;
 	}
+
+	return handler_count;
 }
 
-static void plugin_close(struct kshark_data_stream *stream,
+static int plugin_close(struct kshark_data_stream *stream,
 			 struct kshark_dpi_list *plugin)
 {
-	plugin->interface->close(stream);
+	int handler_count = plugin->interface->close(stream);
+
 	plugin->status &= ~KSHARK_PLUGIN_LOADED;
+
+	return handler_count;
 }
 
 /**
@@ -689,24 +693,24 @@  int kshark_handle_dpi(struct kshark_data_stream *stream,
 	switch (task_id) {
 	case KSHARK_PLUGIN_INIT:
 		if (plugin->status & KSHARK_PLUGIN_ENABLED)
-			plugin_init(stream, plugin);
+			handler_count += plugin_init(stream, plugin);
 
 		break;
 
 	case KSHARK_PLUGIN_UPDATE:
 		if (plugin->status & KSHARK_PLUGIN_LOADED)
-			plugin_close(stream, plugin);
+			handler_count -= plugin_close(stream, plugin);
 
 		plugin->status &= ~KSHARK_PLUGIN_FAILED;
 
 		if (plugin->status & KSHARK_PLUGIN_ENABLED)
-			plugin_init(stream, plugin);
+			handler_count += plugin_init(stream, plugin);
 
 		break;
 
 	case KSHARK_PLUGIN_CLOSE:
 		if (plugin->status & KSHARK_PLUGIN_LOADED)
-			plugin_close(stream, plugin);
+			handler_count -= plugin_close(stream, plugin);
 
 		plugin->status &= ~KSHARK_PLUGIN_FAILED;
 		break;