mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
classes.Protocol: use a lock with updateTS to ensure thread-safety
Closes #274.
This commit is contained in:
parent
6598d56400
commit
58d71b0907
@ -1131,6 +1131,9 @@ class Protocol():
|
||||
self.casemapping = 'rfc1459'
|
||||
self.hook_map = {}
|
||||
|
||||
# Lock for updateTS to make sure only one thread can change the channel TS at one time.
|
||||
self.ts_lock = threading.Lock()
|
||||
|
||||
def parseArgs(self, args):
|
||||
"""Parses a string of RFC1459-style arguments split into a list, where ":" may
|
||||
be used for multi-word arguments that last until the end of a line.
|
||||
@ -1187,6 +1190,9 @@ class Protocol():
|
||||
channel)
|
||||
self.irc.applyModes(channel, modes)
|
||||
|
||||
# Use a lock so only one thread can change a channel's TS at once: this prevents race
|
||||
# conditions from desyncing the channel list.
|
||||
with self.ts_lock:
|
||||
our_ts = self.irc.channels[channel].ts
|
||||
assert type(our_ts) == int, "Wrong type for our_ts (expected int, got %s)" % type(our_ts)
|
||||
assert type(their_ts) == int, "Wrong type for their_ts (expected int, got %s)" % type(their_ts)
|
||||
|
Loading…
Reference in New Issue
Block a user