Comments (9)
Please try upstream/master.
from libevent.
You should not play with fd, especially on non upstream, since it does not includes #795
But I guess you can try to use evhttp_connection_base_bufferevent_new
, and pass bufferevent
with fd
that you configured.
from libevent.
You should not play with fd, especially on non upstream, since it does not includes #795
But I guess you can try to use
evhttp_connection_base_bufferevent_new
, and passbufferevent
withfd
that you configured.
I tried this, but it didn't work. So I found this when I searched again for why it didn't work.
evhttp_make_request(struct evhttp_connection *evcon,
struct evhttp_request *req,
enum evhttp_cmd_type type, const char *uri)
{
......
/* If the connection object is not connected; make it so */
if (!evhttp_connected(evcon)) {
int res = evhttp_connection_connect_(evcon);
/* evhttp_connection_fail_(), which is called through
* evhttp_connection_connect_(), assumes that req lies in
* evcon->requests. Thus, enqueue the request in advance and
* remove it in the error case. */
if (res != 0)
......
In evhttp_make_request
, the evhttp_connection
I passed in must be a link that is not transmitting data, so when this function executes to if (!evhttp_connected(evcon))
, I go into it.
int
evhttp_connection_connect_(struct evhttp_connection *evcon)
{
......
// No matter whether the judgment is successful or not, the bufferevent fd in the evcon is updated.
if (evcon->bind_address || evcon->bind_port) {
evcon->fd = bind_socket(
evcon->bind_address, evcon->bind_port, 0 /*reuse*/);
if (evcon->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))
return (-1);
}
......
But in the next evhttp_connection_connect_(evcon)
, no matter what I do, it will overwrite the fd
in the bufferevent
I passed in the evhttp_connection_base_bufferevent_new
.
So my pre-configured fd is not used in the actual connection.
from libevent.
A guess for the foregoing implementation manner is as follows: The user-defined fd
may fail to meet the requirements of the EVHTTP due to insufficient parameters. but the fd
can be modified by the user. Therefore, except for the FDs that are being connected, in other cases, the fd
does not meet the requirements, you need to create an fd
that meets the evhttp running configuration. You can find many places for configuring the FD in the evhttp_connection_connect_
.
So I would prefer to add option configurations to the fd
that has not yet established a connection in a possible location, rather than letting the user customize the fd
for use.
from libevent.
Which version of the sources you are referring to?
} else {
if (bufferevent_setfd(evcon->bufev, -1))
return (-1);
}
There is no such code anymore -
Lines 2817 to 2828 in c9ec6aa
from libevent.
So I would prefer to add option configurations to the fd that has not yet established a connection in a possible location, rather than letting the user customize the fd for use
The problem with adding separate option for this is that there are too much possible options.
Plus if you create bufferevent by yourself it should work.
Also about your case, doesn't binding to the interface address (using evhttp_connection_set_local_address
) does not work to make outgoing connection via specific interface?
from libevent.
The 2.1.12-stable version I use
from libevent.
So I would prefer to add option configurations to the fd that has not yet established a connection in a possible location, rather than letting the user customize the fd for use
The problem with adding separate option for this is that there are too much possible options. Plus if you create bufferevent by yourself it should work.
Also about your case, doesn't binding to the interface address (using
evhttp_connection_set_local_address
) does not work to make outgoing connection via specific interface?
Using evhttp_connection_set_local_address
to bind the IP address of a specifiedinterface does not take effect. It cannot work on a specified interface.
from libevent.
The master branch solved my problem. Thanks.
from libevent.
Related Issues (20)
- Warnings reported by Infer HOT 2
- Bug in make_ws_frame (ws.c), bug in get_ws_frame (ws.c) HOT 1
- Suggest hash-pin GitHub Actions with sensitive permissions and a Dependency-Update-Tool HOT 8
- Which version is currently most suitable for libevent? HOT 2
- How to get the reqeust queue length of one evhttp_connection? HOT 1
- libevent debugging HOT 1
- [bug] Event activated by event_active on another thread may loss while event timeout HOT 4
- clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [sample/le-proxy] Error 1 HOT 1
- Fix MbedTLS and ZLIB for windows on CI HOT 1
- May bug in evhttp_connection_free_on_completion when the evhttp_connection fail to connect HOT 2
- Security advisory link is broken HOT 2
- find_dependency for MBedTLS failed for LibeventConfig.cmake HOT 1
- Test Failure and Warnings in http/bad_request under SELECT Event Mechanism on Raspberry Pi HOT 2
- install DESTINATIONs inconsistent.
- How to implement a websocket client? HOT 6
- bufferevent_write does not immediately write data to the socket HOT 4
- Use checksec to scan the libevent_pthreads-2.1.so.7.0.1 file FORTIFY item is 'No' HOT 5
- How to deal with bufferevent pointer when used externally? HOT 5
- Upgrading libevent based TCP server implementation from commit id 665d79f1 to ec8d7a5a results in random crashes HOT 5
- evbuffer use after free HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libevent.