Changeset: a7e73a3d8e2e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a7e73a3d8e2e
Modified Files:
        gdk/gdk_system.c
        gdk/gdk_utils.c
Branch: cmake-monetdblite
Log Message:

Mserver's main thread id may not be 1 in MonetDBLite.


diffs (49 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -160,6 +160,8 @@ GDKlockstatistics(int what)
 
 #endif /* LOCK_STATS */
 
+MT_Id mainthreadid = 0;
+
 #ifdef WIN32
 static struct winthread {
        struct winthread *next;
@@ -208,6 +210,7 @@ MT_thread_init(void)
                if (threadslot == TLS_OUT_OF_INDEXES)
                        return false;
                mainthread.tid = GetCurrentThreadId();
+               mainthreadid = (MT_Id) mainthread.tid;
                if (TlsSetValue(threadslot, &mainthread) == 0) {
                        TlsFree(threadslot);
                        threadslot = TLS_OUT_OF_INDEXES;
@@ -527,6 +530,7 @@ MT_thread_init(void)
                return false;
        }
        mainthread.tid = pthread_self();
+       mainthreadid = mainthread.tid;
        if ((ret = pthread_setspecific(threadkey, &mainthread)) != 0) {
                MT_fprintf(stderr,
                        "#MT_thread_init: setting specific value failed: %s\n",
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -755,6 +755,8 @@ GDKprepareExit(void)
        join_detached_threads();
 }
 
+extern MT_Id mainthreadid;
+
 void
 GDKreset(int status)
 {
@@ -780,7 +782,7 @@ GDKreset(int status)
                for (Thread t = GDKthreads; t < GDKthreads + THREADS; t++) {
                        MT_Id victim;
                        if ((victim = (MT_Id) ATOMIC_GET(&t->pid)) != 0) {
-                               if (victim != pid && victim > 1) { /* Not the 
main thread */
+                               if (victim != pid && victim != mainthreadid) { 
/* Not the main thread */
                                        int e;
 
                                        killed = true;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to