libevent: add version 2.0.21 to align with stx 3.0
[pti/rtp.git] / meta-stx / recipes-support / libevent / libevent / libevent-ipv6-client-socket.patch
1 ---
2  http.c |   25 ++++++++++++++++++-------
3  1 file changed, 18 insertions(+), 7 deletions(-)
4
5 --- a/http.c
6 +++ b/http.c
7 @@ -1325,6 +1325,9 @@ evhttp_error_cb(struct bufferevent *bufe
8         struct evhttp_connection *evcon = arg;
9         struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
10  
11 +       if (evcon->fd == -1)
12 +               evcon->fd = bufferevent_getfd(bufev);
13 +
14         switch (evcon->state) {
15         case EVCON_CONNECTING:
16                 if (what & BEV_EVENT_TIMEOUT) {
17 @@ -1390,6 +1393,9 @@ evhttp_connection_cb(struct bufferevent
18         int error;
19         ev_socklen_t errsz = sizeof(error);
20  
21 +       if (evcon->fd == -1)
22 +               evcon->fd = bufferevent_getfd(bufev);
23 +       
24         if (!(what & BEV_EVENT_CONNECTED)) {
25                 /* some operating systems return ECONNREFUSED immediately
26                  * when connecting to a local address.  the cleanup is going
27 @@ -2189,16 +2195,21 @@ evhttp_connection_connect(struct evhttp_
28         EVUTIL_ASSERT(!(evcon->flags & EVHTTP_CON_INCOMING));
29         evcon->flags |= EVHTTP_CON_OUTGOING;
30  
31 -       evcon->fd = bind_socket(
32 -               evcon->bind_address, evcon->bind_port, 0 /*reuse*/);
33 -       if (evcon->fd == -1) {
34 -               event_debug(("%s: failed to bind to \"%s\"",
35 -                       __func__, evcon->bind_address));
36 -               return (-1);
37 +       if (evcon->bind_address || evcon->bind_port) {
38 +               evcon->fd = bind_socket(
39 +                       evcon->bind_address, evcon->bind_port, 0 /*reuse*/);
40 +               if (evcon->fd == -1) {
41 +                       event_debug(("%s: failed to bind to \"%s\"",
42 +                               __func__, evcon->bind_address));
43 +                       return (-1);
44 +               }
45 +
46 +               bufferevent_setfd(evcon->bufev, evcon->fd);
47 +       } else {
48 +               bufferevent_setfd(evcon->bufev, -1);
49         }
50  
51         /* Set up a callback for successful connection setup */
52 -       bufferevent_setfd(evcon->bufev, evcon->fd);
53         bufferevent_setcb(evcon->bufev,
54             NULL /* evhttp_read_cb */,
55             NULL /* evhttp_write_cb */,