Hello, Karel!

I've tried to build MICO library linked in with pthreads static library, but it was unsuccessfull. The problem was with initialisation which took place in pthread.dll (DllMain), but missed in static MICO.

So, I've prepared patch, which correctly init w32 pthreads static lib.
The problem was with the following functions:
pthread_win32_process_attach_np()
pthread_win32_process_detach_np()
pthread_win32_thread_attach_np()
pthread_win32_thread_detach_np()

Patch is against released MICO 2.3.13.

All of the best,
Nikolay Logvinov.
=== modified file 'include/mico/os-thread/pthreads.h'
--- mico2313/include/mico/os-thread/pthreads.h  2011-03-01 16:06:03 +0000
+++ micolib/include/mico/os-thread/pthreads.h   2011-03-15 11:31:54 +0000
@@ -32,6 +32,7 @@
 #define __OS_THREAD_PTHREADS_H__
 
 void _init ();
+void _cleanup ();
 
 //
 // Mutex
@@ -842,6 +843,9 @@
 #endif // MTDEBUG
             return ThreadFailure;
         }
+#ifdef PTW32_STATIC_LIB
+        pthread_win32_thread_attach_np();
+#endif
        if (_detached == Detached)
            pthread_detach (_id);
        return NoError;

=== modified file 'orb/orb.cc'
--- mico2313/orb/orb.cc 2011-03-01 16:06:03 +0000
+++ micolib/orb/orb.cc  2011-03-15 11:31:54 +0000
@@ -1700,6 +1700,7 @@
            }
            _is_shutdown = 2;
 #ifdef HAVE_THREADS
+            MICOMT::_cleanup();
        }
 #endif // HAVE_THREADS
     }

=== modified file 'orb/os-thread/pthreads.cc'
--- mico2313/orb/os-thread/pthreads.cc  2011-03-01 16:06:03 +0000
+++ micolib/orb/os-thread/pthreads.cc   2011-03-15 11:31:54 +0000
@@ -94,6 +94,34 @@
        __mtdebug_unlock();
     }
 #endif // MTDEBUG
+#ifdef PTW32_STATIC_LIB
+    pthread_win32_process_attach_np();
+#endif
+}
+
+
+//
+// No matter what the actual thread implementation is, _cleanup ()
+// takes care of cleaning up before exiting your application
+//
+/*!
+ * \ingroup micomt
+ *
+ * This method will perform cleaning procedure.
+ */
+void MICOMT::_cleanup ()
+{
+#ifdef MTDEBUG
+    if (MICO::Logger::IsLogged(MICO::Logger::Thread)) {
+       __mtdebug_lock();
+       MICO::Logger::Stream (MICO::Logger::Thread)
+           << "MICOMT::_cleanup()" << endl;
+       __mtdebug_unlock();
+    }
+#endif // MTDEBUG
+#ifdef PTW32_STATIC_LIB
+    pthread_win32_process_detach_np();
+#endif
 }
 
 
@@ -500,6 +528,9 @@
        __mtdebug_unlock();
     }
 #endif // MTDEBUG
+#ifdef PTW32_STATIC_LIB
+    pthread_win32_thread_detach_np();
+#endif
 }
 
 //

=== modified file 'orb/os-thread/pththreads.cc'
--- mico2313/orb/os-thread/pththreads.cc        2011-03-01 16:06:03 +0000
+++ micolib/orb/os-thread/pththreads.cc 2011-03-15 11:31:54 +0000
@@ -69,6 +69,20 @@
 }
 
 //
+// No matter what the actual thread implementation is, _cleanup ()
+// takes care of cleaning up before exiting your application
+//
+void MICOMT::_cleanup ()
+{
+  if (MICO::Logger::IsLogged(MICO::Logger::Thread)) {
+    __mtdebug_lock();
+    MICO::Logger::Stream (MICO::Logger::Thread)
+      << "MICOMT::_cleanup()" << endl;
+    __mtdebug_unlock();
+  }
+}
+
+//
 // Thread::ThreadWrapper is a static member function that
 // pthread_create(...) (or the like) can call as its "thread start routine".
 // Any object whose methods are to be invoked as a thread, must derive from

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Mico-devel mailing list
Mico-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mico-devel

Reply via email to