commit eeb616b754913da958b9781aee9ed88db64e7162 from: Stefan Sperling date: Fri Apr 14 21:04:42 2023 UTC remove dependency of gitwrapper on gotd/listen.c Move gotd_find_uid_connection_limit() from listen.c into parse.y and remove listen.c from the list of source files required by gitwrapper. commit - 1eb3899277955a87d80eef900b6ea458ff73bd6c commit + eeb616b754913da958b9781aee9ed88db64e7162 blob - b5090f97c92dbb39058bb0025be416df747495c8 blob + 63098f02298c146e943e4011ce9ae7a50aa48d24 --- gitwrapper/Makefile +++ gitwrapper/Makefile @@ -10,7 +10,7 @@ BINDIR ?= ${PREFIX}/bin PROG= gitwrapper SRCS= gitwrapper.c parse.y log.c dial.c path.c error.c auth.c \ - listen.c reference_parse.c hash.c object_parse.c imsg.c \ + reference_parse.c hash.c object_parse.c imsg.c \ inflate.c pollfd.c CLEANFILES = parse.h blob - 6453c5edd60a936a27ff6c705694973e711adb82 blob + da5659310b289bac96cef1db5c87299064a62cc5 --- gotd/gotd.h +++ gotd/gotd.h @@ -452,6 +452,8 @@ struct gotd_imsg_auth { int parse_config(const char *, enum gotd_procid, struct gotd *, int); struct gotd_repo *gotd_find_repo_by_name(const char *, struct gotd *); struct gotd_repo *gotd_find_repo_by_path(const char *, struct gotd *); +struct gotd_uid_connection_limit *gotd_find_uid_connection_limit( + struct gotd_uid_connection_limit *limits, size_t nlimits, uid_t uid); /* imsg.c */ const struct got_error *gotd_imsg_flush(struct imsgbuf *); blob - b51f18490312837f6627991cf323dc1e5bc2d7a6 blob + 63f3c3f406563f1f34146a9f83783402e5b94c5b --- gotd/listen.c +++ gotd/listen.c @@ -177,26 +177,6 @@ find_uid_connection_counter(uid_t euid) STAILQ_FOREACH(c, &gotd_client_uids[slot], entry) { if (c->euid == euid) return c; - } - - return NULL; -} - -struct gotd_uid_connection_limit * -gotd_find_uid_connection_limit(struct gotd_uid_connection_limit *limits, - size_t nlimits, uid_t uid) -{ - /* This array is always sorted to allow for binary search. */ - int i, left = 0, right = nlimits - 1; - - while (left <= right) { - i = ((left + right) / 2); - if (limits[i].uid == uid) - return &limits[i]; - if (limits[i].uid > uid) - left = i + 1; - else - right = i - 1; } return NULL; blob - e7a67532164502eb5ea8893b35007e6edf63ee36 blob + d20bd8e1a2325f8c8b80d5c1ce127eef7aafd525 --- gotd/listen.h +++ gotd/listen.h @@ -14,9 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -struct gotd_uid_connection_limit *gotd_find_uid_connection_limit( - struct gotd_uid_connection_limit *limits, size_t nlimits, uid_t uid); - void listen_main(const char *title, int gotd_socket, struct gotd_uid_connection_limit *connection_limits, size_t nconnection_limits); blob - 86df002974199b257619f65568a8d0fe77f560af blob + a18d6c539c362ef359781888ef0c1a1995b2183f --- gotd/parse.y +++ gotd/parse.y @@ -1121,6 +1121,26 @@ gotd_find_repo_by_path(const char *repo_path, struct g TAILQ_FOREACH(repo, &gotd->repos, entry) { if (strcmp(repo->path, repo_path) == 0) return repo; + } + + return NULL; +} + +struct gotd_uid_connection_limit * +gotd_find_uid_connection_limit(struct gotd_uid_connection_limit *limits, + size_t nlimits, uid_t uid) +{ + /* This array is always sorted to allow for binary search. */ + int i, left = 0, right = nlimits - 1; + + while (left <= right) { + i = ((left + right) / 2); + if (limits[i].uid == uid) + return &limits[i]; + if (limits[i].uid > uid) + left = i + 1; + else + right = i - 1; } return NULL;