[haiku-commits] r39171 - in haiku/trunk/src/servers: . index_server

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 28 Oct 2010 17:11:02 +0200 (CEST)

Author: czeidler
Date: 2010-10-28 17:11:02 +0200 (Thu, 28 Oct 2010)
New Revision: 39171
Changeset: http://dev.haiku-os.org/changeset/39171

Modified:
   haiku/trunk/src/servers/Jamfile
   haiku/trunk/src/servers/index_server/AnalyserDispatcher.h
   haiku/trunk/src/servers/index_server/CatchUpManager.cpp
   haiku/trunk/src/servers/index_server/VolumeWatcher.cpp
Log:
- The purpose of the SwapEntryRefVector is to exchange entry_ref's between the 
watcher thread and the worker thread. The idea is to use two list, the first 
list is filled by the watcher and the second is passed to the worker. When the 
worker finished both lists are swapped. This was totally broken, the list swap 
was not locked and SwapList always returned the wrong list.
- Use BAutolock class.
- Write the correct sync time in micro seconds.
- Fix the event dispatching in the worker thread.



Modified: haiku/trunk/src/servers/Jamfile
===================================================================
--- haiku/trunk/src/servers/Jamfile     2010-10-28 15:10:58 UTC (rev 39170)
+++ haiku/trunk/src/servers/Jamfile     2010-10-28 15:11:02 UTC (rev 39171)
@@ -4,6 +4,7 @@
 SubInclude HAIKU_TOP src servers bluetooth ;
 SubInclude HAIKU_TOP src servers cddb_daemon ;
 SubInclude HAIKU_TOP src servers debug ;
+SubInclude HAIKU_TOP src servers index_server ;
 SubInclude HAIKU_TOP src servers input ;
 SubInclude HAIKU_TOP src servers mail ;
 SubInclude HAIKU_TOP src servers media ;

Modified: haiku/trunk/src/servers/index_server/AnalyserDispatcher.h
===================================================================
--- haiku/trunk/src/servers/index_server/AnalyserDispatcher.h   2010-10-28 
15:10:58 UTC (rev 39170)
+++ haiku/trunk/src/servers/index_server/AnalyserDispatcher.h   2010-10-28 
15:11:02 UTC (rev 39171)
@@ -20,7 +20,7 @@
 
 class AnalyserDispatcher : public BLooper {
 public:
-                                                               
AnalyserDispatcher();
+                                                               
AnalyserDispatcher(const char* name);
                                                                
~AnalyserDispatcher();
 
                        void                            Stop();

Modified: haiku/trunk/src/servers/index_server/CatchUpManager.cpp
===================================================================
--- haiku/trunk/src/servers/index_server/CatchUpManager.cpp     2010-10-28 
15:10:58 UTC (rev 39170)
+++ haiku/trunk/src/servers/index_server/CatchUpManager.cpp     2010-10-28 
15:11:02 UTC (rev 39171)
@@ -25,6 +25,8 @@
 CatchUpAnalyser::CatchUpAnalyser(const BVolume& volume, time_t start,
        time_t end, BHandler* manager)
        :
+       AnalyserDispatcher("CatchUpAnalyser"),
+
        fVolume(volume),
        fStart(start),
        fEnd(end),
@@ -101,11 +103,14 @@
        for (uint32 i = 0; i < entryList.size(); i++) {
                if (Stopped())
                        return;
+               if (i % 100 == 0)
+                       printf("Catch up: %i/%i\n", 
(int)i,(int)entryList.size());
                AnalyseEntry(entryList[i]);
        }
        LastEntry();
 
-       _WriteSyncSatus(fEnd);
+       _WriteSyncSatus(fEnd * kSecond);
+       printf("Catched up.\n");
 
        BMessenger managerMessenger(fCatchUpManager);
        BMessage msg(kCatchUpDone);

Modified: haiku/trunk/src/servers/index_server/VolumeWatcher.cpp
===================================================================
--- haiku/trunk/src/servers/index_server/VolumeWatcher.cpp      2010-10-28 
15:10:58 UTC (rev 39170)
+++ haiku/trunk/src/servers/index_server/VolumeWatcher.cpp      2010-10-28 
15:11:02 UTC (rev 39171)
@@ -10,6 +10,7 @@
 
 #include <sys/stat.h>
 
+#include <Autolock.h>
 #include <Directory.h>
 #include <NodeMonitor.h>
 #include <Path.h>
@@ -73,9 +74,9 @@
 }
 
 
