-
Notifications
You must be signed in to change notification settings - Fork 37.8k
rpc: Pass const char* to evhttp_connection_get_peer for new libevent #23607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I tested my compilation with last commit - everything was compiled! |
There were no upstream releases for now since the commit libevent/libevent@a18301a has been merged, right? |
@hebasto I used the master branch of libevent so this commit definitely merged. I am not sure about new releases of libevent with this commit. The old versions have |
I rebased these patches to the one patch and rebased on current master branch |
09c85b9
to
7e6efdc
Compare
src/httpserver.cpp
Outdated
@@ -597,7 +601,12 @@ CService HTTPRequest::GetPeer() const | |||
// evhttp retains ownership over returned address string | |||
const char* address = ""; | |||
uint16_t port = 0; | |||
evhttp_connection_get_peer(con, (char**)&address, &port); | |||
|
|||
#if HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align #
's to the left.
src/httpserver.cpp
Outdated
evhttp_connection_get_peer(con, (char**)&address, &port); | ||
|
||
#if HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR | ||
evhttp_connection_get_peer(con, (const char **)&address, &port); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is any cast still needed in this case? &address
is const char**
, right?
Please update the PR title to be clearer. "evhttp_connection_get_peer of libevent" is not a good summary of the change. |
My English is not native, I tried to give a more precise definition for this PR. I also applied the changes recommended by you and made a rebase relative to the current master branch. |
configure.ac
Outdated
@@ -1510,6 +1510,13 @@ if test x$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench | |||
fi | |||
fi | |||
|
|||
AC_MSG_CHECKING([for evhttp_connection_get_peer]) | |||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <event2/http.h>]], | |||
[[ evhttp_connection_get_peer((evhttp_connection*) nullptr,(const char**) nullptr,(uint16_t *) nullptr); ]])], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify valid arguments in case libevent eventually adds nonnull
attributes or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the macro AC_COMPILE_IF ELSE
only checks the possibility of compiling, not running the program. Therefore, I do not understand why to change the parameters as nullptr to any fictitious ones (as in your final example). By and large, I created the code using examples from the same configuration file as this one, for example:
...
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctime>]],
[[ gmtime_r((const time_t *) nullptr, (struct tm *) nullptr); ]])],
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If libevent some day marks the arguments as nonnull
, the compiler may error if nullptr
is passed
configure.ac
Outdated
@@ -1510,6 +1510,13 @@ if test x$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench | |||
fi | |||
fi | |||
|
|||
AC_MSG_CHECKING([for evhttp_connection_get_peer]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AC_MSG_CHECKING([for evhttp_connection_get_peer]) | |
AC_MSG_CHECKING([if evhttp_connection_get_peer expects const char *]) |
Also, please prepend your commit message with a shortish summary (~80 chars max, not a hard limit) and a blank line :) |
Further issues:
Suggested fix for these and prior issues: https://gist.github.com/luke-jr/f8df9d7173a3f673b82b4f0c26854807 |
There is such a code just above my code. Doesn't it guarantee that configure will stop before my code is executed? It seems to me that it is redundant to check the installation of libevent, if it is already checked above.
Is it really that important to use this complex construction with CXXFLAGS here? All 15 checks performed on github pass.
It's probably better for me to just replace the arguments with those used in libevent: uint16_t -> ev_uint16_t
|
If I understand your code correctly, then there will be no constants defined here and I will have to add additional |
…e of the second parameter. Fixing the problem.
@luke-jr, I applied several of your suggestions - description lines in |
Right now, your PR will still break on systems:
(Also note you should ideally not rebase unless there are conflicts) |
The check above only runs with that
If libevent is installed outside the default compiler include path, |
This is how other similar checks are currently done. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
@luke-jr , I did your suggestions in next commit. I hope that they will pass all the tests. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK c62d763
…e of the second parameter. Fixing the problem. Github-Pull: bitcoin#23607 Rebased-From: 091ccc3
Github-Pull: bitcoin#23607 Rebased-From: c62d763
Code review ACK c62d763 |
…eer 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#23606 ACKs for top commit: laanwj: Code review ACK c62d763 luke-jr: tACK c62d763 Tree-SHA512: d1c8062d90bd0d55c582dae2c3a7e5ee1b6c7ca872bf4aa7fe6f45a52ac4a8f59464215759d961f8efde0efbeeade31b08daf9387d7d50d7622baa1c06992d83
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: #23606