commit a004b24a97cfaa2be171871f42cdc15e24fa8682 from: Omar Polo via: Thomas Adam date: Tue Sep 06 08:54:15 2022 UTC gotwebd: shrink struct server keeping GOTWEBD_REPO_CACHESIZE * sizeof(struct cache_repo) inside the struct server makes it too large for imsg on some platforms (linux at least.) Instead, store a pointer and allocate the array when it's received on the child processes. ok stsp@ commit - 5baa5fe241b3b9bb4bc6f68b06d18ea4094ad579 commit + a004b24a97cfaa2be171871f42cdc15e24fa8682 blob - 2f88b5b88c026d281f733775eca7dac69cc21a04 blob + 041e66818e8cd0f84a1d59fe60801962e8f611b4 --- gotwebd/config.c +++ gotwebd/config.c @@ -82,7 +82,9 @@ config_setserver(struct gotwebd *env, struct server *s struct privsep *ps = env->gotwebd_ps; memcpy(&ssrv, srv, sizeof(ssrv)); - proc_compose(ps, PROC_SOCKS, IMSG_CFG_SRV, &ssrv, sizeof(ssrv)); + if (proc_compose(ps, PROC_SOCKS, IMSG_CFG_SRV, &ssrv, sizeof(ssrv)) + == -1) + fatal("proc_compose"); return 0; } @@ -97,13 +99,19 @@ config_getserver(struct gotwebd *env, struct imsg *ims srv = calloc(1, sizeof(*srv)); if (srv == NULL) fatalx("%s: calloc", __func__); - memcpy(srv, p, sizeof(*srv)); if (IMSG_DATA_SIZE(imsg) != sizeof(*srv)) { log_debug("%s: imsg size error", __func__); free(srv); return 1; } + + memcpy(srv, p, sizeof(*srv)); + srv->cached_repos = calloc(GOTWEBD_REPO_CACHESIZE, + sizeof(*srv->cached_repos)); + if (srv->cached_repos == NULL) + fatal("%s: calloc", __func__); + srv->ncached_repos = 0; /* log server info */ log_debug("%s: server=%s fcgi_socket=%s unix_socket=%s", __func__, blob - 976d5eac6eb1b6d018e514bb87a9afbb78454dc1 blob + af0d01554db2962e1c2daf8b575f7bdf9f067331 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -2002,7 +2002,7 @@ cache_repo(struct got_repository **new, struct server struct cached_repo *cr; int evicted = 0; - if (srv->ncached_repos >= nitems(srv->cached_repos)) { + if (srv->ncached_repos >= GOTWEBD_REPO_CACHESIZE) { cr = &srv->cached_repos[srv->ncached_repos - 1]; error = got_repo_close(cr->repo); memset(cr, 0, sizeof(*cr)); blob - ac7f962b1abdcfe1c535e8bc210c9f619e7a2cbc blob + f73ea6b8311442f992dbc1c563f90486ef813c04 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -256,7 +256,7 @@ struct server { TAILQ_ENTRY(server) entry; struct addresslist al; - struct cached_repo cached_repos[GOTWEBD_REPO_CACHESIZE]; + struct cached_repo *cached_repos; int ncached_repos; char name[GOTWEBD_MAXTEXT];