Skip to content

Commit

Permalink
use ev_uint16_t instead of unsigned short for port
Browse files Browse the repository at this point in the history
Like in `sockaddr_in` structure in /usr/include/netinet/in.h

@azat: convert all other users (bench, compat, ..) and tweak message
Fixes: libevent#178
Fixes: libevent#196
Refs: 6bf1ca7
Link: https://codereview.appspot.com/156040043/#msg4
  • Loading branch information
miniupnp authored and azat committed Oct 25, 2016
1 parent bcb990a commit e983712
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions http-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ struct evhttp_connection {
struct event retry_ev; /* for retrying connects */

char *bind_address; /* address to use for binding the src */
unsigned short bind_port; /* local port for binding the src */
ev_uint16_t bind_port; /* local port for binding the src */

char *address; /* address to connect to */
unsigned short port;
ev_uint16_t port;

size_t max_headers_size;
ev_uint64_t max_body_size;
Expand Down
8 changes: 4 additions & 4 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2342,14 +2342,14 @@ evhttp_read_header(struct evhttp_connection *evcon,
*/

struct evhttp_connection *
evhttp_connection_new(const char *address, unsigned short port)
evhttp_connection_new(const char *address, ev_uint16_t port)
{
return (evhttp_connection_base_new(NULL, NULL, address, port));
}

struct evhttp_connection *
evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev,
const char *address, unsigned short port)
const char *address, ev_uint16_t port)
{
struct evhttp_connection *evcon = NULL;

Expand Down Expand Up @@ -2425,7 +2425,7 @@ evhttp_connection_get_server(struct evhttp_connection *evcon)

struct evhttp_connection *
evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase,
const char *address, unsigned short port)
const char *address, ev_uint16_t port)
{
return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port);
}
Expand Down Expand Up @@ -3665,7 +3665,7 @@ evhttp_new(struct event_base *base)
*/

struct evhttp *
evhttp_start(const char *address, unsigned short port)
evhttp_start(const char *address, ev_uint16_t port)
{
struct evhttp *http = NULL;

Expand Down
4 changes: 2 additions & 2 deletions include/event2/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ enum evhttp_request_kind { EVHTTP_REQUEST, EVHTTP_RESPONSE };
*/
EVENT2_EXPORT_SYMBOL
struct evhttp_connection *evhttp_connection_base_bufferevent_new(
struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, unsigned short port);
struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port);

/**
* Return the bufferevent that an evhttp_connection is using.
Expand Down Expand Up @@ -641,7 +641,7 @@ void evhttp_request_free(struct evhttp_request *req);
EVENT2_EXPORT_SYMBOL
struct evhttp_connection *evhttp_connection_base_new(
struct event_base *base, struct evdns_base *dnsbase,
const char *address, unsigned short port);
const char *address, ev_uint16_t port);

/**
* Set family hint for DNS requests.
Expand Down
4 changes: 2 additions & 2 deletions include/event2/http_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
* @param port the port number on which the HTTP server should listen
* @return an struct evhttp object
*/
struct evhttp *evhttp_start(const char *address, unsigned short port);
struct evhttp *evhttp_start(const char *address, ev_uint16_t port);

/**
* A connection object that can be used to for making HTTP requests. The
Expand All @@ -68,7 +68,7 @@ struct evhttp *evhttp_start(const char *address, unsigned short port);
* @deprecated It does not allow an event base to be specified
*/
struct evhttp_connection *evhttp_connection_new(
const char *address, unsigned short port);
const char *address, ev_uint16_t port);

/**
* Associates an event base with the connection - can only be called
Expand Down
2 changes: 1 addition & 1 deletion sample/http-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ main(int argc, char **argv)
struct evhttp *http;
struct evhttp_bound_socket *handle;

unsigned short port = 0;
ev_uint16_t port = 0;
#ifdef _WIN32
WSADATA WSAData;
WSAStartup(0x101, &WSAData);
Expand Down
2 changes: 1 addition & 1 deletion test/bench_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ main(int argc, char **argv)
int i;
int c;
int use_iocp = 0;
unsigned short port = 8080;
ev_uint16_t port = 8080;
char *endptr = NULL;

#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion test/regress_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ http_setup(ev_uint16_t *pport, struct event_base *base, int mask)
#endif

static evutil_socket_t
http_connect(const char *address, unsigned short port)
http_connect(const char *address, ev_uint16_t port)
{
/* Stupid code for connecting */
struct evutil_addrinfo ai, *aitop;
Expand Down

0 comments on commit e983712

Please sign in to comment.