[GTK] Fix webkit2 unit tests in debug builds
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 17:56:10 +0000 (17:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 17:56:10 +0000 (17:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69006

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2011-09-28
Reviewed by Martin Robinson.

We are currently using the WorQueue name as thread name which in
this moment can be com.apple.WebKit.ProcessLauncher or
com.apple.CoreIPC.ReceiveQueue. Both names are longer than 31
characters which is the limit of Visual Studio for thread
names. When log is enabled createThread() will assert instead of
truncate the name, so we need to make sure we don't use a name
longer than 31 characters.

* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::platformInitialize):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96237 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp

index 276b153..ecb67b4 100644 (file)
@@ -1,5 +1,23 @@
 2011-09-28  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] Fix webkit2 unit tests in debug builds
+        https://bugs.webkit.org/show_bug.cgi?id=69006
+
+        Reviewed by Martin Robinson.
+
+        We are currently using the WorQueue name as thread name which in
+        this moment can be com.apple.WebKit.ProcessLauncher or
+        com.apple.CoreIPC.ReceiveQueue. Both names are longer than 31
+        characters which is the limit of Visual Studio for thread
+        names. When log is enabled createThread() will assert instead of
+        truncate the name, so we need to make sure we don't use a name
+        longer than 31 characters.
+
+        * Platform/gtk/WorkQueueGtk.cpp:
+        (WorkQueue::platformInitialize):
+
+2011-09-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         [GTK] Loader client implementation for WebKit2 GTK+ API
         https://bugs.webkit.org/show_bug.cgi?id=68085
 
index 4f7f0a1..8d5d81c 100644 (file)
@@ -99,13 +99,29 @@ public:
 };
 
 // WorkQueue
+static const size_t kVisualStudioThreadNameLimit = 31;
+
 void WorkQueue::platformInitialize(const char* name)
 {
     m_eventContext = g_main_context_new();
     ASSERT(m_eventContext);
     m_eventLoop = g_main_loop_new(m_eventContext, FALSE);
     ASSERT(m_eventLoop);
-    m_workQueueThread = createThread(reinterpret_cast<WTF::ThreadFunction>(&WorkQueue::startWorkQueueThread), this, name);
+
+    // This name can be com.apple.WebKit.ProcessLauncher or com.apple.CoreIPC.ReceiveQueue.
+    // We are using those names for the thread name, but both are longer than 31 characters,
+    // which is the limit of Visual Studio for thread names.
+    // When log is enabled createThread() will assert instead of truncate the name, so we need
+    // to make sure we don't use a name longer than 31 characters.
+    const char* threadName = g_strrstr(name, ".");
+    if (threadName)
+        threadName++;
+    else
+        threadName = name;
+    if (strlen(threadName) > kVisualStudioThreadNameLimit)
+        threadName += strlen(threadName) - kVisualStudioThreadNameLimit;
+
+    m_workQueueThread = createThread(reinterpret_cast<WTF::ThreadFunction>(&WorkQueue::startWorkQueueThread), this, threadName);
 }
 
 void WorkQueue::platformInvalidate()