Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Handle one-word replication commands correctly
Browse files Browse the repository at this point in the history
`REPLICATE` is now a valid command, and it's nice if you can issue it from the
console without remembering to call it `REPLICATE ` with a trailing space.
  • Loading branch information
richvdh committed Apr 7, 2020
1 parent c3e4b4e commit e13c6c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions synapse/replication/tcp/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,23 @@ def send_ping(self):
)
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)
Expand Down

0 comments on commit e13c6c7

Please sign in to comment.