Compare commits

..

No commits in common. 'c9' and 'c8' have entirely different histories.
c9 ... c8

2
.gitignore vendored

@ -1 +1 @@
SOURCES/libevent-2.1.12-stable.tar.gz
SOURCES/libevent-2.1.8-stable.tar.gz

@ -1 +1 @@
cd55656a9b5bed630b08f05495230affb7996b21 SOURCES/libevent-2.1.12-stable.tar.gz
2a1b8bb7a262d3fd0ed6a080a20991a6eed675ec SOURCES/libevent-2.1.8-stable.tar.gz

@ -1,43 +0,0 @@
From 7905dba8cf136574b87c972cf1f91a8f95b9df8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
Date: Tue, 29 Sep 2020 17:37:18 +0200
Subject: [PATCH] Revert "Fix checking return value of the
evdns_base_resolv_conf_parse()"
This reverts commit fc51bf2c5b686f623c9a2906ddad4042d5c3b39a.
---
evdns.c | 2 +-
sample/dns-example.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/evdns.c b/evdns.c
index a5b31a3c..4aef28ec 100644
--- a/evdns.c
+++ b/evdns.c
@@ -4035,7 +4035,7 @@ evdns_base_new(struct event_base *event_base, int flags)
#else
r = evdns_base_resolv_conf_parse(base, opts, "/etc/resolv.conf");
#endif
- if (r) {
+ if (r == -1) {
evdns_base_free_and_unlock(base, 0);
return NULL;
}
diff --git a/sample/dns-example.c b/sample/dns-example.c
index 2d07c387..21a75de8 100644
--- a/sample/dns-example.c
+++ b/sample/dns-example.c
@@ -225,8 +225,8 @@ main(int c, char **v) {
res = evdns_base_resolv_conf_parse(evdns_base,
DNS_OPTION_NAMESERVERS, o.resolv_conf);
- if (res) {
- fprintf(stderr, "Couldn't configure nameservers\n");
+ if (res < 0) {
+ fprintf(stderr, "Couldn't configure nameservers");
return 1;
}
}
--
2.25.4

@ -1,26 +0,0 @@
From e3e7bb212ea17aa8a9d5a30163487342e6ebb350 Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <azat@libevent.org>
Date: Tue, 11 Aug 2020 02:12:23 +0300
Subject: [PATCH] build: add doxygen to all
Fixes: 7e6c5fb4 ("build: do not try install doxygen man pages if they were not requested")
Fixes: #1075
Fixes: #886
---
doxygen.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/doxygen.am b/doxygen.am
index 53da8d24..1377aacd 100644
--- a/doxygen.am
+++ b/doxygen.am
@@ -53,5 +53,6 @@ uninstall-local:
rmdir "$(DESTDIR)$(htmldir)/" || true
doxygen: doxygen-doc
+all: doxygen
endif ENABLE_DOXYGEN
--
2.25.4

@ -1,43 +0,0 @@
From 7e6c5fb46ae9d0f135cdcdb4f8d0376cf25320fd Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <azat@libevent.org>
Date: Thu, 6 Aug 2020 10:24:55 +0300
Subject: [PATCH] build: do not try install doxygen man pages if they were not
requested
Fixes: #1075
---
doxygen.am | 2 ++
m4/ax_prog_doxygen.m4 | 1 +
2 files changed, 3 insertions(+)
diff --git a/doxygen.am b/doxygen.am
index 916d7c40..53da8d24 100644
--- a/doxygen.am
+++ b/doxygen.am
@@ -17,9 +17,11 @@ if ENABLE_DOXYGEN
clean-local:
-rm -rf $(DX_CLEANFILES)
+if ENABLE_DOXYGEN_MAN
# integrate doxygen with automake targets
man3_MANS = @DX_DOCDIR@/man/man3/*
$(man3_MANS): doxygen-doc
+endif ENABLE_DOXYGEN_MAN
# Docs will be installed. It may be one or more docs supported
# by doxygen, but does not include 'man'.
diff --git a/m4/ax_prog_doxygen.m4 b/m4/ax_prog_doxygen.m4
index e5bdeb59..338e4646 100644
--- a/m4/ax_prog_doxygen.m4
+++ b/m4/ax_prog_doxygen.m4
@@ -574,6 +574,7 @@ DX_INSTALL_DOCS = \\
\$(DX_CLEAN_HTML) \\
\$(DX_CLEAN_CHM) \\
\$(DX_CLEAN_CHI) \\
+ \$(DX_CLEAN_MAN) \\
\$(DX_CLEAN_RTF) \\
\$(DX_CLEAN_XML) \\
\$(DX_CLEAN_PS) \\
--
2.25.4

@ -1,443 +0,0 @@
From 4386f0971e4001227732837c6ec60f8e267f9be3 Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <azat@libevent.org>
Date: Wed, 4 Sep 2019 00:56:20 +0300
Subject: [PATCH] http: eliminate redundant bev fd manipulating and caching
At the very beginning we reset the bufferevent fd (if bev has it), which
is not a good idea, since if user passes bufferevent with existing fd he
has some intention.
So we need to:
- use BEV_OPT_CLOSE_ON_FREE for default bufferevent_socket_new() (to
avoid manual shutdown/closee)
- drop getsockopt(SOL_SOCKET, SO_ERROR), since bufferevent already has
evutil_socket_finished_connecting_()
- drop supperior bufferevent_setfd(bev, -1) in
evhttp_connection_connect_()
Closes: #795
Refs: #875
---
http.c | 232 ++++++++++++++++++++++--------------------
include/event2/http.h | 6 +-
2 files changed, 124 insertions(+), 114 deletions(-)
diff --git a/http.c b/http.c
index 04f089bc..a6b3f6bb 100644
--- a/http.c
+++ b/http.c
@@ -634,6 +634,91 @@ evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req)
}
}
+/**
+ Replaces the file descriptor on which the bufferevent operates.
+ Not supported for all bufferevent types.
+
+ Unlike bufferevent_setfd() it will close previous file descriptor (if any).
+
+ @param bufev the bufferevent object for which to change the file descriptor
+ @param fd the file descriptor to operate on
+*/
+static int
+bufferevent_replacefd(struct bufferevent *bev, evutil_socket_t fd)
+{
+ union bufferevent_ctrl_data d;
+ int err = -1;
+ evutil_socket_t old_fd = EVUTIL_INVALID_SOCKET;
+
+ BEV_LOCK(bev);
+ if (bev->be_ops->ctrl) {
+ err = bev->be_ops->ctrl(bev, BEV_CTRL_GET_FD, &d);
+ if (!err) {
+ old_fd = d.fd;
+ if (old_fd != EVUTIL_INVALID_SOCKET) {
+ err = evutil_closesocket(old_fd);
+ }
+ }
+ if (!err) {
+ d.fd = fd;
+ err = bev->be_ops->ctrl(bev, BEV_CTRL_SET_FD, &d);
+ }
+ }
+ if (err)
+ event_debug(("%s: cannot replace fd for %p from "EV_SOCK_FMT" to "EV_SOCK_FMT, __func__, bev, old_fd, fd));
+ BEV_UNLOCK(bev);
+
+ return err;
+}
+
+/** Hard-reset our connection state
+ *
+ * This will:
+ * - reset fd
+ * - clears out buffers
+ * - call closecb
+ */
+static void
+evhttp_connection_reset_hard_(struct evhttp_connection *evcon)
+{
+ struct evbuffer *tmp;
+ int err;
+
+ bufferevent_setcb(evcon->bufev, NULL, NULL, NULL, NULL);
+
+ /* XXXX This is not actually an optimal fix. Instead we ought to have
+ an API for "stop connecting", or use bufferevent_replacefd to turn off
+ connecting. But for Libevent 2.0, this seems like a minimal change
+ least likely to disrupt the rest of the bufferevent and http code.
+
+ Why is this here? If the fd is set in the bufferevent, and the
+ bufferevent is connecting, then you can't actually stop the
+ bufferevent from trying to connect with bufferevent_disable(). The
+ connect will never trigger, since we close the fd, but the timeout
+ might. That caused an assertion failure in evhttp_connection_fail_.
+ */
+ bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE);
+
+ /* inform interested parties about connection close */
+ if (evhttp_connected(evcon) && evcon->closecb != NULL)
+ (*evcon->closecb)(evcon, evcon->closecb_arg);
+
+ /** FIXME: manipulating with fd is unwanted */
+ err = bufferevent_replacefd(evcon->bufev, -1);
+ EVUTIL_ASSERT(!err && "setfd");
+
+ /* we need to clean up any buffered data */
+ tmp = bufferevent_get_output(evcon->bufev);
+ err = evbuffer_drain(tmp, -1);
+ EVUTIL_ASSERT(!err && "drain output");
+ tmp = bufferevent_get_input(evcon->bufev);
+ err = evbuffer_drain(tmp, -1);
+ EVUTIL_ASSERT(!err && "drain input");
+
+ evcon->flags &= ~EVHTTP_CON_READING_ERROR;
+ evcon->state = EVCON_DISCONNECTED;
+}
+
void
evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon,
ev_ssize_t new_max_headers_size)
@@ -777,7 +862,7 @@ evhttp_connection_fail_(struct evhttp_connection *evcon,
evhttp_request_free_(evcon, req);
/* reset the connection */
- evhttp_connection_reset_(evcon);
+ evhttp_connection_reset_hard_(evcon);
/* We are trying the next request that was queued on us */
if (TAILQ_FIRST(&evcon->requests) != NULL)
@@ -837,7 +922,7 @@ evhttp_connection_done(struct evhttp_connection *evcon)
/* check if we got asked to close the connection */
if (need_close)
- evhttp_connection_reset_(evcon);
+ evhttp_connection_reset_hard_(evcon);
if (TAILQ_FIRST(&evcon->requests) != NULL) {
/*
@@ -1171,7 +1256,7 @@ evhttp_read_cb(struct bufferevent *bufev, void *arg)
__func__, EV_SIZE_ARG(total_len)));
#endif
- evhttp_connection_reset_(evcon);
+ evhttp_connection_reset_hard_(evcon);
}
break;
case EVCON_DISCONNECTED:
@@ -1221,13 +1306,10 @@ void
evhttp_connection_free(struct evhttp_connection *evcon)
{
struct evhttp_request *req;
- int need_close = 0;
/* notify interested parties that this connection is going down */
- if (evcon->fd != -1) {
- if (evhttp_connected(evcon) && evcon->closecb != NULL)
- (*evcon->closecb)(evcon, evcon->closecb_arg);
- }
+ if (evhttp_connected(evcon) && evcon->closecb != NULL)
+ (*evcon->closecb)(evcon, evcon->closecb_arg);
/* remove all requests that might be queued on this
* connection. for server connections, this should be empty.
@@ -1252,20 +1334,9 @@ evhttp_connection_free(struct evhttp_connection *evcon)
&evcon->read_more_deferred_cb);
if (evcon->bufev != NULL) {
- need_close =
- !(bufferevent_get_options_(evcon->bufev) & BEV_OPT_CLOSE_ON_FREE);
- if (evcon->fd == -1)
- evcon->fd = bufferevent_getfd(evcon->bufev);
-
bufferevent_free(evcon->bufev);
}
- if (evcon->fd != -1) {
- shutdown(evcon->fd, EVUTIL_SHUT_WR);
- if (need_close)
- evutil_closesocket(evcon->fd);
- }
-
if (evcon->bind_address != NULL)
mm_free(evcon->bind_address);
@@ -1324,54 +1395,17 @@ evhttp_request_dispatch(struct evhttp_connection* evcon)
evhttp_write_buffer(evcon, evhttp_write_connectioncb, NULL);
}
-/* Reset our connection state: disables reading/writing, closes our fd (if
-* any), clears out buffers, and puts us in state DISCONNECTED. */
+/** Reset our connection state
+ *
+ * This will:
+ * - disables reading/writing
+ * - puts us in DISCONNECTED state
+ */
void
evhttp_connection_reset_(struct evhttp_connection *evcon)
{
- struct evbuffer *tmp;
- int err;
-
bufferevent_setcb(evcon->bufev, NULL, NULL, NULL, NULL);
-
- /* XXXX This is not actually an optimal fix. Instead we ought to have
- an API for "stop connecting", or use bufferevent_setfd to turn off
- connecting. But for Libevent 2.0, this seems like a minimal change
- least likely to disrupt the rest of the bufferevent and http code.
-
- Why is this here? If the fd is set in the bufferevent, and the
- bufferevent is connecting, then you can't actually stop the
- bufferevent from trying to connect with bufferevent_disable(). The
- connect will never trigger, since we close the fd, but the timeout
- might. That caused an assertion failure in evhttp_connection_fail_.
- */
- bufferevent_disable_hard_(evcon->bufev, EV_READ|EV_WRITE);
-
- if (evcon->fd == -1)
- evcon->fd = bufferevent_getfd(evcon->bufev);
-
- if (evcon->fd != -1) {
- /* inform interested parties about connection close */
- if (evhttp_connected(evcon) && evcon->closecb != NULL)
- (*evcon->closecb)(evcon, evcon->closecb_arg);
-
- shutdown(evcon->fd, EVUTIL_SHUT_WR);
- evutil_closesocket(evcon->fd);
- evcon->fd = -1;
- }
- err = bufferevent_setfd(evcon->bufev, -1);
- EVUTIL_ASSERT(!err && "setfd");
-
- /* we need to clean up any buffered data */
- tmp = bufferevent_get_output(evcon->bufev);
- err = evbuffer_drain(tmp, -1);
- EVUTIL_ASSERT(!err && "drain output");
- tmp = bufferevent_get_input(evcon->bufev);
- err = evbuffer_drain(tmp, -1);
- EVUTIL_ASSERT(!err && "drain input");
-
evcon->flags &= ~EVHTTP_CON_READING_ERROR;
-
evcon->state = EVCON_DISCONNECTED;
}
@@ -1403,7 +1437,8 @@ evhttp_connection_cb_cleanup(struct evhttp_connection *evcon)
{
struct evcon_requestq requests;
- evhttp_connection_reset_(evcon);
+ evhttp_connection_reset_hard_(evcon);
+
if (evcon->retry_max < 0 || evcon->retry_cnt < evcon->retry_max) {
struct timeval tv_retry = evcon->initial_retry_timeout;
int i;
@@ -1481,16 +1516,13 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
struct evhttp_connection *evcon = arg;
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
- if (evcon->fd == -1)
- evcon->fd = bufferevent_getfd(bufev);
-
switch (evcon->state) {
case EVCON_CONNECTING:
if (what & BEV_EVENT_TIMEOUT) {
event_debug(("%s: connection timeout for \"%s:%d\" on "
EV_SOCK_FMT,
__func__, evcon->address, evcon->port,
- EV_SOCK_ARG(evcon->fd)));
+ EV_SOCK_ARG(bufferevent_getfd(bufev))));
evhttp_connection_cb_cleanup(evcon);
return;
}
@@ -1526,7 +1558,7 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
* disconnected.
*/
EVUTIL_ASSERT(evcon->state == EVCON_IDLE);
- evhttp_connection_reset_(evcon);
+ evhttp_connection_reset_hard_(evcon);
/*
* If we have no more requests that need completion
@@ -1572,11 +1604,6 @@ static void
evhttp_connection_cb(struct bufferevent *bufev, short what, void *arg)
{
struct evhttp_connection *evcon = arg;
- int error;
- ev_socklen_t errsz = sizeof(error);
-
- if (evcon->fd == -1)
- evcon->fd = bufferevent_getfd(bufev);
if (!(what & BEV_EVENT_CONNECTED)) {
/* some operating systems return ECONNREFUSED immediately
@@ -1591,34 +1618,10 @@ evhttp_connection_cb(struct bufferevent *bufev, short what, void *arg)
return;
}
- if (evcon->fd == -1) {
- event_debug(("%s: bufferevent_getfd returned -1",
- __func__));
- goto cleanup;
- }
-
- /* Check if the connection completed */
- if (getsockopt(evcon->fd, SOL_SOCKET, SO_ERROR, (void*)&error,
- &errsz) == -1) {
- event_debug(("%s: getsockopt for \"%s:%d\" on "EV_SOCK_FMT,
- __func__, evcon->address, evcon->port,
- EV_SOCK_ARG(evcon->fd)));
- goto cleanup;
- }
-
- if (error) {
- event_debug(("%s: connect failed for \"%s:%d\" on "
- EV_SOCK_FMT": %s",
- __func__, evcon->address, evcon->port,
- EV_SOCK_ARG(evcon->fd),
- evutil_socket_error_to_string(error)));
- goto cleanup;
- }
-
/* We are connected to the server now */
event_debug(("%s: connected to \"%s:%d\" on "EV_SOCK_FMT"\n",
__func__, evcon->address, evcon->port,
- EV_SOCK_ARG(evcon->fd)));
+ EV_SOCK_ARG(bufferevent_getfd(bufev))));
/* Reset the retry count as we were successful in connecting */
evcon->retry_cnt = 0;
@@ -2280,7 +2283,7 @@ evhttp_read_firstline(struct evhttp_connection *evcon,
if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) {
/* Error while reading, terminate */
event_debug(("%s: bad header lines on "EV_SOCK_FMT"\n",
- __func__, EV_SOCK_ARG(evcon->fd)));
+ __func__, EV_SOCK_ARG(bufferevent_getfd(evcon->bufev))));
evhttp_connection_fail_(evcon, EVREQ_HTTP_INVALID_HEADER);
return;
} else if (res == MORE_DATA_EXPECTED) {
@@ -2297,7 +2300,7 @@ evhttp_read_header(struct evhttp_connection *evcon,
struct evhttp_request *req)
{
enum message_read_status res;
- evutil_socket_t fd = evcon->fd;
+ evutil_socket_t fd = bufferevent_getfd(evcon->bufev);
res = evhttp_parse_headers_(req, bufferevent_get_input(evcon->bufev));
if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) {
@@ -2388,7 +2391,6 @@ evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_bas
goto error;
}
- evcon->fd = -1;
evcon->port = port;
evcon->max_headers_size = EV_SIZE_MAX;
@@ -2403,7 +2405,7 @@ evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_bas
}
if (bev == NULL) {
- if (!(bev = bufferevent_socket_new(base, -1, 0))) {
+ if (!(bev = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE))) {
event_warn("%s: bufferevent_socket_new failed", __func__);
goto error;
}
@@ -2571,24 +2573,30 @@ evhttp_connection_connect_(struct evhttp_connection *evcon)
if (evcon->state == EVCON_CONNECTING)
return (0);
+ /* Do not do hard reset, since this will reset the fd, but someone may
+ * change some options for it (i.e. setsockopt(), #875)
+ *
+ * However don't think that this options will be preserved for all
+ * connection lifetime, they will be reseted in the following cases:
+ * - evhttp_connection_set_local_address()
+ * - evhttp_connection_set_local_port()
+ * - evhttp_connection_set_retries()
+ * */
evhttp_connection_reset_(evcon);
EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING));
evcon->flags |= EVHTTP_CON_OUTGOING;
if (evcon->bind_address || evcon->bind_port) {
- evcon->fd = bind_socket(
- evcon->bind_address, evcon->bind_port, 0 /*reuse*/);
- if (evcon->fd == -1) {
+ int fd = bind_socket(evcon->bind_address, evcon->bind_port,
+ 0 /*reuse*/);
+ if (fd == -1) {
event_debug(("%s: failed to bind to \"%s\"",
__func__, evcon->bind_address));
return (-1);
}
- if (bufferevent_setfd(evcon->bufev, evcon->fd))
- return (-1);
- } else {
- if (bufferevent_setfd(evcon->bufev, -1))
+ if (bufferevent_replacefd(evcon->bufev, fd))
return (-1);
}
@@ -2625,7 +2633,7 @@ evhttp_connection_connect_(struct evhttp_connection *evcon)
if (ret < 0) {
evcon->state = old_state;
- event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed",
+ event_sock_warn(bufferevent_getfd(evcon->bufev), "%s: connection to \"%s\" failed",
__func__, evcon->address);
/* some operating systems return ECONNREFUSED immediately
* when connecting to a local address. the cleanup is going
@@ -4265,9 +4273,7 @@ evhttp_get_request_connection(
evcon->flags |= EVHTTP_CON_INCOMING;
evcon->state = EVCON_READING_FIRSTLINE;
- evcon->fd = fd;
-
- if (bufferevent_setfd(evcon->bufev, fd))
+ if (bufferevent_replacefd(evcon->bufev, fd))
goto err;
if (bufferevent_enable(evcon->bufev, EV_READ))
goto err;
diff --git a/include/event2/http.h b/include/event2/http.h
index 2a41303e..90f4cf9a 100644
--- a/include/event2/http.h
+++ b/include/event2/http.h
@@ -721,7 +721,11 @@ void evhttp_connection_free(struct evhttp_connection *evcon);
EVENT2_EXPORT_SYMBOL
void evhttp_connection_free_on_completion(struct evhttp_connection *evcon);
-/** sets the ip address from which http connections are made */
+/** Sets the IP address from which http connections are made
+ *
+ * Note this resets internal bufferevent fd, so any options that had been
+ * installed will be flushed.
+ */
EVENT2_EXPORT_SYMBOL
void evhttp_connection_set_local_address(struct evhttp_connection *evcon,
const char *address);
--
2.46.0

@ -0,0 +1,502 @@
diff --git a/event_rpcgen.py b/event_rpcgen.py
index 9baf730..2004090 100755
--- a/event_rpcgen.py
+++ b/event_rpcgen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
#
# Copyright (c) 2005-2007 Niels Provos <provos@citi.umich.edu>
# Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
@@ -36,10 +36,10 @@ QUIETLY = 0
def declare(s):
if not QUIETLY:
- print s
+ print(s)
def TranslateList(mylist, mydict):
- return map(lambda x: x % mydict, mylist)
+ return [x % mydict for x in mylist]
# Exception class for parse errors
class RpcGenError(Exception):
@@ -57,7 +57,7 @@ class Struct:
declare(' Created struct: %s' % name)
def AddEntry(self, entry):
- if self._tags.has_key(entry.Tag()):
+ if entry.Tag() in self._tags:
raise RpcGenError(
'Entry "%s" duplicates tag number %d from "%s" '
'around line %d' % (entry.Name(), entry.Tag(),
@@ -78,7 +78,7 @@ class Struct:
def PrintIndented(self, file, ident, code):
"""Takes an array, add indentation to each entry and prints it."""
for entry in code:
- print >>file, '%s%s' % (ident, entry)
+ file.write('%s%s\n' % (ident, entry))
class StructCCode(Struct):
""" Knows how to generate C code for a struct """
@@ -88,20 +88,19 @@ class StructCCode(Struct):
def PrintTags(self, file):
"""Prints the tag definitions for a structure."""
- print >>file, '/* Tag definition for %s */' % self._name
- print >>file, 'enum %s_ {' % self._name.lower()
+ file.write('/* Tag definition for %s */\n' % self._name)
+ file.write('enum %s_ {\n' % self._name.lower())
for entry in self._entries:
- print >>file, ' %s=%d,' % (self.EntryTagName(entry),
- entry.Tag())
- print >>file, ' %s_MAX_TAGS' % (self._name.upper())
- print >>file, '};\n'
+ file.write(' %s=%d,\n' % (self.EntryTagName(entry), entry.Tag()))
+ file.write(' %s_MAX_TAGS\n' % (self._name.upper()))
+ file.write('};\n\n')
def PrintForwardDeclaration(self, file):
- print >>file, 'struct %s;' % self._name
+ file.write('struct %s;\n' % self._name)
def PrintDeclaration(self, file):
- print >>file, '/* Structure declaration for %s */' % self._name
- print >>file, 'struct %s_access_ {' % self._name
+ file.write('/* Structure declaration for %s */\n' % self._name)
+ file.write('struct %s_access_ {\n' % self._name)
for entry in self._entries:
dcl = entry.AssignDeclaration('(*%s_assign)' % entry.Name())
dcl.extend(
@@ -110,20 +109,19 @@ class StructCCode(Struct):
dcl.extend(
entry.AddDeclaration('(*%s_add)' % entry.Name()))
self.PrintIndented(file, ' ', dcl)
- print >>file, '};\n'
+ file.write('};\n\n')
- print >>file, 'struct %s {' % self._name
- print >>file, ' struct %s_access_ *base;\n' % self._name
+ file.write('struct %s {\n' % self._name)
+ file.write(' struct %s_access_ *base;\n\n' % self._name)
for entry in self._entries:
dcl = entry.Declaration()
self.PrintIndented(file, ' ', dcl)
- print >>file, ''
+ file.write('\n')
for entry in self._entries:
- print >>file, ' ev_uint8_t %s_set;' % entry.Name()
- print >>file, '};\n'
+ file.write(' ev_uint8_t %s_set;\n' % entry.Name())
+ file.write('};\n\n')
- print >>file, \
-"""struct %(name)s *%(name)s_new(void);
+ file.write("""struct %(name)s *%(name)s_new(void);
struct %(name)s *%(name)s_new_with_arg(void *);
void %(name)s_free(struct %(name)s *);
void %(name)s_clear(struct %(name)s *);
@@ -133,7 +131,7 @@ int %(name)s_complete(struct %(name)s *);
void evtag_marshal_%(name)s(struct evbuffer *, ev_uint32_t,
const struct %(name)s *);
int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
- struct %(name)s *);""" % { 'name' : self._name }
+ struct %(name)s *);\n""" % { 'name' : self._name })
# Write a setting function of every variable
@@ -146,22 +144,21 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
self.PrintIndented(file, '', entry.AddDeclaration(
entry.AddFuncName()))
- print >>file, '/* --- %s done --- */\n' % self._name
+ file.write('/* --- %s done --- */\n\n' % self._name)
def PrintCode(self, file):
- print >>file, ('/*\n'
+ file.write(('/*\n'
' * Implementation of %s\n'
- ' */\n') % self._name
+ ' */\n\n') % self._name)
- print >>file, \
- 'static struct %(name)s_access_ %(name)s_base__ = {' % \
- { 'name' : self._name }
+ file.write('static struct %(name)s_access_ %(name)s_base__ = {\n' % \
+ { 'name' : self._name })
for entry in self._entries:
self.PrintIndented(file, ' ', entry.CodeBase())
- print >>file, '};\n'
+ file.write('};\n\n')
# Creation
- print >>file, (
+ file.write((
'struct %(name)s *\n'
'%(name)s_new(void)\n'
'{\n'
@@ -176,77 +173,77 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
' event_warn("%%s: malloc", __func__);\n'
' return (NULL);\n'
' }\n'
- ' tmp->base = &%(name)s_base__;\n') % { 'name' : self._name }
+ ' tmp->base = &%(name)s_base__;\n\n') % { 'name' : self._name })
for entry in self._entries:
self.PrintIndented(file, ' ', entry.CodeInitialize('tmp'))
- print >>file, ' tmp->%s_set = 0;\n' % entry.Name()
+ file.write(' tmp->%s_set = 0;\n\n' % entry.Name())
- print >>file, (
+ file.write((
' return (tmp);\n'
- '}\n')
+ '}\n\n'))
# Adding
for entry in self._entries:
if entry.Array():
self.PrintIndented(file, '', entry.CodeAdd())
- print >>file, ''
+ file.write('\n')
# Assigning
for entry in self._entries:
self.PrintIndented(file, '', entry.CodeAssign())
- print >>file, ''
+ file.write('\n')
# Getting
for entry in self._entries:
self.PrintIndented(file, '', entry.CodeGet())
- print >>file, ''
+ file.write('\n')
# Clearing
- print >>file, ( 'void\n'
+ file.write(( 'void\n'
'%(name)s_clear(struct %(name)s *tmp)\n'
'{'
- ) % { 'name' : self._name }
+ '\n') % { 'name' : self._name })
for entry in self._entries:
self.PrintIndented(file, ' ', entry.CodeClear('tmp'))
- print >>file, '}\n'
+ file.write('}\n\n')
# Freeing
- print >>file, ( 'void\n'
+ file.write(( 'void\n'
'%(name)s_free(struct %(name)s *tmp)\n'
'{'
- ) % { 'name' : self._name }
+ '\n') % { 'name' : self._name })
for entry in self._entries:
self.PrintIndented(file, ' ', entry.CodeFree('tmp'))
- print >>file, (' free(tmp);\n'
- '}\n')
+ file.write((' free(tmp);\n'
+ '}\n\n'))
# Marshaling
- print >>file, ('void\n'
+ file.write(('void\n'
'%(name)s_marshal(struct evbuffer *evbuf, '
'const struct %(name)s *tmp)'
- '{') % { 'name' : self._name }
+ '{\n') % { 'name' : self._name })
for entry in self._entries:
indent = ' '
# Optional entries do not have to be set
if entry.Optional():
indent += ' '
- print >>file, ' if (tmp->%s_set) {' % entry.Name()
+ file.write(' if (tmp->%s_set) {\n' % entry.Name())
self.PrintIndented(
file, indent,
entry.CodeMarshal('evbuf', self.EntryTagName(entry),
entry.GetVarName('tmp'),
entry.GetVarLen('tmp')))
if entry.Optional():
- print >>file, ' }'
+ file.write(' }\n')
- print >>file, '}\n'
+ file.write('}\n\n')
# Unmarshaling
- print >>file, ('int\n'
+ file.write(('int\n'
'%(name)s_unmarshal(struct %(name)s *tmp, '
' struct evbuffer *evbuf)\n'
'{\n'
@@ -255,14 +252,14 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
' if (evtag_peek(evbuf, &tag) == -1)\n'
' return (-1);\n'
' switch (tag) {\n'
- ) % { 'name' : self._name }
+ '\n') % { 'name' : self._name })
for entry in self._entries:
- print >>file, ' case %s:\n' % self.EntryTagName(entry)
+ file.write(' case %s:\n' % self.EntryTagName(entry))
if not entry.Array():
- print >>file, (
+ file.write((
' if (tmp->%s_set)\n'
' return (-1);'
- ) % (entry.Name())
+ '\n') % (entry.Name()))
self.PrintIndented(
file, ' ',
@@ -271,26 +268,26 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
entry.GetVarName('tmp'),
entry.GetVarLen('tmp')))
- print >>file, ( ' tmp->%s_set = 1;\n' % entry.Name() +
- ' break;\n' )
- print >>file, ( ' default:\n'
+ file.write(( ' tmp->%s_set = 1;\n' % entry.Name() +
+ ' break;\n' ))
+ file.write(( ' default:\n'
' return -1;\n'
' }\n'
- ' }\n' )
+ ' }\n\n' ))
# Check if it was decoded completely
- print >>file, ( ' if (%(name)s_complete(tmp) == -1)\n'
+ file.write(( ' if (%(name)s_complete(tmp) == -1)\n'
' return (-1);'
- ) % { 'name' : self._name }
+ '\n') % { 'name' : self._name })
# Successfully decoded
- print >>file, ( ' return (0);\n'
- '}\n')
+ file.write(( ' return (0);\n'
+ '}\n\n'))
# Checking if a structure has all the required data
- print >>file, (
+ file.write((
'int\n'
'%(name)s_complete(struct %(name)s *msg)\n'
- '{' ) % { 'name' : self._name }
+ '{\n' ) % { 'name' : self._name })
for entry in self._entries:
if not entry.Optional():
code = [
@@ -303,12 +300,12 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
self.PrintIndented(
file, ' ',
entry.CodeComplete('msg', entry.GetVarName('msg')))
- print >>file, (
+ file.write((
' return (0);\n'
- '}\n' )
+ '}\n\n' ))
# Complete message unmarshaling
- print >>file, (
+ file.write((
'int\n'
'evtag_unmarshal_%(name)s(struct evbuffer *evbuf, '
'ev_uint32_t need_tag, struct %(name)s *msg)\n'
@@ -330,10 +327,10 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
' error:\n'
' evbuffer_free(tmp);\n'
' return (res);\n'
- '}\n' ) % { 'name' : self._name }
+ '}\n\n' ) % { 'name' : self._name })
# Complete message marshaling
- print >>file, (
+ file.write((
'void\n'
'evtag_marshal_%(name)s(struct evbuffer *evbuf, ev_uint32_t tag, '
'const struct %(name)s *msg)\n'
@@ -343,7 +340,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
' %(name)s_marshal(buf_, msg);\n'
' evtag_marshal_buffer(evbuf, tag, buf_);\n '
' evbuffer_free(buf_);\n'
- '}\n' ) % { 'name' : self._name }
+ '}\n\n' ) % { 'name' : self._name })
class Entry:
def __init__(self, type, name, tag):
@@ -420,7 +417,7 @@ class Entry:
"optaddarg" :
self._optaddarg and ", const %s value" % self._ctype or ""
}
- for (k, v) in extradict.items():
+ for (k, v) in list(extradict.items()):
mapping[k] = v
return mapping
@@ -1127,7 +1124,7 @@ class EntryArray(Entry):
codearrayassign = self._entry.CodeArrayAssign(
'msg->%(name)s_data[off]' % self.GetTranslation(), 'value')
- code += map(lambda x: ' ' + x, codearrayassign)
+ code += [' ' + x for x in codearrayassign]
code += TranslateList([
' }',
@@ -1168,7 +1165,7 @@ class EntryArray(Entry):
code = TranslateList(code, self.GetTranslation())
- code += map(lambda x: ' ' + x, codearrayadd)
+ code += [' ' + x for x in codearrayadd]
code += TranslateList([
' msg->%(name)s_set = 1;',
@@ -1196,7 +1193,7 @@ class EntryArray(Entry):
code = TranslateList(code, translate)
- code += map(lambda x: ' ' + x, tmp)
+ code += [' ' + x for x in tmp]
code += [
' }',
@@ -1261,7 +1258,7 @@ class EntryArray(Entry):
code = TranslateList(code, translate)
if codearrayfree:
- code += map(lambda x: ' ' + x, codearrayfree)
+ code += [' ' + x for x in codearrayfree]
code += [
' }' ]
@@ -1687,23 +1684,23 @@ class CommandLine:
declare('... creating "%s"' % header_file)
header_fp = open(header_file, 'w')
- print >>header_fp, factory.HeaderPreamble(filename)
+ header_fp.write(factory.HeaderPreamble(filename))
# Create forward declarations: allows other structs to reference
# each other
for entry in entities:
entry.PrintForwardDeclaration(header_fp)
- print >>header_fp, ''
+ header_fp.write('\n')
for entry in entities:
entry.PrintTags(header_fp)
entry.PrintDeclaration(header_fp)
- print >>header_fp, factory.HeaderPostamble(filename)
+ header_fp.write(factory.HeaderPostamble(filename))
header_fp.close()
declare('... creating "%s"' % impl_file)
impl_fp = open(impl_file, 'w')
- print >>impl_fp, factory.BodyPreamble(filename, header_file)
+ impl_fp.write(factory.BodyPreamble(filename, header_file))
for entry in entities:
entry.PrintCode(impl_fp)
impl_fp.close()
@@ -1713,16 +1710,16 @@ if __name__ == '__main__':
CommandLine(sys.argv).run()
sys.exit(0)
- except RpcGenError, e:
- print >>sys.stderr, e
+ except RpcGenError as e:
+ sys.stderr.write(e)
sys.exit(1)
- except EnvironmentError, e:
+ except EnvironmentError as e:
if e.filename and e.strerror:
- print >>sys.stderr, "%s: %s" % (e.filename, e.strerror)
+ sys.stderr.write("%s: %s" % (e.filename, e.strerror))
sys.exit(1)
elif e.strerror:
- print >> sys.stderr, e.strerror
+ sys.stderr.write(e.strerror)
sys.exit(1)
else:
raise
diff --git a/test/check-dumpevents.py b/test/check-dumpevents.py
index 16fe9bc..3e1df30 100755
--- a/test/check-dumpevents.py
+++ b/test/check-dumpevents.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
#
# Post-process the output of test-dumpevents and check it for correctness.
#
@@ -15,12 +15,12 @@ try:
got_inserted_pos = text.index("Inserted events:\n")
got_active_pos = text.index("Active events:\n")
except ValueError:
- print >>sys.stderr, "Missing expected dividing line in dumpevents output"
+ sys.stderr.write("Missing expected dividing line in dumpevents output")
sys.exit(1)
if not (expect_inserted_pos < expect_active_pos <
got_inserted_pos < got_active_pos):
- print >>sys.stderr, "Sections out of order in dumpevents output"
+ sys.stderr.write("Sections out of order in dumpevents output")
sys.exit(1)
now,T= text[1].split()
@@ -45,10 +45,10 @@ cleaned_inserted = set( pat.sub(replace_time, s) for s in got_inserted
if "Internal" not in s)
if cleaned_inserted != want_inserted:
- print >>sys.stderr, "Inserted event lists were not as expected!"
+ sys.stderr.write("Inserted event lists were not as expected!")
sys.exit(1)
if set(got_active) != set(want_active):
- print >>sys.stderr, "Active event lists were not as expected!"
+ sys.stderr.write("Active event lists were not as expected!")
sys.exit(1)
diff --git a/test/rpcgen_wrapper.sh b/test/rpcgen_wrapper.sh
index aaa0303..fe582d5 100755
--- a/test/rpcgen_wrapper.sh
+++ b/test/rpcgen_wrapper.sh
@@ -25,19 +25,10 @@ exit_failed() {
echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2
exit 1
}
-
-if [ -x /usr/bin/python2 ] ; then
- PYTHON2=/usr/bin/python2
-elif [ "x`which python2`" != x ] ; then
- PYTHON2=python2
-else
- PYTHON2=python
-fi
-
srcdir=$1
srcdir=${srcdir:-.}
-${PYTHON2} ${srcdir}/../event_rpcgen.py --quiet ${srcdir}/regress.rpc \
+${srcdir}/../event_rpcgen.py --quiet ${srcdir}/regress.rpc \
test/regress.gen.h test/regress.gen.c
case "$?" in
diff --git a/test/test.sh b/test/test.sh
index dd3d986..8a76529 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -82,8 +82,8 @@ run_tests () {
fi
done
announce_n " test-dumpevents: "
- if python2 -c 'import sys; assert(sys.version_info >= (2, 4))' 2>/dev/null && test -f $TEST_SRC_DIR/check-dumpevents.py; then
- if $TEST_DIR/test-dumpevents | python2 $TEST_SRC_DIR/check-dumpevents.py >> "$TEST_OUTPUT_FILE" ;
+ if python -c 'import sys; assert(sys.version_info >= (2, 4))' 2>/dev/null && test -f $TEST_SRC_DIR/check-dumpevents.py; then
+ if $TEST_DIR/test-dumpevents | $TEST_SRC_DIR/check-dumpevents.py >> "$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else

@ -1,8 +1,8 @@
%global develdocdir %{_docdir}/%{name}-devel
Name: libevent
Version: 2.1.12
Release: 8%{?dist}
Version: 2.1.8
Release: 5%{?dist}
Summary: Abstract asynchronous event notification library
# arc4random.c, which is used in build, is ISC. The rest is BSD.
@ -10,10 +10,6 @@ License: BSD and ISC
URL: http://libevent.org/
Source0: https://github.com/libevent/libevent/releases/download/release-%{version}-stable/libevent-%{version}-stable.tar.gz
BuildRequires: make
BuildRequires: gcc
# Needed for ./autogen.sh:
BuildRequires: automake libtool
%if ! 0%{?_module_build}
BuildRequires: doxygen
%endif
@ -22,20 +18,9 @@ BuildRequires: python3-devel
# Disable network tests
Patch01: libevent-nonettests.patch
# Upstream patch:
Patch02: 0001-build-do-not-try-install-doxygen-man-pages-if-they-w.patch
# Upstream patch:
Patch03: 0001-build-add-doxygen-to-all.patch
# Temporary downstream change: revert a problematic upstream change
# until Transmission is fixed. Please drop the patch when the Transmission
# issue is fixed.
# https://github.com/transmission/transmission/issues/1437
Patch04: 0001-Revert-Fix-checking-return-value-of-the-evdns_base_r.patch
# 3 cherry-picked upstream commits adjusted to not break ABI
# https://github.com/libevent/libevent/commit/afa66ea
# https://github.com/libevent/libevent/commit/aea752b
# https://github.com/libevent/libevent/commit/2385638
Patch05: 0001-http-eliminate-redundant-bev-fd-manipulating-and-cac.patch
# Port the python scripts to Python 3
# Fixed upstream: https://github.com/libevent/libevent/commit/8b0aa7b36a3250fad4953f194c8a94ab25032583
Patch02: port-scripts-to-python3.patch
%description
The libevent API provides a mechanism to execute a callback function
@ -67,33 +52,24 @@ This package contains the development documentation for %{name}.
%prep
%setup -q -n libevent-%{version}-stable
%patch01 -p1 -b .nonettests
%patch02 -p1 -b .fix-install
%patch03 -p1 -b .fix-install-2
%patch04 -p1 -b .revert-problematic-change
%patch05 -p1 -b .fix-duplicate-fd-handling
%patch02 -p1 -b .py3port
pathfix.py -i %{__python3} -pn test/check-dumpevents.py \
event_rpcgen.py
%build
# We're patching doxygen.am, so regenerate the autotools stuff to be
# safe
./autogen.sh
%configure \
--disable-dependency-tracking --disable-static
make %{?_smp_mflags} all
%if ! 0%{?_module_build}
--enable-doxygen-doc \
# Create the docs
make doxygen
%endif
--disable-dependency-tracking --disable-static
%make_build all
%install
%make_install
make DESTDIR=$RPM_BUILD_ROOT install
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
# Maintain the Fedora-specific location of libevent documentation, at
# least for now
mv $RPM_BUILD_ROOT/%{_docdir}/%{name} $RPM_BUILD_ROOT/%{develdocdir}
# Fix multilib install of devel (bug #477685)
mv $RPM_BUILD_ROOT%{_includedir}/event2/event-config.h \
$RPM_BUILD_ROOT%{_includedir}/event2/event-config-%{__isa_bits}.h
@ -109,6 +85,12 @@ cat > $RPM_BUILD_ROOT%{_includedir}/event2/event-config.h << EOF
#endif
EOF
%if ! 0%{?_module_build}
mkdir -p $RPM_BUILD_ROOT/%{develdocdir}/html
(cd doxygen/html; \
install -p -m 644 *.* $RPM_BUILD_ROOT/%{develdocdir}/html)
%endif
mkdir -p $RPM_BUILD_ROOT/%{develdocdir}/sample
(cd sample; \
install -p -m 644 *.c *.am $RPM_BUILD_ROOT/%{develdocdir}/sample)
@ -154,62 +136,16 @@ mkdir -p $RPM_BUILD_ROOT/%{develdocdir}/sample
%doc %{develdocdir}/
%changelog
* Tue Aug 20 2024 Pavol Žáčik <pzacik@redhat.com> - 2.1.12-8
- Rework the patch from 2.1.12-7 to prevent ABI changes.
- Related: RHEL-26128
* Tue Aug 13 2024 Pavol Žáčik <pzacik@redhat.com> - 2.1.12-7
- Patch duplicate file descriptor manipulation
- Resolves: RHEL-26128
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 2.1.12-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.1.12-5
- Rebuilt for RHEL 9 BETA for openssl 3.0
Related: rhbz#1971065
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.1.12-4
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.12-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Sep 29 2020 Ondřej Lysoněk <olysonek@redhat.com> - 2.1.12-2
- Temporarily revert a problematic upstream change
* Mon Sep 14 2020 Ondřej Lysoněk <olysonek@redhat.com> - 2.1.12-1
- new version
- Resolves: rhbz#1713942
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.8-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 13 2020 Tom Stellard <tstellar@redhat.com> - 2.1.8-9
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.8-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Aug 15 2019 Ondřej Lysoněk <olysonek@redhat.com> - 2.1.8-7
- Port python scripts to Python 3
- Resolves: rhbz#1738022
- Resolves: rhbz#1655232
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Wed Oct 10 2018 Ondřej Lysoněk <olysonek@redhat.com> - 2.1.8-5
- Install documentation files to an unversioned directory
- Resolves: rhbz#1638032
* Mon Sep 03 2018 Ondřej Lysoněk <olysonek@redhat.com> - 2.1.8-4
- Corrected the License tag
- Resolves: rhbz#1624851
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Jul 19 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.1.8-3
- Port the python scripts to Python 3
* Thu Feb 15 2018 Steve Dickson <steved@redhat.com> - 2.1.8-2
- Explicitly express SONAME in the %%file section

Loading…
Cancel
Save