Commit a251e40e110f1b745d1be771f304a7e31e2167ba

Stefan Sperling 2020-03-18T16:10:31

GOT_IMSG_ACK isn't needed; just fill the pipe, reading responses will block

diff --git a/lib/fetch.c b/lib/fetch.c
index d1b0036..0a308b0 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -314,9 +314,6 @@ got_clone(char *uri, char *branch_filter, char *dirname)
 	err = got_privsep_send_fetch_req(&ibuf, fetchfd);
 	if (err != NULL)
 		return err;
-	err = got_privsep_wait_ack(&ibuf);
-	if (err != NULL)
-		return err;
 	err = got_privsep_send_tmpfd(&ibuf, npackfd);
 	if (err != NULL)
 		return err;
@@ -343,9 +340,6 @@ got_clone(char *uri, char *branch_filter, char *dirname)
 	err = got_privsep_send_index_pack_req(&ibuf, npackfd, packhash);
 	if (err != NULL)
 		return err;
-	err = got_privsep_wait_ack(&ibuf);
-	if (err != NULL)
-		return err;
 	err = got_privsep_send_tmpfd(&ibuf, nidxfd);
 	if (err != NULL)
 		return err;
diff --git a/lib/got_lib_privsep.h b/lib/got_lib_privsep.h
index 0c4a043..12c2aa8 100644
--- a/lib/got_lib_privsep.h
+++ b/lib/got_lib_privsep.h
@@ -85,9 +85,6 @@ enum got_imsg_type {
 	/* Stop the child process. */
 	GOT_IMSG_STOP,
 
-	/* We got a message as part of a sequence */
-	GOT_IMSG_ACK,
-
 	/*
 	 * Messages concerned with read access to objects in a repository.
 	 * Object and pack files are opened by the main process, where
diff --git a/lib/privsep.c b/lib/privsep.c
index b5ea8d2..90f056a 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -231,31 +231,6 @@ got_privsep_send_stop(int fd)
 }
 
 const struct got_error *
-got_privsep_send_ack(struct imsgbuf *ibuf)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_ACK, 0, 0, -1, NULL, 0) == -1)
-		return got_error_from_errno("imsg_compose ACK");
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_wait_ack(struct imsgbuf *ibuf)
-{
-	const struct got_error *err = NULL;
-	struct imsg imsg;
-
-	err = got_privsep_recv_imsg(&imsg, ibuf, 0);
-	if (err)
-		return err;
-	if (imsg.hdr.type == GOT_IMSG_ACK && imsg.hdr.len - IMSG_HEADER_SIZE == 0)
-		return NULL;
-	else
-		return got_error(GOT_ERR_PRIVSEP_MSG);
-	imsg_free(&imsg);
-}
-
-
-const struct got_error *
 got_privsep_send_obj_req(struct imsgbuf *ibuf, int fd)
 {
 	if (imsg_compose(ibuf, GOT_IMSG_OBJECT_REQUEST, 0, 0, fd, NULL, 0)
diff --git a/libexec/got-fetch-pack/got-fetch-pack.c b/libexec/got-fetch-pack/got-fetch-pack.c
index 8d96080..f47aa8e 100644
--- a/libexec/got-fetch-pack/got-fetch-pack.c
+++ b/libexec/got-fetch-pack/got-fetch-pack.c
@@ -429,7 +429,6 @@ main(int argc, char **argv)
 		goto done;
 	}
 	fetchfd = imsg.fd;
-	got_privsep_send_ack(&ibuf);
 
 	if((err = got_privsep_recv_imsg(&imsg, &ibuf, 0)) != 0) {
 		if (err->code == GOT_ERR_PRIVSEP_PIPE)
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index c000f2c..cd6e4f4 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -1236,7 +1236,6 @@ main(int argc, char **argv)
 	}
 	packfd = imsg.fd;
 	memcpy(packhash.sha1, imsg.data, SHA1_DIGEST_LENGTH);
-	got_privsep_send_ack(&ibuf);
 
 	if((err = got_privsep_recv_imsg(&imsg, &ibuf, 0)) != 0) {
 		if (err->code == GOT_ERR_PRIVSEP_PIPE)