Skip to content

Commit

Permalink
examples: disconnect signals upon driver detach
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed Oct 14, 2023
1 parent 80eb96a commit f4f13fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,22 @@ _attach(LogDriverPlugin *s, LogDriver *driver)
msg_debug("HttpTestSlotsPlugin::attach()",
evt_tag_printf("SignalSlotConnector", "%p", ssc));

/* DISCONNECT: the whole SignalSlotConnector is destroyed when the owner LogDriver is freed up, so DISCONNECT is not required */
CONNECT(ssc, signal_http_header_request, _slot_append_test_headers, s);

return TRUE;
}

static void
_detach(LogDriverPlugin *s, LogDriver *driver)
{
SignalSlotConnector *ssc = driver->super.signal_slot_connector;

msg_debug("HttpTestSlotsPlugin::detach()",
evt_tag_printf("SignalSlotConnector", "%p", ssc));

DISCONNECT(ssc, signal_http_header_request, _slot_append_test_headers, s);
}

static void
_free(LogDriverPlugin *s)
{
Expand All @@ -76,6 +86,7 @@ http_test_slots_plugin_new(void)
log_driver_plugin_init_instance(&self->super, HTTP_TEST_SLOTS_PLUGIN);

self->super.attach = _attach;
self->super.detach = _detach;
self->super.free_fn = _free;

return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,22 @@ _attach(LogDriverPlugin *s, LogDriver *driver)
msg_debug("TlsTestValidationPlugin::attach()",
evt_tag_printf("SignalSlotConnector", "%p", ssc));

/* DISCONNECT: the whole SignalSlotConnector is destroyed when the owner LogDriver is freed up, so DISCONNECT is not required */
CONNECT(ssc, signal_afsocket_tls_certificate_validation, _slot_append_test_identity, s);

return TRUE;
}

static void
_detach(LogDriverPlugin *s, LogDriver *driver)
{
SignalSlotConnector *ssc = driver->super.signal_slot_connector;

msg_debug("TlsTestValidationPlugin::detach()",
evt_tag_printf("SignalSlotConnector", "%p", ssc));

DISCONNECT(ssc, signal_afsocket_tls_certificate_validation, _slot_append_test_identity, s);
}

static void
_free(LogDriverPlugin *s)
{
Expand All @@ -80,6 +90,7 @@ tls_test_validation_plugin_new(void)
log_driver_plugin_init_instance(&self->super, TLS_TEST_VALIDATION_PLUGIN);

self->super.attach = _attach;
self->super.detach = _detach;
self->super.free_fn = _free;

return self;
Expand Down

0 comments on commit f4f13fb

Please sign in to comment.