History log of /haiku/headers/private/storage/PathMonitor.h
Revision Date Author Comments
# 04382d49 27-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: rewrite

This resolves all issues the test suite uncovered. It should also deal
with hard links correctly, though that hasn't been tested. Still
unsupported are:
* changes due to mounting/unmounting a volume,
* tracking of symlinks in the path components.


# cb4a05cf 24-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Missed B_WATCH_FOLDERS_ONLY occurrence


# 38afe232 23-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: pass BMessenger by reference


# 7b198d81 23-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

B_WATCH_FOLDERS_ONLY -> B_WATCH_DIRECTORIES_ONLY

Stick to the nomenclature generally used in the public API.


# 77ca66cd 20-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: make the node watching mechanism configurable

Add inner class BWatchingInterface and method SetWatchingInterface().
This abstracts the calls to watch_node() and stop_watching(), thus
making it possible to use the path monitor in Tracker.


# ad1875fd 20-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: use pthread_once for initialization


# afbd081a 11-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* TRACE macro no longer needs double parenthesis.
* The global BPathMonitor looper is now always used, no more optional looper
and no more BApplication looper usage. This way we know how the looper behaves
and PathHandler::Quit() can be synchronous. In the end, the bug I was
observing was not caused by the previous asynchronous node monitor stopping,
but this should be safer anyways. When BPathMonitor::StopWatching() returns,
you have really stopped watching and not some time later.
* Introduced "FileEntry" which is an entry_ref plus node id. This is now used
instead of the node_ref for the "watched files set". The whole point
is to really be able to add the "path" field to the B_PATH_MONITOR message.
Previously, the initial path that was passed to StartWatching() was added,
regardless if the message was for an entry somewhere down the hierarchy when
watching recursively. The downside of the new method is that it uses a lot
more RAM per entry. Another option would be to store the node id of the parent
directory and iterate the directory always when in need to construct the path.
* Watching a folder recursively now really adds all the existing subfolders
as well as all the files if not watching for folders only. The tests for the
old implementation only tested what happens when the watched folder was newly
created and then subfolders were created. Those where already added by the
code. Now it also adds the subfolders of folder that appear in a watched
folder.
TODO: Remove folders and files recursively when they dissappear. More testing
for B_ENTRY_MOVED. Optimizations are possible when some information is
retrieved twice. I am also planning to add a way for the BPathMonitor user to
filter the automatically watched files/folders in B_WATCH_RECURSIVELY mode.

I grepped the entire Haiku tree for usage of BPathMonitor. Only net_server
and Mail were using it, but both in a way that is not affected by these
changes. Anyways, TextSearch works more reliable now, even for entries in
subfolders.

Feedback very welcome! :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26936 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7c226f4 06-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* StartWatching() now takes an optional BLooper pointer. This looper will
then be used for receiving node monitoring messages.
* Reenabled using be_app as default BLooper if the API user does not provide
one. I think the problem that Stefano needed to work aroung in r23995 was
actually caused by the incorrect locking (an never unlocking) of the looper
before calling PathHandler::Quit().
->If I understand correctly, this code as supposed to work around the possible
situation that the looper holding those PathHandlers may have already quit,
leaving stale PathHandler pointers behind. But that case was not prevented
by the old code anyways, since one would have had to access freed memory to
even get the stale BLooper pointer. The real fix would be to store the
BLooper pointer with each PathHandler so that the possible gone-ness of
those loopers could be checked independent of accessing the PathHandler
pointer. (The whole problem is that PathHandler adds itself to the BLooper
and if the looper quits, it will free all its attached handlers.)
* Introduced a global fallback BLooper for the case that no BApplication is
running, which resolves a TODO.