-AnalyserDispatcher::AnalyserDispatcher()
+AnalyserDispatcher::AnalyserDispatcher(const char* name)
        :
-       BLooper(NULL, B_LOW_PRIORITY),
+       BLooper(name, B_LOW_PRIORITY),
 
        fStopped(0)
 {
@@ -143,13 +144,11 @@
                return false;
 
        bool result;
-       Lock();
-       if (_FindAnalyser(analyser->Name())) {
-               Unlock();
+       BAutolock _(this);
+       if (_FindAnalyser(analyser->Name()))
                return false;
-       }
+
        result = fFileAnalyserList.AddItem(analyser);
-       Unlock();
        return result;
 }
 
@@ -157,15 +156,13 @@
 bool
 AnalyserDispatcher::RemoveAnalyser(const BString& name)
 {
-       Lock();
+       BAutolock _(this);
        FileAnalyser* analyser = _FindAnalyser(name);
        if (analyser) {
                fFileAnalyserList.RemoveItem(analyser);
                delete analyser;
-               Unlock();
                return true;
        }
-       Unlock();
        return false;
 }
 
@@ -216,6 +213,8 @@
 
 VolumeWorker::VolumeWorker(VolumeWatcher* watcher)
        :
+       AnalyserDispatcher("VolumeWorker"),
+
        fVolumeWatcher(watcher),
        fBusy(0)
 {
@@ -262,16 +261,16 @@
                AnalyseEntry(collection.createdList->at(i));
        collection.createdList->clear();
 
+       for (unsigned int i = 0; i < collection.deletedList->size() || 
Stopped();
+               i++)
+               DeleteEntry(collection.deletedList->at(i));
+       collection.deletedList->clear();
+
        for (unsigned int i = 0; i < collection.modifiedList->size() || 
Stopped();
                i++)
                AnalyseEntry(collection.modifiedList->at(i));
        collection.modifiedList->clear();
 
-       for (unsigned int i = 0; i < collection.createdList->size() || 
Stopped();
-               i++)
-               AnalyseEntry(collection.createdList->at(i));
-       collection.createdList->clear();
-
        for (unsigned int i = 0; i < collection.movedList->size() || Stopped();
                i++)
                MoveEntry(collection.movedFromList->at(i), 
collection.movedList->at(i));
@@ -372,7 +371,7 @@
        EntryRefVector* temp = fCurrentList;
        fCurrentList = fNextList;
        fNextList = temp;
-       return fCurrentList;
+       return temp;
 }
 
 
@@ -400,7 +399,6 @@
 
 VolumeWatcher::~VolumeWatcher()
 {
-printf("~VolumeWatcher()\n");
        Stop();
        thread_id threadId = fVolumeWorker->Thread();
        fVolumeWorker->PostMessage(B_QUIT_REQUESTED);
@@ -486,14 +484,12 @@
        if (!fVolumeWorker->AddAnalyser(analyser))
                return false;
 
-       Lock();
-       if (!fCatchUpManager.AddAnalyser(analyser)) {
-               Unlock();
+       BAutolock _(this);
+       if (!fCatchUpManager.AddAnalyser(analyser))
                return false;
-       }
+
        if (fWatching)
                fCatchUpManager.CatchUp();
-       Unlock();
 
        return true;
 }
@@ -505,9 +501,8 @@
        if (!fVolumeWorker->RemoveAnalyser(name))
                return false;
 
-       Lock();
+       BAutolock _(this);
        fCatchUpManager.RemoveAnalyser(name);
-       Unlock();
        return true;
 }
 
@@ -515,6 +510,7 @@
 void
 VolumeWatcher::GetSecureEntries(list_collection& collection)
 {
+       BAutolock _(this);
        collection.createdList = fCreatedList.SwapList();
        collection.deletedList = fDeleteList.SwapList();
        collection.modifiedList = fModifiedList.SwapList();


Other related posts:

  • » [haiku-commits] r39171 - in haiku/trunk/src/servers: . index_server - clemens . zeidler