Mercurial > hg
comparison mercurial/commandserver.py @ 23036:19f5273c9f3e
cmdserver: include pid of server handling requests in hello message
Because unix-mode server forks child process per connection, client does not
know the pid of the server that will handle requests. The pid is necessary
to interrupt hung process:
1. client connects to socket server
2. server accepts the connection, forks, and tells pid
3. client requests "runcommand pull"
.. hung ..
4. client sends SIGINT to the (forked) server
5. server returns from I/O wait
Note that getsockopt(SO_PEERCRED) of Linux cannot be used because the server
fork()s after accept().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 18 Oct 2014 12:24:50 +0900 |
parents | 840be5ca03e1 |
children | 000cfc8b3913 |
comparison
equal
deleted
inserted
replaced
23035:5f8f8225fc7e | 23036:19f5273c9f3e |
---|---|
230 | 230 |
231 def serve(self): | 231 def serve(self): |
232 hellomsg = 'capabilities: ' + ' '.join(sorted(self.capabilities)) | 232 hellomsg = 'capabilities: ' + ' '.join(sorted(self.capabilities)) |
233 hellomsg += '\n' | 233 hellomsg += '\n' |
234 hellomsg += 'encoding: ' + encoding.encoding | 234 hellomsg += 'encoding: ' + encoding.encoding |
235 hellomsg += '\n' | |
236 hellomsg += 'pid: %d' % os.getpid() | |
235 | 237 |
236 # write the hello msg in -one- chunk | 238 # write the hello msg in -one- chunk |
237 self.cout.write(hellomsg) | 239 self.cout.write(hellomsg) |
238 | 240 |
239 try: | 241 try: |