From 84fd6e4efe92723aa0265c914d1eaa5da94b6c2f Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 18 Dec 2022 10:24:43 +0100 Subject: [PATCH] [httpd/artwork] Drop support for libevent <2.1.4 --- configure.ac | 8 +------- docs/installation.md | 2 +- src/artwork.c | 14 -------------- src/evrtsp/rtsp.c | 11 ----------- src/httpd.c | 42 ------------------------------------------ 5 files changed, 2 insertions(+), 75 deletions(-) diff --git a/configure.ac b/configure.ac index 2527bd95..45573da6 100644 --- a/configure.ac +++ b/configure.ac @@ -148,13 +148,7 @@ OWNTONE_MODULES_CHECK([COMMON], [SQLITE3], [sqlite3 >= 3.5.0], [AC_MSG_RESULT([[runtime will tell]])]) ]) -OWNTONE_MODULES_CHECK([OWNTONE], [LIBEVENT], [libevent >= 2], - [event_base_new], [event2/event.h], - [dnl check for old version - PKG_CHECK_EXISTS([libevent >= 2.1.4], [], - [AC_DEFINE([HAVE_LIBEVENT2_OLD], 1, - [Define to 1 if you have libevent 2 (<2.1.4)])]) - ]) +OWNTONE_MODULES_CHECK([OWNTONE], [LIBEVENT], [libevent >= 2.1.4], [event_base_new], [event2/event.h]) OWNTONE_MODULES_CHECK([OWNTONE], [JSON_C], [json-c], [json_tokener_parse], [json.h], diff --git a/docs/installation.md b/docs/installation.md index 018f775d..17cfde95 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -233,7 +233,7 @@ Libraries: from - libconfuse from -- libevent 2.0+ (best with 2.1.4+) +- libevent 2.1.4+ from - MiniXML (aka mxml or libmxml) from diff --git a/src/artwork.c b/src/artwork.c index 3ef57c85..2a991f8c 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -574,20 +574,6 @@ size_calculate(int *dst_w, int *dst_h, int src_w, int src_h, int max_w, int max_ DPRINTF(E_DBG, L_ART, "Rescale required, destination width %d height %d\n", *dst_w, *dst_h); } -#ifdef HAVE_LIBEVENT2_OLD -// This is not how this function is actually defined in libevent 2.1+, but it -// works as a less optimal stand-in -int -evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf) -{ - uint8_t *buf = evbuffer_pullup(inbuf, -1); - if (!buf) - return -1; - - return evbuffer_add_reference(outbuf, buf, evbuffer_get_length(inbuf), NULL, NULL); -} -#endif - /* * Either gets the artwork file given in "path" (rescaled if needed) or rescales * the artwork given in "inbuf". diff --git a/src/evrtsp/rtsp.c b/src/evrtsp/rtsp.c index 4d467df7..4f70d48d 100644 --- a/src/evrtsp/rtsp.c +++ b/src/evrtsp/rtsp.c @@ -63,17 +63,6 @@ #include "log.h" #include "rtsp-internal.h" -// For compability with libevent 2.0 (HAVE_LIBEVENT2_OLD) -#if defined(_EVENT_HAVE_GETNAMEINFO) -# define EVENT__HAVE_GETNAMEINFO 1 -#endif -#if defined(_EVENT_HAVE_GETADDRINFO) -# define EVENT__HAVE_GETADDRINFO 1 -#endif -#if defined(_EVENT_HAVE_STRSEP) -# define EVENT__HAVE_STRSEP 1 -#endif - #ifndef EVENT__HAVE_GETNAMEINFO #define NI_MAXSERV 32 #define NI_MAXHOST 1025 diff --git a/src/httpd.c b/src/httpd.c index 12f237d7..959acb72 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -42,10 +42,6 @@ #include #include #include -#ifdef HAVE_LIBEVENT2_OLD -# include -# include -#endif #include #include "logger.h" @@ -134,10 +130,6 @@ static pthread_t tid_httpd; static const char *allow_origin; static int httpd_port; -#ifdef HAVE_LIBEVENT2_OLD -struct stream_ctx *g_st; -#endif - /* -------------------------------- HELPERS --------------------------------- */ @@ -550,11 +542,6 @@ stream_end(struct stream_ctx *st, int failed) close(st->fd); } -#ifdef HAVE_LIBEVENT2_OLD - if (g_st == st) - g_st = NULL; -#endif - free(st); } @@ -592,15 +579,6 @@ stream_chunk_resched_cb(struct evhttp_connection *evcon, void *arg) } } -#ifdef HAVE_LIBEVENT2_OLD -static void -stream_chunk_resched_cb_wrapper(struct bufferevent *bufev, void *arg) -{ - if (g_st) - stream_chunk_resched_cb(NULL, g_st); -} -#endif - static void stream_chunk_xcode_cb(int fd, short event, void *arg) { @@ -648,17 +626,7 @@ stream_chunk_xcode_cb(int fd, short event, void *arg) else ret = xcoded; -#ifdef HAVE_LIBEVENT2_OLD - evhttp_send_reply_chunk(st->req, st->evbuf); - - struct evhttp_connection *evcon = evhttp_request_get_connection(st->req); - struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon); - - g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream - bufev->writecb = stream_chunk_resched_cb_wrapper; -#else evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st); -#endif st->offset += ret; @@ -714,17 +682,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg) evbuffer_add(st->evbuf, st->buf, ret); -#ifdef HAVE_LIBEVENT2_OLD - evhttp_send_reply_chunk(st->req, st->evbuf); - - struct evhttp_connection *evcon = evhttp_request_get_connection(st->req); - struct bufferevent *bufev = evhttp_connection_get_bufferevent(evcon); - - g_st = st; // Can't pass st to callback so use global - limits libevent 2.0 to a single stream - bufev->writecb = stream_chunk_resched_cb_wrapper; -#else evhttp_send_reply_chunk_with_cb(st->req, st->evbuf, stream_chunk_resched_cb, st); -#endif st->offset += ret;