diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 18:28:19 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 18:28:19 +0000 |
commit | c891ab9654f7e78ce33e84294431a04c5de3abd1 (patch) | |
tree | 6d26437c65e6ec92aa3736206b5473a02edbe388 /base/waitable_event_watcher_unittest.cc | |
parent | 546dc8d90051f5d8d0c38fd70e52f8674e0762a7 (diff) | |
download | chromium_src-c891ab9654f7e78ce33e84294431a04c5de3abd1.zip chromium_src-c891ab9654f7e78ce33e84294431a04c5de3abd1.tar.gz chromium_src-c891ab9654f7e78ce33e84294431a04c5de3abd1.tar.bz2 |
POSIX: allow WaitableEvents to be deleted while watching them.
On Windows, one can close a HANDLE which is currently being waited on. The MSDN
documentation says that the resulting behaviour is 'undefined', but it doesn't
crash. Currently, on POSIX, one couldn't use WaitableEventWatcher to watch an
event which gets deleted. This mismatch has bitten us several times now.
This patch allows WaitableEvents to be deleted while a WaitableEventWatcher is
still watching them. It applies only to watchers, the usual Wait() and
WaitMany() calls still require that all their target be valid until the end of
the call.
http://crbug.com/8809
Review URL: http://codereview.chromium.org/53026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/waitable_event_watcher_unittest.cc')
-rw-r--r-- | base/waitable_event_watcher_unittest.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/base/waitable_event_watcher_unittest.cc b/base/waitable_event_watcher_unittest.cc index 44b9b89..049de38 100644 --- a/base/waitable_event_watcher_unittest.cc +++ b/base/waitable_event_watcher_unittest.cc @@ -107,6 +107,22 @@ void RunTest_OutlivesMessageLoop(MessageLoop::Type message_loop_type) { } } +void RunTest_DeleteUnder(MessageLoop::Type message_loop_type) { + // Delete the WaitableEvent out from under the Watcher. This is explictly + // allowed by the interface. + + MessageLoop message_loop(message_loop_type); + + { + WaitableEventWatcher watcher; + + WaitableEvent* event = new WaitableEvent(false, false); + QuitDelegate delegate; + watcher.StartWatching(event, &delegate); + delete event; + } +} + } // namespace //----------------------------------------------------------------------------- @@ -134,3 +150,9 @@ TEST(WaitableEventWatcherTest, OutlivesMessageLoop) { RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); } + +TEST(WaitableEventWatcherTest, DeleteUnder) { + RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); + RunTest_DeleteUnder(MessageLoop::TYPE_IO); + RunTest_DeleteUnder(MessageLoop::TYPE_UI); +} |