Skip to content

Commit 767ee2e

Browse files
committed
Merge bitcoin/bitcoin#23607: rpc: Pass const char* to evhttp_connection_get_peer for new libevent
c62d763 Necessary improvements to make configure work without libevent installed (Perlover) 091ccc3 The evhttp_connection_get_peer function from libevent changes the type of the second parameter. Fixing the problem. (Perlover) Pull request description: The second parameter of evhttp_connection_get_peer in libevent already has type as `const char **` The compilation of bitcoind with the fresh libevent occurs errors Details: bitcoin/bitcoin#23606 ACKs for top commit: laanwj: Code review ACK c62d763 luke-jr: tACK c62d763 Tree-SHA512: d1c8062d90bd0d55c582dae2c3a7e5ee1b6c7ca872bf4aa7fe6f45a52ac4a8f59464215759d961f8efde0efbeeade31b08daf9387d7d50d7622baa1c06992d83
2 parents 31db3dd + c62d763 commit 767ee2e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

configure.ac

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,26 @@ if test "$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench
15001500
fi
15011501
fi
15021502

1503+
if test x$use_libevent = xyes; then
1504+
TEMP_CXXFLAGS="$CXXFLAGS"
1505+
CXXFLAGS="$CXXFLAGS $EVENT_CFLAGS"
1506+
AC_MSG_CHECKING([if evhttp_connection_get_peer expects const char**])
1507+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508+
#include <cstdint>
1509+
#include <event2/http.h>
1510+
]], [[
1511+
evhttp_connection *conn = (evhttp_connection *)1;
1512+
const char *host;
1513+
uint16_t port;
1514+
1515+
evhttp_connection_get_peer(conn, &host, &port);
1516+
]])],
1517+
[ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR], [1], [Define this symbol if evhttp_connection_get_peer expects const char**]) ],
1518+
[ AC_MSG_RESULT([no]) ]
1519+
)
1520+
CXXFLAGS="$TEMP_CXXFLAGS"
1521+
fi
1522+
15031523
dnl QR Code encoding library check
15041524

15051525
if test "$use_qr" != "no"; then
@@ -1852,6 +1872,7 @@ AC_SUBST(HAVE_BUILTIN_PREFETCH)
18521872
AC_SUBST(HAVE_MM_PREFETCH)
18531873
AC_SUBST(HAVE_STRONG_GETAUXVAL)
18541874
AC_SUBST(ANDROID_ARCH)
1875+
AC_SUBST(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR)
18551876
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
18561877
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
18571878
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])

src/httpserver.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <httpserver.h>
610

711
#include <chainparamsbase.h>
@@ -597,7 +601,13 @@ CService HTTPRequest::GetPeer() const
597601
// evhttp retains ownership over returned address string
598602
const char* address = "";
599603
uint16_t port = 0;
604+
605+
#ifdef HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
606+
evhttp_connection_get_peer(con, &address, &port);
607+
#else
600608
evhttp_connection_get_peer(con, (char**)&address, &port);
609+
#endif // HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
610+
601611
peer = LookupNumeric(address, port);
602612
}
603613
return peer;

0 commit comments

Comments
 (0)