commit 106807b41a6bef7947cfced77add51eb02ad574f from: Stefan Sperling date: Sat Sep 15 18:57:10 2018 UTC make object caching actually work in got-read-pack commit - f4081577c6c649149ef61572d31b82167e5ad33b commit + 106807b41a6bef7947cfced77add51eb02ad574f blob - 91f70c774b1229a71ff2fd12276504df52656861 blob + b39f11fe79428dd8bc9691d9b8b2300171346459 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -177,6 +177,7 @@ struct got_imsg_pack { * Structure for GOT_IMSG_PACKED_OBJECT_REQUEST data. */ struct got_imsg_packed_object { + uint8_t id[SHA1_DIGEST_LENGTH]; int idx; }; @@ -211,5 +212,6 @@ const struct got_error *got_privsep_send_blob(struct i const struct got_error *got_privsep_recv_blob(size_t *, struct imsgbuf *); const struct got_error *got_privsep_init_pack_child(struct imsgbuf *, struct got_pack *, struct got_packidx *); -const struct got_error *got_privsep_send_packed_obj_req(struct imsgbuf *, int); +const struct got_error *got_privsep_send_packed_obj_req(struct imsgbuf *, int, + struct got_object_id *); const struct got_error *got_privsep_send_pack_child_ready(struct imsgbuf *); blob - 2ff896aeceaa318ea2ab3a6c82d5f3751584d169 blob + 7ae2b4c4a8f44dece07f51783d56f8242cfa981e --- lib/object_parse.c +++ lib/object_parse.c @@ -191,7 +191,7 @@ request_packed_object(struct got_object **obj, struct const struct got_error *err = NULL; struct imsgbuf *ibuf = pack->privsep_child->ibuf; - err = got_privsep_send_packed_obj_req(ibuf, idx); + err = got_privsep_send_packed_obj_req(ibuf, idx, id); if (err) return err; blob - 4d61efe62b805d605307c413fcd382d327362dcc blob + fd18041fae8a7d318c0d9a6a115419cf8cd82e18 --- lib/pack.c +++ lib/pack.c @@ -589,8 +589,7 @@ open_plain_object(struct got_object **obj, const char (*obj)->pack_idx = idx; (*obj)->hdrlen = 0; (*obj)->size = size; - if (id) - memcpy(&(*obj)->id, id, sizeof((*obj)->id)); + memcpy(&(*obj)->id, id, sizeof((*obj)->id)); (*obj)->pack_offset = offset; return NULL; @@ -887,8 +886,7 @@ open_delta_object(struct got_object **obj, struct got_ (*obj)->flags = 0; (*obj)->hdrlen = 0; (*obj)->size = 0; /* Not known because deltas aren't applied yet. */ - if (id) - memcpy(&(*obj)->id, id, sizeof((*obj)->id)); + memcpy(&(*obj)->id, id, sizeof((*obj)->id)); (*obj)->pack_offset = offset + tslen; (*obj)->path_packfile = strdup(pack->path_packfile); blob - 9079955e9790c3b92539b537bb8bc36306b3195f blob + be1744b9deba2272530722aa02122fdb504e367c --- lib/privsep.c +++ lib/privsep.c @@ -860,11 +860,13 @@ got_privsep_init_pack_child(struct imsgbuf *ibuf, stru } const struct got_error * -got_privsep_send_packed_obj_req(struct imsgbuf *ibuf, int idx) +got_privsep_send_packed_obj_req(struct imsgbuf *ibuf, int idx, + struct got_object_id *id) { struct got_imsg_packed_object iobj; iobj.idx = idx; + memcpy(iobj.id, id->sha1, sizeof(iobj.id)); if (imsg_compose(ibuf, GOT_IMSG_PACKED_OBJECT_REQUEST, 0, 0, -1, &iobj, sizeof(iobj)) == -1) blob - 87e9fc0833f07dfe77c55287aa38f054cb803c8c blob + 010b14b5519db260c50522b9ffb8d93182af1675 --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -49,14 +49,16 @@ object_request(struct imsg *imsg, struct imsgbuf *ibuf const struct got_error *err = NULL; struct got_imsg_packed_object iobj; struct got_object *obj; + struct got_object_id id; size_t datalen; datalen = imsg->hdr.len - IMSG_HEADER_SIZE; if (datalen != sizeof(iobj)) return got_error(GOT_ERR_PRIVSEP_LEN); memcpy(&iobj, imsg->data, sizeof(iobj)); + memcpy(id.sha1, iobj.id, SHA1_DIGEST_LENGTH); - err = got_packfile_open_object(&obj, pack, packidx, iobj.idx, NULL); + err = got_packfile_open_object(&obj, pack, packidx, iobj.idx, &id); if (err) return err; obj->refcnt++;