[Libreoffice-commits] online.git: 2 commits - Mobile/Mobile.xcodeproj net/FakeSocket.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 23 12:25:19 UTC 2018
Mobile/Mobile.xcodeproj/project.pbxproj | 14 ++++++++++++
net/FakeSocket.cpp | 37 ++++++++++++++------------------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit decf78ff2e07587f1b7dbf55f5049e9585557c5b
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 23 14:50:23 2018 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 23 15:23:01 2018 +0300
Buffer an unlimited (eek, scary) number of messages per fake socket
Matches the behaviour of real sockets in a real Online server better.
Seems to get rid of the occasional hang problem.
I had already some time ago suspected that such a change would fix
that problem, but unfortunately my first attempt missed one crucial
detail, so it didn't, and I spent days looking for other ways to fix
the problem instead, in vain.
Probably I should add some sanity limit on the number of buffered
messages, though... But if such a sanity limit then would be hit, most
likely much else is totally broken already anyway.
Change-Id: Ice43057814ee5abd85b2935ffaa91765845a515a
diff --git a/net/FakeSocket.cpp b/net/FakeSocket.cpp
index 34b32f41b..5562e20ca 100644
--- a/net/FakeSocket.cpp
+++ b/net/FakeSocket.cpp
@@ -50,7 +50,7 @@ struct FakeSocketPair
int connectingFd;
bool shutdown[2];
bool readable[2];
- std::vector<char> buffer[2];
+ std::vector<std::vector<char>> buffer[2];
FakeSocketPair()
{
@@ -219,11 +219,10 @@ static bool checkForPoll(std::vector<FakeSocketPair>& fds, struct pollfd *pollfd
retval = true;
}
}
- // With our trivial single-message buffering, a socket is writable if the peer socket is
- // open and not readable.
+ // With multiple buffers, a socket is always writable unless the peer is closed or shut down
if (pollfds[i].events & POLLOUT)
{
- if (fds[pollfds[i].fd/2].fd[N] != -1 && !fds[pollfds[i].fd/2].readable[N] && !fds[pollfds[i].fd/2].shutdown[N])
+ if (fds[pollfds[i].fd/2].fd[N] != -1 && !fds[pollfds[i].fd/2].shutdown[N])
{
pollfds[i].revents |= POLLOUT;
retval = true;
@@ -464,9 +463,9 @@ ssize_t fakeSocketAvailableDataLength(int fd)
return -1;
}
- loggingBuffer << "FakeSocket Available data on #" << fd << ": " << pair.buffer[K].size() << flush();
+ loggingBuffer << "FakeSocket Available data on #" << fd << ": " << pair.buffer[K][0].size() << flush();
- return pair.buffer[K].size();
+ return pair.buffer[K][0].size();
}
ssize_t fakeSocketRead(int fd, void *buf, size_t nbytes)
@@ -507,8 +506,9 @@ ssize_t fakeSocketRead(int fd, void *buf, size_t nbytes)
return -1;
}
- // These sockets are record-oriented! It won't work to read less than the whole buffer.
- ssize_t result = pair.buffer[K].size();
+ // These sockets are record-oriented. It won't work to read less than the whole record in turn
+ // to be read.
+ ssize_t result = pair.buffer[K][0].size();
if (nbytes < result)
{
loggingBuffer << "FakeSocket EAGAIN: Read from #" << fd << ", " << nbytes << (nbytes == 1 ? " byte" : " bytes") << flush();
@@ -516,12 +516,16 @@ ssize_t fakeSocketRead(int fd, void *buf, size_t nbytes)
return -1;
}
- memmove(buf, pair.buffer[K].data(), result);
- pair.buffer[K].resize(0);
+ if (pair.buffer[K].size() == 0)
+ return 0;
+
+ memmove(buf, pair.buffer[K][0].data(), result);
+ pair.buffer[K].erase(pair.buffer[K].begin());
+
// If peer is closed or shut down, we continue to be readable
if (pair.fd[N] == -1 || pair.shutdown[N])
pair.readable[K] = true;
- else
+ else if (pair.buffer[K].size() == 0)
pair.readable[K] = false;
theCV.notify_all();
@@ -564,15 +568,8 @@ ssize_t fakeSocketWrite(int fd, const void *buf, size_t nbytes)
return -1;
}
- if (pair.readable[N])
- {
- loggingBuffer << "FakeSocket EAGAIN: Write to #" << fd << ", " << nbytes << (nbytes == 1 ? " byte" : " bytes") << flush();
- errno = EAGAIN;
- return -1;
- }
-
- pair.buffer[N].resize(nbytes);
- memmove(pair.buffer[N].data(), buf, nbytes);
+ pair.buffer[N].emplace_back(std::vector<char>(nbytes));
+ memmove(pair.buffer[N].back().data(), buf, nbytes);
pair.readable[N] = true;
theCV.notify_all();
commit 60a373385907d41a85f3acb1d37c2a826189c993
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 23 14:48:21 2018 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 23 15:19:10 2018 +0300
Add also some .hpp files for easier breakpointing
Change-Id: I8cb92c80f21bb2b3390e786d44c3621ff5836466
diff --git a/Mobile/Mobile.xcodeproj/project.pbxproj b/Mobile/Mobile.xcodeproj/project.pbxproj
index e97e3a2e8..058e2c13b 100644
--- a/Mobile/Mobile.xcodeproj/project.pbxproj
+++ b/Mobile/Mobile.xcodeproj/project.pbxproj
@@ -72,6 +72,13 @@
BE00F89E21396585001CE2D4 /* images */ = {isa = PBXFileReference; lastKnownFileType = folder; name = images; path = ../../../loleaflet/dist/images; sourceTree = "<group>"; };
BE00F8B4213ED543001CE2D4 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; };
BE00F8B6213ED573001CE2D4 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
+ BE58E129217F295B00249358 /* Log.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Log.hpp; sourceTree = "<group>"; };
+ BE58E12A217F295B00249358 /* Png.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Png.hpp; sourceTree = "<group>"; };
+ BE58E12B217F295B00249358 /* SigUtil.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SigUtil.hpp; sourceTree = "<group>"; };
+ BE58E12C217F295B00249358 /* Util.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Util.hpp; sourceTree = "<group>"; };
+ BE58E12D217F295B00249358 /* MessageQueue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MessageQueue.hpp; sourceTree = "<group>"; };
+ BE58E12E217F295B00249358 /* Protocol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Protocol.hpp; sourceTree = "<group>"; };
+ BE58E12F217F295B00249358 /* Session.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Session.hpp; sourceTree = "<group>"; };
BE5EB5B9213FE29900E0826C /* Log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Log.cpp; sourceTree = "<group>"; };
BE5EB5BA213FE29900E0826C /* SpookyV2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpookyV2.cpp; sourceTree = "<group>"; };
BE5EB5BB213FE29900E0826C /* Session.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Session.cpp; sourceTree = "<group>"; };
@@ -323,14 +330,21 @@
children = (
BE5EB5C0213FE29900E0826C /* FileUtil.cpp */,
BE5EB5B9213FE29900E0826C /* Log.cpp */,
+ BE58E129217F295B00249358 /* Log.hpp */,
BE5EB5BD213FE29900E0826C /* MessageQueue.cpp */,
+ BE58E12D217F295B00249358 /* MessageQueue.hpp */,
+ BE58E12A217F295B00249358 /* Png.hpp */,
BE5EB5BF213FE29900E0826C /* Protocol.cpp */,
+ BE58E12E217F295B00249358 /* Protocol.hpp */,
BE5EB5BB213FE29900E0826C /* Session.cpp */,
+ BE58E12F217F295B00249358 /* Session.hpp */,
BE5EB5BE213FE29900E0826C /* SigUtil.cpp */,
+ BE58E12B217F295B00249358 /* SigUtil.hpp */,
BE5EB5BA213FE29900E0826C /* SpookyV2.cpp */,
BEA28376214FFD8C00848631 /* Unit.cpp */,
BEA283782150172600848631 /* Unit.hpp */,
BE5EB5BC213FE29900E0826C /* Util.cpp */,
+ BE58E12C217F295B00249358 /* Util.hpp */,
);
path = common;
sourceTree = "<group>";
More information about the Libreoffice-commits
mailing list