[gentoo-commits] repo/gentoo:master commit in: dev-libs/libevent/files/, dev-libs/libevent/

2023-07-10 Thread Michał Górny
commit: 0edb96f7d0518fd8498cd6f019335195c5368dc3
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Jul 11 04:30:03 2023 +
Commit: Michał Górny  gentoo  org>
CommitDate: Tue Jul 11 05:51:41 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0edb96f7

dev-libs/libevent: Disable signalfd by default in 2.2.1

Backport the upstream pull request that disables signalfd by default,
as it turned out to cause lots of unexpected breakage.  In particular,
app-misc/tmux was broken and it can't be trivially fixed.

Signed-off-by: Michał Górny  gentoo.org>

 .../files/libevent-2.2.1-disable-signalfd.patch| 152 +
 ...nt-2.2.1-r1.ebuild => libevent-2.2.1-r2.ebuild} |   8 +-
 2 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/dev-libs/libevent/files/libevent-2.2.1-disable-signalfd.patch 
b/dev-libs/libevent/files/libevent-2.2.1-disable-signalfd.patch
new file mode 100644
index ..6dfce3db3497
--- /dev/null
+++ b/dev-libs/libevent/files/libevent-2.2.1-disable-signalfd.patch
@@ -0,0 +1,152 @@
+From 594ab34f1dfc73db85e8f95ec51892cadecaa76c Mon Sep 17 00:00:00 2001
+From: Azat Khuzhin 
+Date: Mon, 10 Jul 2023 10:40:49 +0200
+Subject: [PATCH] Disable signalfd by default
+
+signalfd may behave differently to sigaction/signal, so to avoid
+breaking libevent users (like [1], [2]) disable it by default.
+
+  [1]: https://github.com/tmux/tmux/pull/3621
+  [2]: https://github.com/tmux/tmux/pull/3626
+
+Also signalfd is not that perfect:
+- you need to SIG_BLOCK the signal before
+  - blocked signals are not reset on exec
+  - blocked signals are allowed to coalesce - so in case of multiple
+signals sent you may get the signal only once (ok for most of the
+signals, but may be a problem for SIGCHLD, though you may call
+waitpid() in a loop or use pidfd)
+- and also one implementation problem -
+  sigprocmask is unspecified in a multithreaded process
+
+Refs:
+- https://lwn.net/Articles/415684/
+- https://ldpreload.com/blog/signalfd-is-useless
+
+Refs: https://github.com/libevent/libevent/issues/1460
+Refs: #1342 (cc @dmantipov)
+---
+ CMakeLists.txt |  1 +
+ include/event2/event.h |  6 --
+ signalfd.c |  4 ++--
+ test/include.am|  2 ++
+ test/test.sh   | 11 +--
+ 5 files changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index cd41d16e57..9c402ec0c1 100644
+--- a/CMakeLists.txt
 b/CMakeLists.txt
+@@ -1509,6 +1509,7 @@ if (NOT EVENT__DISABLE_TESTS)
+ else()
+ add_backend_test(${BACKEND} "${BACKEND_ENV_VARS}")
+ endif()
++add_backend_test(signalfd_${BACKEND} 
"${BACKEND_ENV_VARS};EVENT_USE_SIGNALFD=1")
+ endforeach()
+ 
+ #
+diff --git a/include/event2/event.h b/include/event2/event.h
+index 384a84178b..9b971edf1d 100644
+--- a/include/event2/event.h
 b/include/event2/event.h
