Download raw body.
convert imsg->fd to imsg_get_fd()
On 2024/01/17 13:10:39 +0100, Stefan Sperling <stsp@stsp.name> wrote: > On Wed, Jan 17, 2024 at 12:58:01PM +0100, Stefan Sperling wrote: > > On Wed, Jan 17, 2024 at 12:01:06PM +0100, Omar Polo wrote: > > > Oh, this also means that got can't be built on the latest release. > > > > The main branch already fails to build on 7.4 now. > > > > I would like to preserve our ability to provide -stable packages on 7.4. > > Is the hack below too horrible or can we use this until 7.5? > > New diff which also fixes the build of gotd, gotsh, and gotwebd > on 7.4 by adding imsg_get_fd() stubs in additional places. I concur with the sentiment but the implementation is wrong. We leak fds if imsg_free() doesn't close them, which is the case in 7.4. Here's another way to do this, with less fiddling. Still ugly, but should avoid the leaks. We'll need to augment this with imsg_get_data() and _len() soon. diff 177bdeb4f88233e7ea397bd3a8494b5d1930204e refs/heads/main commit - 177bdeb4f88233e7ea397bd3a8494b5d1930204e commit + 08fe932a5bc4e17bb7d4e71aa3d15c4f460b553e blob - 495bc5a1d44efc6d760792f0976a4cbf808e0b8a blob + 5c2c859e9c3935f75e07b83044904479f69122ce --- Makefile.inc +++ Makefile.inc @@ -6,6 +6,12 @@ CPPFLAGS += -DGOT_LIBEXECDIR=${LIBEXECDIR} -DGOT_VERSI #CFLAGS += -DGOT_DELTA_CACHE_DEBUG #CFLAGS += -DGOT_DIFF_NO_MMAP +# Compat hack for OpenBSD 7.4. Can be removed once 7.5 has been released. +GOT_NEED_IMSG_COMPAT != if nm /usr/lib/libutil.a | grep -q imsg_get_fd; then echo 'No'; else echo 'Yes'; fi +.if "${GOT_NEED_IMSG_COMPAT}" == "Yes" +CFLAGS += -DGOT_NEED_IMSG_COMPAT +.endif + .if "${GOT_RELEASE}" == "Yes" PREFIX ?= /usr/local BINDIR ?= ${PREFIX}/bin blob - /dev/null blob + e44bfec14d6091326bb8fcf9424f8440a48338e3 (mode 644) --- /dev/null +++ lib/imsg.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Claudio Jeker <claudio@openbsd.org> + * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef GOT_IMSG_H +#define GOT_IMSG_H + +#include_next "imsg.h" + +#ifdef GOT_NEED_IMSG_COMPAT + +#include <stdlib.h> +#include <unistd.h> + +static inline int +got_imsg_get_fd(struct imsg *imsg) +{ + int fd = imsg->fd; + + imsg->fd = -1; + return fd; +} + +static inline void +got_imsg_free(struct imsg *imsg) +{ + if (imsg->fd != -1) + close(imsg->fd); + imsg_free(imsg); +} + +#define imsg_get_fd got_imsg_get_fd +#define imsg_free got_imsg_free + +#endif + +#endif /* GOT_IMSG_H */
convert imsg->fd to imsg_get_fd()