Skip to content

The evhttp_connection_get_peer in the libevent has now const char** #23606

@Perlover

Description

@Perlover

The developers of the libevent library changed the parameter type, which now conflicts with your parameter conversion.

Expected behavior

A compilation without errors

Actual behavior

A compilation from sources (the current master branch today) shows to me a following errors:

  CXX      libbitcoin_server_a-httpserver.o
httpserver.cpp: In member function 'CService HTTPRequest::GetPeer() const':
httpserver.cpp:600:41: error: invalid conversion from 'char**' to 'const char**' [-fpermissive]
  600 |         evhttp_connection_get_peer(con, (char**)&address, &port);
      |                                         ^~~~~~~~~~~~~~~~
      |                                         |
      |                                         char**
In file included from ./support/events.h:12,
                 from httpserver.cpp:35:
/home/bitcoin/include/event2/http.h:981:18: note:   initializing argument 2 of 'void evhttp_connection_get_peer(evhttp_connection*, const char**, uint16_t*)'
  981 |     const char **address, ev_uint16_t *port);
      |     ~~~~~~~~~~~~~^~~~~~~

I researched the problem and found that the libevent which I use (from sources) has the related commit:

commit a18301a2bb160ff7c3ffaf5b7653c39ffe27b385
Author: Leon M. George <leon@georgemail.eu>
Date:   Tue Sep 8 15:38:16 2020 +0200

    http: const out address param to evcon_get_peer

diff --git a/http.c b/http.c
index abd255dc..8afb3600 100644
--- a/http.c
+++ b/http.c
@@ -2754,7 +2754,7 @@ evhttp_connection_set_closecb(struct evhttp_connection *evcon,
 
 void
 evhttp_connection_get_peer(struct evhttp_connection *evcon,
-    char **address, ev_uint16_t *port)
+    const char **address, ev_uint16_t *port)

To reproduce

May be you have to have a following software:

  • gcc v11.2.0
  • libevent with commit a18301a2bb160ff7c3ffaf5b7653c39ffe27b385 (Tue Sep 8 15:38:16 2020 +0200)
  • bitcoind current master branch (at 2021-11-26)

System information

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions