[PATCH stateful-chg] commandserver: move _socket state to handler

Jun Wu quark at fb.com
Sat May 20 00:21:13 EDT 2017


Excerpts from Yuya Nishihara's message of 2017-05-20 01:01:41 +0900:
> I recalled that, thanks. Can we move the fork logic to commandserver.py?
> 
>   # unixforkingservice
>   mainloop:
>     if h.need_to_reinitialize_in_background?  # reads IPC
>       fork
>       if child:
>         reinitialize_server
>       else:
>         keep serving in the current process
> 
>   reinitialize_server:
>     close_existing_socket
>     h.preload
>     h.rebind_socket(new_socket)
> 
> IMHO, it isn't easy to abstract fork() stuff cleanly. Doing that in service
> subclass or handler would make it harder to track where resources are created
> and released, and could lead to subtle bugs.

I think that works. So this patch could be dropped. And maybe take the
dispatch.py change so the next steps are easier.

https://bitbucket.org/quark-zju/hg-draft/commits/branch/chg-stateful is a
preview about what's next roughly.


More information about the Mercurial-devel mailing list