Author: j16sdiz
Date: 2009-01-01 11:19:57 +0000 (Thu, 01 Jan 2009)
New Revision: 24858

Modified:
   trunk/plugins/XMLSpider/XMLSpider.java
   trunk/plugins/XMLSpider/db/PerstRoot.java
Log:
lock queued pages on startSomeRequests()

Modified: trunk/plugins/XMLSpider/XMLSpider.java
===================================================================
--- trunk/plugins/XMLSpider/XMLSpider.java      2009-01-01 11:19:44 UTC (rev 
24857)
+++ trunk/plugins/XMLSpider/XMLSpider.java      2009-01-01 11:19:57 UTC (rev 
24858)
@@ -147,9 +147,10 @@
                                if (running >= 
root.getConfig().getMaxParallelRequests())
                                        return;
 
-                               // perpare to start
+                               // Prepare to start
                                toStart = new 
ArrayList<ClientGetter>(root.getConfig().getMaxParallelRequests() - running);
-                               synchronized (root) {
+                               root.sharedLockPages(Status.QUEUED);
+                               try {
                                        Iterator<Page> it = 
root.getPages(Status.QUEUED);
 
                                        while (running + toStart.size() < 
root.getConfig().getMaxParallelRequests() && it.hasNext()) {
@@ -168,6 +169,8 @@
                                                        
page.setStatus(Status.FAILED);
                                                }
                                        }
+                               } finally {
+                                       root.unlockPages(Status.QUEUED);
                                }
                        }
                }

Modified: trunk/plugins/XMLSpider/db/PerstRoot.java
===================================================================
--- trunk/plugins/XMLSpider/db/PerstRoot.java   2009-01-01 11:19:44 UTC (rev 
24857)
+++ trunk/plugins/XMLSpider/db/PerstRoot.java   2009-01-01 11:19:57 UTC (rev 
24858)
@@ -136,6 +136,21 @@
                }
        }
 
+       public void exclusiveLock(Status status) {
+               FieldIndex<Page> index = getPageIndex(status);
+               index.exclusiveLock();
+       }
+
+       public void sharedLockPages(Status status) {
+               FieldIndex<Page> index = getPageIndex(status);
+               index.sharedLock();
+       }
+
+       public void unlockPages(Status status) {
+               FieldIndex<Page> index = getPageIndex(status);
+               index.unlock();
+       }
+       
        public Iterator<Page> getPages(Status status) {
                FieldIndex<Page> index = getPageIndex(status);
                index.sharedLock();

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to