diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-04-07 22:00:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 22:00:55 +0100 |
commit | aedeedc2068cbf0eed9f4f6d8d9b7474e78c52ac (patch) | |
tree | bd3ebe258f5945f5b5eb1216b2918aa6f0e15fff /synapse/replication/tcp/protocol.py | |
parent | Convert delete_url_cache_media to async/await. (#7241) (diff) | |
parent | changelog (diff) | |
download | synapse-aedeedc2068cbf0eed9f4f6d8d9b7474e78c52ac.tar.xz |
Merge pull request #7239 from matrix-org/rav/replication_cleanup
Miscellaneous cleanups to replication code
Diffstat (limited to 'synapse/replication/tcp/protocol.py')
-rw-r--r-- | synapse/replication/tcp/protocol.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/replication/tcp/protocol.py b/synapse/replication/tcp/protocol.py index 9aabb9c586..9276ed2965 100644 --- a/synapse/replication/tcp/protocol.py +++ b/synapse/replication/tcp/protocol.py @@ -201,15 +201,23 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver): ) self.send_error("ping timeout") - def lineReceived(self, line): + def lineReceived(self, line: bytes): """Called when we've received a line """ if line.strip() == "": # Ignore blank lines return - line = line.decode("utf-8") - cmd_name, rest_of_line = line.split(" ", 1) + linestr = line.decode("utf-8") + + # split at the first " ", handling one-word commands + idx = linestr.index(" ") + if idx >= 0: + cmd_name = linestr[:idx] + rest_of_line = linestr[idx + 1 :] + else: + cmd_name = linestr + rest_of_line = "" if cmd_name not in self.VALID_INBOUND_COMMANDS: logger.error("[%s] invalid command %s", self.id(), cmd_name) |