commit 65a36f170d3f7b1ba00e709925d6a320cbecef60 from: Stefan Sperling via: Thomas Adam date: Sat Apr 22 18:09:16 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 - 5769f9a0a07516237666a060ff3e06d43f4db8ed commit + 65a36f170d3f7b1ba00e709925d6a320cbecef60 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 - 4ac000801b8cadce8c293a8ff3878d4ed250d823 blob + 5a4ee87d85e91b5837d1d53b64706a661b1a359e --- gotd/listen.c +++ gotd/listen.c @@ -175,26 +175,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 - eb736f63ba59501f38728a4c2a6c5c0c4a1e7eec blob + 7c22e7b91c8d384d95968e9643bdac9c6069bc33 --- gotd/parse.y +++ gotd/parse.y @@ -1119,6 +1119,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;