Commit ec013ac7 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Add missing connection flushes

When waiting for a reply from a request, XCB (under some circumstances)
may only flush the request queue up to the request in question.  This
may cause unnecessary round trips.  To avoid this, add an explicit flush
where necessary.

R=sky

Bug: None
Change-Id: Ifaa1a43103517668b963d644d7ee628bbd1dc935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533397
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826966}
parent 17cc71f5
......@@ -465,6 +465,8 @@ bool GetInnerWindowBounds(x11::Window window, gfx::Rect* rect) {
auto translate_coords = connection->TranslateCoordinates({x11_window, root});
// Sync after making both requests so only one round-trip is made.
// Flush so all requests are sent before waiting on any replies.
connection->Flush();
auto geometry = get_geometry.Sync();
auto coords = translate_coords.Sync();
......
......@@ -1530,6 +1530,8 @@ class GenExtensionManager(FileWriter):
self.write(
'auto %s_future = conn->QueryExtension({"%s"});' %
(extension.proto, extension.module.namespace.ext_xname))
# Flush so all requests are sent before waiting on any replies.
self.write('conn->Flush();')
self.write()
for extension in self.extensions:
name = extension.proto
......
......@@ -259,6 +259,8 @@ X11AtomCache::X11AtomCache() : connection_(x11::Connection::Get()) {
for (const char* name : kAtomsToCache)
requests.push_back(
connection_->InternAtom(x11::InternAtomRequest{.name = name}));
// Flush so all requests are sent before waiting on any replies.
connection_->Flush();
for (size_t i = 0; i < kCacheCount; ++i) {
if (auto response = requests[i].Sync())
cached_atoms_[kAtomsToCache[i]] = static_cast<x11::Atom>(response->atom);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment