Patchwork [5,of,7] chg: make connect debug message less repetitive

login
register
mail settings
Submitter Jun Wu
Date April 4, 2016, 2:30 a.m.
Message ID <f5414d2b4f32431a2510.1459737052@x1c>
Download mbox | patch
Permalink /patch/14322/
State Accepted
Headers show

Comments

Jun Wu - April 4, 2016, 2:30 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1459733765 -3600
#      Mon Apr 04 02:36:05 2016 +0100
# Node ID f5414d2b4f32431a251029ebf46f48efdd9f013c
# Parent  7a1c32c2436c36ef46d10550cd2104b747c8cdec
chg: make connect debug message less repetitive

Before this patch, "connect to" debug message is printed repeatedly because
a previous patch changed how the chg client decides the server is ready to be
connected.

This patch revises the places we print connect debug messages so they are less
repetitive without losing useful information.
Pierre-Yves David - April 4, 2016, 3:14 a.m.
On 04/03/2016 07:30 PM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1459733765 -3600
> #      Mon Apr 04 02:36:05 2016 +0100
> # Node ID f5414d2b4f32431a251029ebf46f48efdd9f013c
> # Parent  7a1c32c2436c36ef46d10550cd2104b747c8cdec
> chg: make connect debug message less repetitive
>
> Before this patch, "connect to" debug message is printed repeatedly because
> a previous patch changed how the chg client decides the server is ready to be
> connected.
>
> This patch revises the places we print connect debug messages so they are less
> repetitive without losing useful information.

Patches 1, 2, 3, 4 an 5 are pushed, thanks.

Patch

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -236,6 +236,7 @@ 
 	static const struct timespec sleepreq = {0, 10 * 1000000};
 	int pst = 0;
 
+	debugmsg("try connect to %s repeatedly", opts->sockname);
 	for (unsigned int i = 0; i < 10 * 100; i++) {
 		hgclient_t *hgc = hgc_open(opts->sockname);
 		if (hgc)
@@ -271,6 +272,7 @@ 
 {
 	const char *sockname = opts->redirectsockname[0] ?
 		opts->redirectsockname : opts->sockname;
+	debugmsg("try connect to %s", sockname);
 	hgclient_t *hgc = hgc_open(sockname);
 	if (hgc)
 		return hgc;
diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -429,7 +429,6 @@ 
 	strncpy(addr.sun_path, sockname, sizeof(addr.sun_path));
 	addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
 
-	debugmsg("connect to %s", addr.sun_path);
 	int r = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
 	if (r < 0) {
 		close(fd);
@@ -438,6 +437,7 @@ 
 		abortmsg("cannot connect to %s (errno = %d)",
 			 addr.sun_path, errno);
 	}
+	debugmsg("connected to %s", addr.sun_path);
 
 	hgclient_t *hgc = mallocx(sizeof(hgclient_t));
 	memset(hgc, 0, sizeof(*hgc));