diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 19:33:00 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 19:33:00 +0000 |
commit | 476640cbedafc1ef49246843584f141c28be55b1 (patch) | |
tree | 545f5347388dc10b6aa1416fd84d8d01014c3354 /ui | |
parent | 3a368a2245c082c1fca5f50f73f2139cfffd493d (diff) | |
download | chromium_src-476640cbedafc1ef49246843584f141c28be55b1.zip chromium_src-476640cbedafc1ef49246843584f141c28be55b1.tar.gz chromium_src-476640cbedafc1ef49246843584f141c28be55b1.tar.bz2 |
x11: Set a timeout for the clipboard copy request.
It is possible for an app to take too long to send back the clipboard
data, and in such cases, it is possible to spin up multiple nested
message-loops, each waiting for a response from X11 server for a
response to the clipboard request. Avoid this, and instead timeout
after 300ms and break out of the nested message-loop.
I have seen some crashes that have multiple nested message-loops from
calls to PerformBlockingConvertSelection (e.g. crash 3b1528e4957b87ef
and others), and this should help avoid those cases.
BUG=none
R=erg@chromium.org
Review URL: https://codereview.chromium.org/213263002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259659 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/x/selection_requestor.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ui/base/x/selection_requestor.cc b/ui/base/x/selection_requestor.cc index f044cf8..158028d 100644 --- a/ui/base/x/selection_requestor.cc +++ b/ui/base/x/selection_requestor.cc @@ -55,6 +55,13 @@ bool SelectionRequestor::PerformBlockingConvertSelection( base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); base::RunLoop run_loop; + // Stop waiting for a response after a certain amount of time. + const int kMaxWaitTimeForClipboardResponse = 300; + loop->PostDelayedTask( + FROM_HERE, + run_loop.QuitClosure(), + base::TimeDelta::FromMilliseconds(kMaxWaitTimeForClipboardResponse)); + PendingRequest pending_request(target, run_loop.QuitClosure()); pending_requests_.push_back(&pending_request); run_loop.Run(); |