discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c043f55a436fecd0a4b54800cf3e4a520ef1b927

commit c043f55a436fecd0a4b54800cf3e4a520ef1b927
Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Jun 15 16:43:39 2018 -0400

    eina: prevent threads subcomponent from being shutdown while eina is active
    
    this basically breaks all thread usage if it happens, so ensure that the
    threads infrastructure stays active for as long as eina is active
    
    @fix
    
    Differential Revision: https://phab.enlightenment.org/D6303
---
 src/lib/eina/eina_main.c | 65 +++++++++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 28 deletions(-)

diff --git a/src/lib/eina/eina_main.c b/src/lib/eina/eina_main.c
index 3aa7e24e7a..b3790f14d7 100644
--- a/src/lib/eina/eina_main.c
+++ b/src/lib/eina/eina_main.c
@@ -225,6 +225,39 @@ _eina_shutdown_from_desc(const struct eina_desc_setup *itr)
    eina_log_shutdown();
 }
 
+static void
+_eina_threads_do_shutdown(void)
+{
+#ifdef EINA_HAVE_DEBUG_THREADS
+   const Eina_Lock *lk;
+
+   pthread_mutex_lock(&_eina_tracking_lock);
+   if (_eina_tracking)
+     {
+       if (((Eina_Lock*)_eina_tracking != (&_sysmon_lock)) || 
(_eina_tracking->next))
+         {
+            fprintf(stderr, "*************************\n");
+            fprintf(stderr, "* The IMPOSSIBLE HAPPEN *\n");
+            fprintf(stderr, "* LOCK STILL TAKEN :    *\n");
+            fprintf(stderr, "*************************\n");
+            EINA_INLIST_FOREACH(_eina_tracking, lk)
+              {
+                 fprintf(stderr, "=======\n");
+                 eina_lock_debug(lk);
+              }
+            fprintf(stderr, "*************************\n");
+            abort();
+         }
+     }
+   pthread_mutex_unlock(&_eina_tracking_lock);
+#endif
+
+   eina_share_common_threads_shutdown();
+   eina_log_threads_shutdown();
+
+   _eina_threads_activated = EINA_FALSE;
+}
+
 /**
  * @endcond
  */
@@ -332,6 +365,8 @@ eina_shutdown(void)
 
         _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
 
+        if (_eina_threads_activated && (!_eina_main_thread_count))
+          _eina_threads_do_shutdown();
 #ifdef EINA_HAVE_DEBUG_THREADS
        pthread_mutex_destroy(&_eina_tracking_lock);
 #endif
@@ -382,8 +417,6 @@ eina_threads_shutdown(void)
    int ret;
 
 #ifdef EINA_HAVE_DEBUG_THREADS
-   const Eina_Lock *lk;
-
    assert(pthread_equal(_eina_main_loop, pthread_self()));
    assert(_eina_main_thread_count > 0);
 #endif
@@ -392,32 +425,8 @@ eina_threads_shutdown(void)
    if(_eina_main_thread_count > 0)
      return ret;
 
-#ifdef EINA_HAVE_DEBUG_THREADS
-   pthread_mutex_lock(&_eina_tracking_lock);
-   if (_eina_tracking)
-     {
-        if (((Eina_Lock*)_eina_tracking != (&_sysmon_lock)) || 
(_eina_tracking->next))
-          {
-             fprintf(stderr, "*************************\n");
-             fprintf(stderr, "* The IMPOSSIBLE HAPPEN *\n");
-             fprintf(stderr, "* LOCK STILL TAKEN :    *\n");
-             fprintf(stderr, "*************************\n");
-             EINA_INLIST_FOREACH(_eina_tracking, lk)
-               {
-                  fprintf(stderr, "=======\n");
-                  eina_lock_debug(lk);
-               }
-             fprintf(stderr, "*************************\n");
-             abort();
-          }
-     }
-   pthread_mutex_unlock(&_eina_tracking_lock);
-#endif
-
-   eina_share_common_threads_shutdown();
-   eina_log_threads_shutdown();
-
-   _eina_threads_activated = EINA_FALSE;
+   if (!_eina_main_count)
+     _eina_threads_do_shutdown();
 
    return ret;
 #else

-- 


Reply via email to