[PATCH 2 of 3] chg: add pgid to hgclient struct
Jun Wu
quark at fb.com
Sun Jul 17 18:09:42 EDT 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1468793159 -3600
# Sun Jul 17 23:05:59 2016 +0100
# Node ID 57234c11a5d542865e7360b7b943793e4fd110f7
# Parent 2278b2c5638684efdd9d39ad1e1bc2f691f12b1e
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 57234c11a5d5
chg: add pgid to hgclient struct
The previous patch makes the server tell the client its pgid. This patch
stores it in hgclient_t and adds a function to get it.
diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -63,6 +63,7 @@ typedef struct {
struct hgclient_tag_ {
int sockfd;
+ pid_t pgid;
pid_t pid;
context_t ctx;
unsigned int capflags;
@@ -339,6 +340,8 @@ static void readhello(hgclient_t *hgc)
u = dataend;
if (strncmp(s, "capabilities:", t - s + 1) == 0) {
hgc->capflags = parsecapabilities(t + 2, u);
+ } else if (strncmp(s, "pgid:", t - s + 1) == 0) {
+ hgc->pgid = strtol(t + 2, NULL, 10);
} else if (strncmp(s, "pid:", t - s + 1) == 0) {
hgc->pid = strtol(t + 2, NULL, 10);
}
@@ -463,6 +466,12 @@ void hgc_close(hgclient_t *hgc)
free(hgc);
}
+pid_t hgc_peerpgid(const hgclient_t *hgc)
+{
+ assert(hgc);
+ return hgc->pgid;
+}
+
pid_t hgc_peerpid(const hgclient_t *hgc)
{
assert(hgc);
diff --git a/contrib/chg/hgclient.h b/contrib/chg/hgclient.h
--- a/contrib/chg/hgclient.h
+++ b/contrib/chg/hgclient.h
@@ -18,6 +18,7 @@ typedef struct hgclient_tag_ hgclient_t;
hgclient_t *hgc_open(const char *sockname);
void hgc_close(hgclient_t *hgc);
+pid_t hgc_peerpgid(const hgclient_t *hgc);
pid_t hgc_peerpid(const hgclient_t *hgc);
const char **hgc_validate(hgclient_t *hgc, const char *const args[],
More information about the Mercurial-devel
mailing list