| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Libevent
Revision: 948
Author: nprovos
Date: 16 Nov 2008 18:22:14
Changes:Allow setting of local port for evhttp connections to support millions of connections from a single system; from Richard Jones
Files:| ... | ...@@ -127,6 +127,7 @@ | |
| 127 | 127 | o Do not remove Accept-Encoding header |
| 128 | 128 | o Clear the timer cache on entering the event loop; reported by Victor Chang |
| 129 | 129 | o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez |
| 130 | o Allow setting of local port for evhttp connections to support millions of connections from a single system; from Richard Jones. | |
| 130 | 131 | |
| 131 | 132 | Changes in 1.4.0: |
| 132 | 133 | o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. |
| ... | ...@@ -312,6 +312,10 @@ | |
| 312 | 312 | void evhttp_connection_set_local_address(struct evhttp_connection *evcon, |
| 313 | 313 | const char *address); |
| 314 | 314 | |
| 315 | /** sets the local port from which http connections are made */ | |
| 316 | void evhttp_connection_set_local_port(struct evhttp_connection *evcon, | |
| 317 | ev_uint16_t port); | |
| 318 | ||
| 315 | 319 | /** Sets the timeout for events related to this connection */ |
| 316 | 320 | void evhttp_connection_set_timeout(struct evhttp_connection *evcon, |
| 317 | 321 | int timeout_in_secs); |
| ... | ...@@ -65,6 +65,7 @@ | |
| 65 | 65 | struct event close_ev; |
| 66 | 66 | |
| 67 | 67 | char *bind_address; /* address to use for binding the src */ |
| 68 | u_short bind_port; /* local port for binding the src */ | |
| 68 | 69 | |
| 69 | 70 | char *address; /* address to connect to */ |
| 70 | 71 | u_short port; |
| ... | ...@@ -982,6 +982,13 @@ | |
| 982 | 982 | event_err(1, "%s: strdup", __func__); |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | void | |
| 986 | evhttp_connection_set_local_port(struct evhttp_connection *evcon, | |
| 987 | ev_uint16_t port) | |
| 988 | { | |
| 989 | assert(evcon->state == EVCON_DISCONNECTED); | |
| 990 | evcon->bind_port = port; | |
| 991 | } | |
| 985 | 992 | |
| 986 | 993 | static void |
| 987 | 994 | evhttp_request_dispatch(struct evhttp_connection* evcon) |
| ... | ...@@ -1761,7 +1768,8 @@ | |
| 1761 | 1768 | assert(!(evcon->flags & EVHTTP_CON_INCOMING)); |
| 1762 | 1769 | evcon->flags |= EVHTTP_CON_OUTGOING; |
| 1763 | 1770 | |
| 1764 | evcon->fd = bind_socket(evcon->bind_address, 0 /*port*/, 0 /*reuse*/); | |
| 1771 | evcon->fd = bind_socket( | |
| 1772 | evcon->bind_address, evcon->bind_port, 0 /*reuse*/); | |
| 1765 | 1773 | if (evcon->fd == -1) { |
| 1766 | 1774 | event_debug(("%s: failed to bind to \"%s\"", |
| 1767 | 1775 | __func__, evcon->bind_address)); |