<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><blockquote class=""><div class="">On 19 Oct 2017, at 12:32, Frediano Ziglio <<a href="mailto:fziglio@redhat.com" class="" target="_blank">fziglio@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="" class=""><blockquote style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="">From: Christophe de Dinechin <<a href="mailto:dinechin@redhat.com" class="" target="_blank">dinechin@redhat.com</a>><br class=""><br class="">This is useful for some instrumentation, e.g. the leaks tracer,<br class="">that perform some of their operations within gst_deinit.<br class=""><br class="">Without this patch, if you run spicy with<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>GST_DEBUG="GST_TRACER:7" GST_TRACERS="leaks" spicy ...<br class="">the leak tracer does not run at exit, because it runs in gst_deinit.<br class=""><br class="">Signed-off-by: Christophe de Dinechin <<a href="mailto:dinechin@redhat.com" class="" target="_blank">dinechin@redhat.com</a>><br class="">---<br class="">spice-common | 2 +-<br class="">src/channel-display-gst.c | 1 +<br class="">2 files changed, 2 insertions(+), 1 deletion(-)<br class=""><br class="">diff --git a/spice-common b/spice-common<br class="">index 429ad96..ba11de3 160000<br class="">--- a/spice-common<br class="">+++ b/spice-common<br class="">@@ -1 +1 @@<br class="">-Subproject commit 429ad965371ceaaf60b81ccbed7da660ef9e0a94<br class="">+Subproject commit ba11de3f3fd58d1b1a99bb62dd9e409e9961a78e<br class="">diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c<br class="">index f978602..c9ab9bf 100644<br class="">--- a/src/channel-display-gst.c<br class="">+++ b/src/channel-display-gst.c<br class="">@@ -578,6 +578,7 @@ static gboolean gstvideo_init(void)<br class=""> GError *err = NULL;<br class=""> if (gst_init_check(NULL, NULL, &err)) {<br class=""> success = 1;<br class="">+ atexit(gst_deinit);<br class=""> } else {<br class=""> spice_warning("Disabling GStreamer video support: %s",<br class=""> err->message);<br class=""> g_clear_error(&err);<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Calling atexit from a library is a bad idea.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>Could you elaborate?</div><div><br class=""></div><div>I do not really agree with this statement. I’d actually go as far as saying</div><div>that libraries are the reason atexit exists to start with.</div><div>Apparently, I’m not alone, see first three responses in</div><div><a href="https://stackoverflow.com/questions/25115612/whats-the-scenario-to-use-atexit-function" class="" target="_blank">https://stackoverflow.com/questions/25115612/whats-the-scenario-to-use-atexit-function</a><br data-mce-bogus="1"></div><div>that all mention libraries.</div><div><br class=""></div><div><br class=""></div><div>Christophe</div></div></blockquote><div>Shared libraries in theory can be unloaded before the atexit function is called for instance.<br></div><div><br></div><div>Calling gst_deinit from a library is a bad idea because other part of the program could use<br></div><div>gstreamer too and call other gstreamer functions. Even after your atexit function!<br></div><div><br></div><div>The gcc way to catch shared library unload is to use the destructor attribute which in<br></div><div>Unix usually chain the .deinit/deinit function. Also has the advantage of not using space<br></div><div>(atexit function calls are usually limited as in many systems the buffer used to register<br></div><div>them is static).<br></div><div><br></div><div>Frediano<br></div><div><br></div></div></body></html>