+@@ -599,9 +599,11 @@ enum event_base_config_flag {
+*/
+   EVENT_BASE_FLAG_EPOLL_DISALLOW_TIMERFD = 0x40,
+ 
+-  /** Do not use signalfd(2) to handle signals even if supported.
++  /** Use signalfd(2) to handle signals over sigaction/signal.
++   *
++   * But note, that in some edge cases signalfd() may works differently.
+*/
+-  EVENT_BASE_FLAG_DISALLOW_SIGNALFD = 0x80,
++  EVENT_BASE_FLAG_USE_SIGNALFD = 0x80,
+ };
+ 
+ /**
+diff --git a/signalfd.c b/signalfd.c
+index 376a04d539..ed31014e5f 100644
+--- a/signalfd.c
 b/signalfd.c
+@@ -205,8 +205,8 @@ sigfd_del(struct event_base *base, int signo, short old, 
short events, void *p)
+ int sigfd_init_(struct event_base *base)
+ {
+   EVUTIL_ASSERT(base != NULL);
+-  if ((base->flags & EVENT_BASE_FLAG_DISALLOW_SIGNALFD) ||
+-  getenv("EVENT_DISALLOW_SIGNALFD"))
++  if (!(base->flags & EVENT_BASE_FLAG_USE_SIGNALFD) &&
++  !getenv("EVENT_USE_SIGNALFD"))
+   return -1;
+   base->evsigsel = 
+   return 0;
+diff --git a/test/include.am b/test/include.am
+index e061c937b7..9b50759da7 100644
+--- a/test/include.am
 b/test/include.am
+@@ -80,6 +80,8 @@ test_runner_changelist: $(top_srcdir)/test/test.sh
+   $(top_srcdir)/test/test.sh -b "" -c
+ test_runner_timerfd_changelist: $(top_srcdir)/test/test.sh
+   $(top_srcdir)/test/test.sh -b "" -T
++test_runner_timerfd_changelist: $(top_srcdir)/test/test.sh
++  $(top_srcdir)/test/test.sh -b "" -S
+ 
+ DISTCLEANFILES += test/regress.gen.c test/regress.gen.h
+ 
+diff --git a/test/test.sh b/test/test.sh
+index dfdd2bf098..79362888c5 100755
+--- a/test/test.sh
 b/test/test.sh
+@@ -50,6 +50,7 @@ setup () {
+   done
+   unset EVENT_EPOLL_USE_CHANGELIST
+   unset EVENT_PRECISE_TIMER
++  unset EVENT_USE_SIGNALFD
+ }
+ 
+ announce () {
+@@ -138,10 +139,12 @@ do_test() {
+   EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST
+   elif test "$2" = "(timerfd)" ; then
+   EVENT_PRECISE_TIMER=1; 

[gentoo-commits] repo/gentoo:master commit in: dev-libs/libevent/files/, dev-libs/libevent/

2023-05-02 Thread Sam James
commit: ae11d4beef4f60804707d74f07e0c25fe6c59b5b
Author: orbea  riseup  net>
AuthorDate: Tue May  2 17:14:37 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue May  2 20:47:07 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae11d4be

dev-libs/libevent: fix the build with clang-16

Closes: https://bugs.gentoo.org/880381
Upstream-Commit: 
https://github.com/libevent/libevent/commit/35375101e741d78bf49642c6929c1eb69a7c3d79
Signed-off-by: orbea  riseup.net>
Closes: https://github.com/gentoo/gentoo/pull/30840
Signed-off-by: Sam James  gentoo.org>

 .../libevent/files/libevent-2.1.12-clang16.patch   | 105 +
 dev-libs/libevent/libevent-2.1.12-r1.ebuild|   1 +
 2 files changed, 106 insertions(+)

diff --git a/dev-libs/libevent/files/libevent-2.1.12-clang16.patch 
b/dev-libs/libevent/files/libevent-2.1.12-clang16.patch
new file mode 100644
index ..2ecf2472079f
--- /dev/null
+++ b/dev-libs/libevent/files/libevent-2.1.12-clang16.patch
@@ -0,0 +1,105 @@
+https://bugs.gentoo.org/880381
+https://github.com/libevent/libevent/commit/35375101e741d78bf49642c6929c1eb69a7c3d79
+
+From 35375101e741d78bf49642c6929c1eb69a7c3d79 Mon Sep 17 00:00:00 2001
+From: Azat Khuzhin 
+Date: Fri, 27 Jan 2023 08:57:33 +0100
+Subject: [PATCH] Fixes some new warnings under clang-15
+
+- -Wdeprecated-non-prototype
+
+  /src/le/libevent/strlcpy.c:48:1: warning: a function definition without a 
prototype is deprecated in all versions of C and is not supported in C2x 
[-Wdeprecated-non-prototype]
+  event_strlcpy_(dst, src, siz)
+
+- -Wstrict-prototypes
+
+  /src/le/libevent/evthread.c:82:70: warning: a function declaration without a 
prototype is deprecated in all versions of C [-Wstrict-prototypes]
+  struct evthread_condition_callbacks *evthread_get_condition_callbacks()
+
+- -Wunused-but-set-variable
+
+  /src/le/libevent/test/regress_buffer.c:130:6: warning: variable 'n' set but 
not used [-Wunused-but-set-variable]
+  int n = 0;
+ ^
+---
+ evthread.c| 4 ++--
+ strlcpy.c | 6 +-
+ test/regress_buffer.c | 5 -
+ 3 files changed, 3 insertions(+), 12 deletions(-)
+
+diff --git a/evthread.c b/evthread.c
+index 3eac594d64..c2da914da1 100644
+--- a/evthread.c
 b/evthread.c
+@@ -74,12 +74,12 @@ evthread_set_id_callback(unsigned long (*id_fn)(void))
+   evthread_id_fn_ = id_fn;
+ }
+ 
+-struct evthread_lock_callbacks *evthread_get_lock_callbacks()
++struct evthread_lock_callbacks *evthread_get_lock_callbacks(void)
+ {
+   return evthread_lock_debugging_enabled_
+   ? _lock_fns_ : _lock_fns_;
+ }
+-struct evthread_condition_callbacks *evthread_get_condition_callbacks()
++struct evthread_condition_callbacks *evthread_get_condition_callbacks(void)
+ {
+   return evthread_lock_debugging_enabled_
+   ? _cond_fns_ : _cond_fns_;
+diff --git a/strlcpy.c b/strlcpy.c
+index 3876475f5a..04c74298dc 100644
+--- a/strlcpy.c
 b/strlcpy.c
+@@ -44,11 +44,7 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 
15:40:16 deraadt Exp
+  * will be copied.  Always NUL terminates (unless siz == 0).
+  * Returns strlen(src); if retval >= siz, truncation occurred.
+  */
+-size_t
+-event_strlcpy_(dst, src, siz)
+-  char *dst;
+-  const char *src;
+-  size_t siz;
++size_t event_strlcpy_(char *dst, const char *src, size_t siz)
+ {
+   register char *d = dst;
+   register const char *s = src;
+diff --git a/test/regress_buffer.c b/test/regress_buffer.c
+index 5683810e26..b0a9e0c162 100644
+--- a/test/regress_buffer.c
 b/test/regress_buffer.c
+@@ -127,19 +127,16 @@ evbuffer_get_waste(struct evbuffer *buf, size_t 
*allocatedp, size_t *wastedp, si
+ {
+   struct evbuffer_chain *chain;
+   size_t a, w, u;
+-  int n = 0;
+   u = a = w = 0;
+ 
+   chain = buf->first;
+   /* skip empty at start */
+   while (chain && chain->off==0) {
+-  ++n;
+   a += chain->buffer_len;
+   chain = chain->next;
+   }
+   /* first nonempty chain: stuff at the end only is wasted. */
+   if (chain) {
+-  ++n;
+   a += chain->buffer_len;
+   u += chain->off;
+   if (chain->next && chain->next->off)
+@@ -148,7 +145,6 @@ evbuffer_get_waste(struct evbuffer *buf, size_t 
*allocatedp, size_t *wastedp, si
+   }
+   /* subsequent nonempty chains */
+   while (chain && chain->off) {
+-  ++n;
+   a += chain->buffer_len;
+   w += (size_t)chain->misalign;
+   u += chain->off;
+@@ -158,7 +154,6 @@ evbuffer_get_waste(struct evbuffer *buf, size_t 
*allocatedp, size_t *wastedp, si
+   }
+   /* subsequent empty chains */
+   while (chain) {
+-  ++n;
+   a += chain->buffer_len;
+   }
+   *allocatedp = a;

diff --git 

[gentoo-commits] repo/gentoo:master commit in: dev-libs/libevent/files/, dev-libs/libevent/

2023-05-02 Thread Sam James
commit: 339d581366252f59abd7b6a9fe06d4c5c08af0c2
Author: orbea  riseup  net>
AuthorDate: Tue May  2 16:45:03 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Tue May  2 20:47:06 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=339d5813

dev-libs/libevent: add upstream libressl patch

This fixes the build with LibreSSL >= 3.5 when the BIO_get_init()
function became available.

Bug: https://bugs.gentoo.org/903001
Upstream-Issue: https://github.com/libevent/libevent/issues/1277
Upstream-PR: https://github.com/libevent/libevent/pull/1227
Upstream-Commit: 
https://github.com/libevent/libevent/commit/883630f76cbf512003b81de25cd96cb75c6cf0f9
Signed-off-by: orbea  riseup.net>
Signed-off-by: Sam James  gentoo.org>

 .../libevent/files/libevent-2.1.12-libressl.patch  | 30 ++
 dev-libs/libevent/libevent-2.1.12-r1.ebuild|  4 +++
 2 files changed, 34 insertions(+)

diff --git a/dev-libs/libevent/files/libevent-2.1.12-libressl.patch 
b/dev-libs/libevent/files/libevent-2.1.12-libressl.patch
new file mode 100644
index ..4c809aface12
--- /dev/null
+++ b/dev-libs/libevent/files/libevent-2.1.12-libressl.patch
@@ -0,0 +1,30 @@
+https://bugs.gentoo.org/903001
+https://github.com/libevent/libevent/issues/1277
+https://github.com/libevent/libevent/pull/1227
+https://github.com/libevent/libevent/commit/883630f76cbf512003b81de25cd96cb75c6cf0f9
+
+From 883630f76cbf512003b81de25cd96cb75c6cf0f9 Mon Sep 17 00:00:00 2001
+From: Theo Buehler 
+Date: Sun, 21 Nov 2021 21:38:20 +0100
+Subject: [PATCH] Don't define BIO_get_init() for LibreSSL 3.5+
+
+BIO_get_init() is available in LibreSSL 3.5 and later. The BIO type
+will become opaque, so the existing macro will break the build.
+---
+ openssl-compat.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/openssl-compat.h b/openssl-compat.h
+index a23e34251b..f5de25539f 100644
+--- a/openssl-compat.h
 b/openssl-compat.h
+@@ -40,7 +40,8 @@ static inline BIO_METHOD *BIO_meth_new(int type, const char 
*name)
+ #endif /* (OPENSSL_VERSION_NUMBER < 0x1010L) || \
+   (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 
0x2070L) */
+ 
+-#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070L
++#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 
0x2070L && \
++  LIBRESSL_VERSION_NUMBER < 0x3050L
+ #define BIO_get_init(b) (b)->init
+ #endif
+ 

diff --git a/dev-libs/libevent/libevent-2.1.12-r1.ebuild 
b/dev-libs/libevent/libevent-2.1.12-r1.ebuild
index 2077b9fd606f..bc2c6da3c012 100644
--- a/dev-libs/libevent/libevent-2.1.12-r1.ebuild
+++ b/dev-libs/libevent/libevent-2.1.12-r1.ebuild
@@ -37,6 +37,10 @@ MULTILIB_WRAPPED_HEADERS=(
 )
 S=${WORKDIR}/${P/_/-}-stable
 
+PATCHES=(
+   "${FILESDIR}"/${P}-libressl.patch #903001
+)
+
 src_prepare() {
default
# bug #767472