commit ffca96789477456b045948733974ef18c7e5c18b93b28878c9468fb6d4f8d0ce from: Stefan Sperling date: Fri Jul 18 11:58:02 2025 UTC fix 'gotctl reload -s secrets' failing once gotd has failed to reload once Reset reload secrets state on reload failure, such that the next reload attempt will not be rejected with an 'unexpected imsg' error. commit - 43b0bd60b39be0341c38ce5eafec6a1e2271ea527c903e0cfa1e86c59b1f50b6 commit + ffca96789477456b045948733974ef18c7e5c18b93b28878c9468fb6d4f8d0ce blob - d020d38e788525d02e851f667ce6eb4c0ae0747d23cd58e8a73619a031d32897 blob + ab58d2f9a439b51fcdcaee34e75235a3297358193c52734a46b8d84723b94b6a --- gotd/gotd.c +++ gotd/gotd.c @@ -638,6 +638,17 @@ halt_listener(struct gotd_imsgev *iev) } static void +reload_reset(void) +{ + /* Clear state such that reloading again will work. */ + close(gotd_reload_conf_fd); + gotd_reload_conf_fd = -1; + close(gotd_reload_secrets_fd); + gotd_reload_secrets_fd = -1; + have_reload_secrets = 0; +} + +static void gotd_dispatch_reload(int fd, short event, void *arg) { const struct got_error *err = NULL; @@ -698,6 +709,7 @@ gotd_dispatch_reload(int fd, short event, void *arg) kill_proc(gotd.reload_proc, 0); gotd.reload_proc = NULL; imsg_free(&imsg); + reload_reset(); return; } @@ -3685,12 +3697,7 @@ main(int argc, char **argv) imsgbuf_clear(&ibuf); close(GOTD_FILENO_MSG_PIPE); - /* Clear state such that reloading again will work. */ - close(gotd_reload_conf_fd); - gotd_reload_conf_fd = -1; - close(gotd_reload_secrets_fd); - gotd_reload_secrets_fd = -1; - have_reload_secrets = 0; + reload_reset(); } gotd.argv0 = argv0;