commit 73ab1060354e23885c41d858ec39bcf11e2f5023 from: Stefan Sperling date: Wed Mar 18 16:13:45 2020 UTC use a dedicated imsg for sending the pack index output file descriptor commit - b81777769a6919b267c6799d14f324d44cc467be commit + 73ab1060354e23885c41d858ec39bcf11e2f5023 blob - 2fdd0e7c1725a3b09a7e56e75a5342d747df9a68 blob + 0a0cc2608e50604177f758c8f58bb8a78103e8b5 --- lib/fetch.c +++ lib/fetch.c @@ -502,7 +502,7 @@ got_fetch_pack(struct got_object_id **pack_hash, struc if (err != NULL) goto done; npackfd = -1; - err = got_privsep_send_tmpfd(&idxibuf, nidxfd); + err = got_privsep_send_index_pack_outfd(&idxibuf, nidxfd); if (err != NULL) goto done; nidxfd = -1; blob - b949a92af66121cfec06dc0bfea4accecd970423 blob + 0e76d54d1fe621953015794234ff1cad8b3d30d3 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -116,6 +116,7 @@ enum got_imsg_type { GOT_IMSG_FETCH_DOWNLOAD_PROGRESS, GOT_IMSG_FETCH_DONE, GOT_IMSG_IDXPACK_REQUEST, + GOT_IMSG_IDXPACK_OUTFD, GOT_IMSG_IDXPACK_PROGRESS, GOT_IMSG_IDXPACK_DONE, @@ -377,6 +378,8 @@ const struct got_error *got_privsep_send_obj(struct im struct got_object *); const struct got_error *got_privsep_send_index_pack_req(struct imsgbuf *, uint8_t *, int); +const struct got_error *got_privsep_send_index_pack_outfd(struct imsgbuf *, + int); const struct got_error *got_privsep_send_index_pack_progress(struct imsgbuf *, int, int, int, int); const struct got_error *got_privsep_send_index_pack_done(struct imsgbuf *); blob - b42b1cd03197ef33807cd68e7fae1906826925a1 blob + 938c697a5bf2802cce9397822a280e11350b4a49 --- lib/privsep.c +++ lib/privsep.c @@ -368,13 +368,12 @@ got_privsep_send_blob_outfd(struct imsgbuf *ibuf, int return flush_imsg(ibuf); } -const struct got_error * -got_privsep_send_tmpfd(struct imsgbuf *ibuf, int fd) +static const struct got_error * +send_fd(struct imsgbuf *ibuf, int imsg_code, int fd) { const struct got_error *err = NULL; - if (imsg_compose(ibuf, GOT_IMSG_TMPFD, 0, 0, fd, NULL, 0) - == -1) { + if (imsg_compose(ibuf, imsg_code, 0, 0, fd, NULL, 0) == -1) { err = got_error_from_errno("imsg_compose TMPFD"); close(fd); return err; @@ -384,6 +383,12 @@ got_privsep_send_tmpfd(struct imsgbuf *ibuf, int fd) } const struct got_error * +got_privsep_send_tmpfd(struct imsgbuf *ibuf, int fd) +{ + return send_fd(ibuf, GOT_IMSG_TMPFD, fd); +} + +const struct got_error * got_privsep_send_obj(struct imsgbuf *ibuf, struct got_object *obj) { struct got_imsg_object iobj; @@ -783,6 +788,12 @@ got_privsep_send_index_pack_req(struct imsgbuf *ibuf, } const struct got_error * +got_privsep_send_index_pack_outfd(struct imsgbuf *ibuf, int fd) +{ + return send_fd(ibuf, GOT_IMSG_IDXPACK_OUTFD, fd); +} + +const struct got_error * got_privsep_send_index_pack_progress(struct imsgbuf *ibuf, int nobj_total, int nobj_indexed, int nobj_loose, int nobj_resolved) { blob - 3a91c7605733a8e1016866b330c7ef773143c7d2 blob + f64e53033279fba0a88a4ca4234ad50182f293aa --- libexec/got-index-pack/got-index-pack.c +++ libexec/got-index-pack/got-index-pack.c @@ -845,7 +845,7 @@ main(int argc, char **argv) goto done; if (imsg.hdr.type == GOT_IMSG_STOP) goto done; - if (imsg.hdr.type != GOT_IMSG_TMPFD) { + if (imsg.hdr.type != GOT_IMSG_IDXPACK_OUTFD) { err = got_error(GOT_ERR_PRIVSEP_MSG); goto done; }