Mercurial > hg
changeset 30679:fe11f466880d
chg: handle connect failure before errno gets overridden
This patch moves the error handling logic up so that errno after connect
won't be overridden.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sun, 25 Dec 2016 23:32:11 +0000 |
parents | caf7e1c5efe4 |
children | 4677df6b449a |
files | contrib/chg/hgclient.c |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/chg/hgclient.c Sun Dec 25 03:06:55 2016 +0530 +++ b/contrib/chg/hgclient.c Sun Dec 25 23:32:11 2016 +0000 @@ -457,16 +457,17 @@ /* real connect */ int r = connect(fd, (struct sockaddr *)&addr, sizeof(addr)); + if (r < 0) { + if (errno != ENOENT && errno != ECONNREFUSED) + abortmsgerrno("cannot connect to %s", sockname); + } if (bakfd != -1) { fchdirx(bakfd); close(bakfd); } - if (r < 0) { close(fd); - if (errno == ENOENT || errno == ECONNREFUSED) - return NULL; - abortmsgerrno("cannot connect to %s", addr.sun_path); + return NULL; } debugmsg("connected to %s", addr.sun_path);