mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
cmdserver: write channel header and payload by a single write() call
This makes a channeledoutput thread-safe as long as the underlying fwrite() is thread-safe. Both POSIX and Windows implementations are documented as MT-safe. MT-safety is necessary to use ui.fout and ui.ferr in hgweb.
This commit is contained in:
parent
db11160c56
commit
51001d7040
@ -54,8 +54,8 @@ class channeledoutput(object):
|
||||
def write(self, data):
|
||||
if not data:
|
||||
return
|
||||
self.out.write(struct.pack('>cI', self.channel, len(data)))
|
||||
self.out.write(data)
|
||||
# single write() to guarantee the same atomicity as the underlying file
|
||||
self.out.write(struct.pack('>cI', self.channel, len(data)) + data)
|
||||
self.out.flush()
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
Loading…
Reference in New Issue
Block a user