Merge mozilla-central into mozilla-inbound
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 07 Nov 2012 22:12:13 -0500
changeset 112663 1626c61ba11b788a7cf47520e8a00062aa46a612
parent 112662 b5c86318a3eea414659dd660afe06c373ad2d584 (current diff)
parent 112601 36e99ea02c052fd5b7278cd0c255bcaa37d6a899 (diff)
child 112664 de95b48ab6e14d4d8d91ef14dfc3098fe5a352be
push id23833
push useremorley@mozilla.com
push dateThu, 08 Nov 2012 10:20:57 +0000
treeherdermozilla-central@e0d7b394462b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-central into mozilla-inbound
--- a/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp
+++ b/other-licenses/nsis/Contrib/InetBgDL/InetBgDL.cpp
@@ -15,16 +15,17 @@
 #define STATUS_ERR_CANCELLED 499
 
 typedef DWORD FILESIZE_T; // Limit to 4GB for now...
 #define FILESIZE_UNKNOWN (-1)
 
 HINSTANCE g_hInst;
 NSIS::stack_t*g_pLocations = NULL;
 HANDLE g_hThread = NULL;
+HANDLE g_hGETStartedEvent = NULL;
 volatile UINT g_FilesTotal = 0;
 volatile UINT g_FilesCompleted = 0;
 volatile UINT g_Status = STATUS_INITIAL;
 volatile FILESIZE_T g_cbCurrXF;
 volatile FILESIZE_T g_cbCurrTot = FILESIZE_UNKNOWN;
 CRITICAL_SECTION g_CritLock;
 UINT g_N_CCH;
 PTSTR g_N_Vars;
@@ -66,30 +67,38 @@ NSIS::stack_t* StackPopItem(NSIS::stack_
     *ppST = pItem->next;
     return pItem;
   }
   return NULL;
 }
 
 void Reset()
 {
+  // The g_hGETStartedEvent event is used to make sure that the Get() call will
+  // acquire the lock before the Reset() call acquires the lock.
+  if (g_hGETStartedEvent) {
+    WaitForSingleObject(g_hGETStartedEvent, INFINITE);
+    CloseHandle(g_hGETStartedEvent);
+    g_hGETStartedEvent = NULL;
+  }
+
   TaskLock_AcquireExclusive();
 #ifndef ONELOCKTORULETHEMALL
   StatsLock_AcquireExclusive();
 #endif
   g_FilesTotal = 0; // This causes the Task thread to exit the transfer loop
   if (g_hThread)
   {
     if (WAIT_OBJECT_0 != WaitForSingleObject(g_hThread, 10 * 1000))
     {
       TerminateThread(g_hThread, ERROR_OPERATION_ABORTED);
     }
     CloseHandle(g_hThread);
+    g_hThread = NULL;
   }
-  g_hThread = NULL;
   g_FilesTotal = 0;
   g_FilesCompleted = 0;
   g_Status = STATUS_INITIAL;
 #ifndef ONELOCKTORULETHEMALL
   StatsLock_ReleaseExclusive();
 #endif
   for (NSIS::stack_t*pTmpTast,*pTask = g_pLocations; pTask ;)
   {
@@ -117,16 +126,23 @@ DWORD CALLBACK TaskThreadProc(LPVOID Thr
   NSIS::stack_t *pURL,*pFile;
   HINTERNET hInetSes = NULL;
   HANDLE hLocalFile;
   bool completedFile = false;
 startnexttask:
   hLocalFile = INVALID_HANDLE_VALUE;
   pFile = NULL;
   TaskLock_AcquireExclusive();
+  // Now that we've acquired the lock, we can set the event to indicate this.
+  // SetEvent will likely never fail, but if it does we should set it to NULL
+  // to avoid anyone waiting on it.
+  if (!SetEvent(g_hGETStartedEvent)) {
+    CloseHandle(g_hGETStartedEvent);
+    g_hGETStartedEvent = NULL;
+  }
   pURL = g_pLocations;
   if (pURL)
   {
     pFile = pURL->next;
     g_pLocations = pFile->next;
   }
 #ifndef ONELOCKTORULETHEMALL
   StatsLock_AcquireExclusive();
@@ -338,17 +354,21 @@ freeurlandexit:
     }
     else
     {
       g_pLocations = pURL;
     }
 
     if (!g_hThread)
     {
-      DWORD tid;tid;
+      DWORD tid;
+      if (g_hGETStartedEvent) {
+        CloseHandle(g_hGETStartedEvent);
+      }
+      g_hGETStartedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
       g_hThread = CreateThread(NULL, 0, TaskThreadProc, NULL, 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