[PATCH 3 of 3 V2] chg: hold a lock file before connected to server
Yuya Nishihara
yuya at tcha.org
Wed Feb 24 08:26:44 EST 2016
On Mon, 22 Feb 2016 17:59:09 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1455620932 0
> # Tue Feb 16 11:08:52 2016 +0000
> # Node ID 43e380f60dd4373090fb94497761ebfdc181ca54
> # Parent 118b386f47cb6e6aa4f231c9ae22bc2e155e7b99
> chg: hold a lock file before connected to server
> +/* Connect to a cmdserver. Will start a new server on demand. */
> +static hgclient_t *connectcmdserver(struct cmdserveropts *opts)
> {
> - debugmsg("start cmdserver at %s", opts->sockname);
> + hgclient_t *hgc = hgc_open(opts->sockname);
> + if (hgc)
> + return hgc;
>
> - if (lockcmdserver(opts) < 0) {
> - debugmsg("lock file exists, waiting...");
> - waitcmdserver(opts, 0);
> - return;
> + lockcmdserver(opts);
> + hgc = hgc_open(opts->sockname);
> + if (hgc) {
> + unlockcmdserver(opts);
> + debugmsg("cmdserver is started by another process");
> + return hgc;
> }
>
> - /* remove dead cmdserver socket if any */
> - unlink(opts->sockname);
unlink() is the only way to recover from server crash, but I expect your future
patches will make it unnecessary. Please let me know if you removed these lines
unintentionally.
More information about the Mercurial-devel
mailing list