Mercurial > hg-stable
changeset 30277:7f2313450e86
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 29 Feb 2016 13:41:54 +0900 |
parents | bc5d0e6fd9f3 |
children | dd3dd80fca10 |
files | mercurial/commandserver.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commandserver.py Fri Mar 18 17:15:06 2016 -0700 +++ b/mercurial/commandserver.py Mon Feb 29 13:41:54 2016 +0900 @@ -54,8 +54,8 @@ 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):