All this is yet untested, but should have a good chance of working.
(Famous last words...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26843 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5bc41de 04-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* Use new header layout in PathMonitor.h
* Honor 80 char/line limit in PathMonitor.cpp


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26788 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d00539e3 07-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Revamped BPathMonitor API as suggested by Ingo - we could rename it to BNodeMonitor
and add wrappers for watch_node() as well, though.
* Implemented more or less all what is needed for the path monitoring to work.
* Added a test application: works fine under Haiku, but somewhat flaky under BeOS,
dunno why yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21066 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f30198a0 04-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Implemented PathMonitor class - untested, but compiles.
* The API is just a proposal at this time, please comment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21020 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 04382d496e445d90a3aab7c8752ee9cb59825035 27-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: rewrite

This resolves all issues the test suite uncovered. It should also deal
with hard links correctly, though that hasn't been tested. Still
unsupported are:
* changes due to mounting/unmounting a volume,
* tracking of symlinks in the path components.


# cb4a05cfdf59c3645e0e09e3cf154204e1a28c41 24-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Missed B_WATCH_FOLDERS_ONLY occurrence


# 38afe232de0aba455fb21897ac8a739dd5793e52 23-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: pass BMessenger by reference


# 7b198d812e45dfdaf08d5660fec27b3b4acf2a6f 23-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

B_WATCH_FOLDERS_ONLY -> B_WATCH_DIRECTORIES_ONLY

Stick to the nomenclature generally used in the public API.


# 77ca66cdb7b44669fc03e80e084234bee21bfd0e 20-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: make the node watching mechanism configurable

Add inner class BWatchingInterface and method SetWatchingInterface().
This abstracts the calls to watch_node() and stop_watching(), thus
making it possible to use the path monitor in Tracker.


# ad1875fd705fe89064bcc91788ab4a05d14bf59d 20-Jun-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

BPathMonitor: use pthread_once for initialization


# afbd081a6fe420971f135720f917541815b7ad0a 11-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* TRACE macro no longer needs double parenthesis.
* The global BPathMonitor looper is now always used, no more optional looper
and no more BApplication looper usage. This way we know how the looper behaves
and PathHandler::Quit() can be synchronous. In the end, the bug I was
observing was not caused by the previous asynchronous node monitor stopping,
but this should be safer anyways. When BPathMonitor::StopWatching() returns,
you have really stopped watching and not some time later.
* Introduced "FileEntry" which is an entry_ref plus node id. This is now used
instead of the node_ref for the "watched files set". The whole point
is to really be able to add the "path" field to the B_PATH_MONITOR message.
Previously, the initial path that was passed to StartWatching() was added,
regardless if the message was for an entry somewhere down the hierarchy when
watching recursively. The downside of the new method is that it uses a lot
more RAM per entry. Another option would be to store the node id of the parent
directory and iterate the directory always when in need to construct the path.
* Watching a folder recursively now really adds all the existing subfolders
as well as all the files if not watching for folders only. The tests for the
old implementation only tested what happens when the watched folder was newly
created and then subfolders were created. Those where already added by the
code. Now it also adds the subfolders of folder that appear in a watched
folder.
TODO: Remove folders and files recursively when they dissappear. More testing
for B_ENTRY_MOVED. Optimizations are possible when some information is
retrieved twice. I am also planning to add a way for the BPathMonitor user to
filter the automatically watched files/folders in B_WATCH_RECURSIVELY mode.

I grepped the entire Haiku tree for usage of BPathMonitor. Only net_server
and Mail were using it, but both in a way that is not affected by these
changes. Anyways, TextSearch works more reliable now, even for entries in
subfolders.

Feedback very welcome! :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26936 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7c226f46761738631518ef7051d9b1dfd2e15ed 06-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* StartWatching() now takes an optional BLooper pointer. This looper will
then be used for receiving node monitoring messages.
* Reenabled using be_app as default BLooper if the API user does not provide
one. I think the problem that Stefano needed to work aroung in r23995 was
actually caused by the incorrect locking (an never unlocking) of the looper
before calling PathHandler::Quit().
->If I understand correctly, this code as supposed to work around the possible
situation that the looper holding those PathHandlers may have already quit,
leaving stale PathHandler pointers behind. But that case was not prevented
by the old code anyways, since one would have had to access freed memory to
even get the stale BLooper pointer. The real fix would be to store the
BLooper pointer with each PathHandler so that the possible gone-ness of
those loopers could be checked independent of accessing the PathHandler
pointer. (The whole problem is that PathHandler adds itself to the BLooper
and if the looper quits, it will free all its attached handlers.)
* Introduced a global fallback BLooper for the case that no BApplication is
running, which resolves a TODO.

All this is yet untested, but should have a good chance of working.
(Famous last words...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26843 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5bc41debfcaa76eb340cde8108e36503ef872ee 04-Aug-2008 Stephan Aßmus <superstippi@gmx.de>

* Use new header layout in PathMonitor.h
* Honor 80 char/line limit in PathMonitor.cpp


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26788 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d00539e3ba985c9438085f6ac10875183525f626 07-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Revamped BPathMonitor API as suggested by Ingo - we could rename it to BNodeMonitor
and add wrappers for watch_node() as well, though.
* Implemented more or less all what is needed for the path monitoring to work.
* Added a test application: works fine under Haiku, but somewhat flaky under BeOS,
dunno why yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21066 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f30198a05113232c63144c30e753e7d983dccf3a 04-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Implemented PathMonitor class - untested, but compiles.
* The API is just a proposal at this time, please comment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21020 a95241bf-73f2-0310-859d-f6bbb57e9c96