Hello!

We would like to contribute to VirtualBox under MIT license. We send our changes to fix bug described at https://www.virtualbox.org/ticket/13802 .

The idea is that we not only check waiting workers presence but also compare amount of waiting workers and amount of requests. So when amount of request is greater than amount of free workers (and situation not changed after short sleeping) we create new worker. In this case there will be always sufficient amount of workers.

We find amount of requests by iterating through whole list and it seems like it doesn't cause execution speed decreasing (due to not so big requests queue). But if there will be some problems with it we can correct code to count elements on every appending / removing operation (this way not so good because count variable must be changed in every append / remove / etc operation and every new operation in ipcList class).

Regards,
Alexander

--- old/ipcDConnectService.cpp	2015-01-30 17:17:38.000000000 +0300
+++ new/ipcDConnectService.cpp	2015-01-30 17:20:21.000000000 +0300
@@ -3553,7 +3553,7 @@
   PR_Sleep(PR_INTERVAL_NO_WAIT);
   mon.Enter();
   // examine the queue
-  if (!mPendingQ.IsEmpty() && !mWaitingWorkers)
+  if (mPendingQ.Count() > mWaitingWorkers)
   {
     // wait a little while to let the workers empty the queue.
     mon.Exit();
@@ -3564,7 +3564,7 @@
     }
     mon.Enter();
     // examine the queue again
-    if (!mPendingQ.IsEmpty() && !mWaitingWorkers)
+    if (mPendingQ.Count() > mWaitingWorkers)
     {
       // we need one more worker
       nsresult rv = CreateWorker();
--- old/ipcList.h	2015-01-30 17:17:38.000000000 +0300
+++ new/ipcList.h	2015-01-30 17:20:21.000000000 +0300
@@ -174,6 +174,19 @@
         mTail = NULL;
     }
 
+    // gets count of list elements
+    PRUint32 Count()
+    {
+        T *obj = mHead;
+        PRUint32 count = 0;
+        while (obj) {
+            count++;
+            obj = obj->mNext;
+        }
+
+        return count;
+    }
+
 protected:
     void AdvanceHead()
     {
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev

Reply via email to