bug 1373866 - consistently hold the pr_wp.ml lock while accessing pr_wp.opHead r=kaie
authorDavid Keeler <dkeeler@mozilla.com>
Wed, 21 Jun 2017 18:57:13 +0200
changeset 4738 37643d296da1fa9c34792d71f1c73cfec1a0a0df
parent 4735 b928b889222563c9b4a56fcffa30d5c4db8066c3
child 4739 7fc298409c446f7f913e227176fc0f3bb33a8772
push id256
push userkaie@kuix.de
push dateWed, 21 Jun 2017 16:57:13 +0000
reviewerskaie
bugs1373866
bug 1373866 - consistently hold the pr_wp.ml lock while accessing pr_wp.opHead r=kaie
pr/src/md/unix/uxproces.c
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -619,33 +619,33 @@ static void WaitPidDaemonThread(void *un
 	PR_Lock(pr_wp.ml);
 #endif
 	    
         do {
             rv = read(pr_wp.pipefd[0], buf, sizeof(buf));
         } while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));
 
 #ifdef _PR_SHARE_CLONES
-	PR_Unlock(pr_wp.ml);
 	while ((op = pr_wp.opHead) != NULL) {
+	    PR_Unlock(pr_wp.ml);
 	    op->process = ForkAndExec(op->path, op->argv,
 		    op->envp, op->attr);
 	    if (NULL == op->process) {
 		op->prerror = PR_GetError();
 		op->oserror = PR_GetOSError();
 	    }
 	    PR_Lock(pr_wp.ml);
 	    pr_wp.opHead = op->next;
 	    if (NULL == pr_wp.opHead) {
 		pr_wp.opTail = NULL;
 	    }
 	    op->done = PR_TRUE;
 	    PR_NotifyCondVar(op->doneCV);
-	    PR_Unlock(pr_wp.ml);
 	}
+	PR_Unlock(pr_wp.ml);
 #endif
 
 	while (1) {
 	    do {
 	        pid = waitpid((pid_t) -1, &status, WNOHANG);
 	    } while ((pid_t) -1 == pid && EINTR == errno);
 	    if (0 == pid) break;
 	    if ((pid_t) -1 == pid) {