[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Feb 13 05:25:38 UTC 2017
wsd/LOOLWSD.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
New commits:
commit 2da90d0cfc4e73490e323cb3ab00f66dd4d25ab0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Feb 11 18:03:14 2017 -0500
wsd: explain the root of the document bifurcation bug
Change-Id: I9ac290c94296ed18dc25ce3b2d9c4939e4eeea91
Reviewed-on: https://gerrit.libreoffice.org/34192
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index d268d68..c910f98 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1595,6 +1595,26 @@ inline ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
// that happens accidentally for developers only anyway, in production systemd takes care of
// having just one, I hope.)
+ // Note: We really should _not_ need to do this at all. The reason we do is that,
+ // if we don't, when an instance of loolwsd is already running, a second instance
+ // would not fail to listen to the _same_ port, and start stealing connections.
+ // This would have the undesirable side-effect of bifurcating documents (meaning,
+ // clients loading a document that is already loaded in the first instance of
+ // wsd, if their socket is accepted by the second instance of wsd, will not
+ // be able to collaborate with their peers, who are in the first instance of wsd).
+ // This situation arises because Poco's Socket::bind() (when reuseAddress,
+ // the second arg, is true) enables reuse for both address _and_ port.
+ // The latter is damaging (and the root of this bug). It's designed (on Linux)
+ // to load-balance requests on a given port to all server instances.
+ // But this only works if requests are independent (as in web-page serving)
+ // and fail miserably for our purposes here (collaborative editing).
+
+ // The correct solution is to explicitly enable only address reuse
+ // before bind and pass reuseAddress=false (second arg) to bind.
+ // Reusing the address is fine, since that eliminates the wait
+ // when we recycle and the socket from the earlier run is still
+ // in TIME_WAIT.
+
if (reuseDetails)
{
try
More information about the Libreoffice-commits
mailing list