mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Replace users of "int fd" with "evutil_socket_t fd" in portable code
Remeber, win32 has a socket type that's actually a handle, so if there's a chance that code is run on win32, we can't use "int" as the socket type. This isn't a blind search-and-replace: sometimes an fd is really in fact for a file, and not a socket at all.
This commit is contained in:
parent
38b7b571c8
commit
c7cf6f0049
@ -92,10 +92,10 @@ void event_changelist_remove_all(struct event_changelist *changelist,
|
||||
void event_changelist_freemem(struct event_changelist *changelist);
|
||||
|
||||
/** Implementation of eventop_add that queues the event in a changelist. */
|
||||
int event_changelist_add(struct event_base *base, int fd, short old, short events,
|
||||
int event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p);
|
||||
/** Implementation of eventop_del that queues the event in a changelist. */
|
||||
int event_changelist_del(struct event_base *base, int fd, short old, short events,
|
||||
int event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p);
|
||||
|
||||
#endif
|
||||
|
2
event.c
2
event.c
@ -2420,7 +2420,7 @@ event_set_mem_functions(void *(*malloc_fn)(size_t sz),
|
||||
|
||||
#if defined(_EVENT_HAVE_EVENTFD) && defined(_EVENT_HAVE_SYS_EVENTFD_H)
|
||||
static void
|
||||
evthread_notify_drain_eventfd(int fd, short what, void *arg)
|
||||
evthread_notify_drain_eventfd(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
ev_uint64_t msg;
|
||||
|
||||
|
@ -77,7 +77,7 @@ void evmap_io_active(struct event_base *base, evutil_socket_t fd, short events);
|
||||
|
||||
int evmap_signal_add(struct event_base *base, int signum, struct event *ev);
|
||||
int evmap_signal_del(struct event_base *base, int signum, struct event *ev);
|
||||
void evmap_signal_active(struct event_base *base, int fd, int ncalls);
|
||||
void evmap_signal_active(struct event_base *base, evutil_socket_t fd, int ncalls);
|
||||
|
||||
void *evmap_io_get_fdinfo(struct event_io_map *ctx, evutil_socket_t fd);
|
||||
|
||||
|
4
evmap.c
4
evmap.c
@ -628,7 +628,7 @@ event_changelist_get_or_construct(struct event_changelist *changelist,
|
||||
}
|
||||
|
||||
int
|
||||
event_changelist_add(struct event_base *base, int fd, short old, short events,
|
||||
event_changelist_add(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p)
|
||||
{
|
||||
struct event_changelist *changelist = &base->changelist;
|
||||
@ -659,7 +659,7 @@ event_changelist_add(struct event_base *base, int fd, short old, short events,
|
||||
}
|
||||
|
||||
int
|
||||
event_changelist_del(struct event_base *base, int fd, short old, short events,
|
||||
event_changelist_del(struct event_base *base, evutil_socket_t fd, short old, short events,
|
||||
void *p)
|
||||
{
|
||||
struct event_changelist *changelist = &base->changelist;
|
||||
|
2
http.c
2
http.c
@ -1698,7 +1698,7 @@ evhttp_read_header(struct evhttp_connection *evcon,
|
||||
struct evhttp_request *req)
|
||||
{
|
||||
enum message_read_status res;
|
||||
int fd = evcon->fd;
|
||||
evutil_socket_t fd = evcon->fd;
|
||||
|
||||
res = evhttp_parse_headers(req, bufferevent_get_input(evcon->bufev));
|
||||
if (res == DATA_CORRUPTED || res == DATA_TOO_LONG) {
|
||||
|
@ -168,7 +168,7 @@ main(int c, char **v) {
|
||||
evdns_set_log_fn(logfn);
|
||||
|
||||
if (servertest) {
|
||||
int sock;
|
||||
evutil_socket_t sock;
|
||||
struct sockaddr_in my_addr;
|
||||
sock = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
evutil_make_socket_nonblocking(sock);
|
||||
|
@ -33,7 +33,7 @@
|
||||
int called = 0;
|
||||
|
||||
static void
|
||||
signal_cb(int fd, short event, void *arg)
|
||||
signal_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct event *signal = arg;
|
||||
|
||||
|
@ -62,7 +62,7 @@ static struct event *events;
|
||||
|
||||
|
||||
static void
|
||||
read_cb(int fd, short which, void *arg)
|
||||
read_cb(evutil_socket_t fd, short which, void *arg)
|
||||
{
|
||||
long idx = (long) arg, widx = idx + 1;
|
||||
u_char ch;
|
||||
|
@ -59,7 +59,7 @@ static int *pipes;
|
||||
static struct event *events;
|
||||
|
||||
static void
|
||||
read_cb(int fd, short which, void *arg)
|
||||
read_cb(evutil_socket_t fd, short which, void *arg)
|
||||
{
|
||||
char ch;
|
||||
long idx = (long) arg;
|
||||
|
@ -107,7 +107,7 @@ errorcb(struct bufferevent *b, short what, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
frob_socket(int sock)
|
||||
frob_socket(evutil_socket_t sock)
|
||||
{
|
||||
struct linger l;
|
||||
int one = 1;
|
||||
@ -121,7 +121,7 @@ frob_socket(int sock)
|
||||
static int
|
||||
launch_request(void)
|
||||
{
|
||||
int sock;
|
||||
evutil_socket_t sock;
|
||||
struct sockaddr_in sin;
|
||||
struct bufferevent *b;
|
||||
|
||||
|
@ -104,7 +104,7 @@ struct basic_cb_args
|
||||
};
|
||||
|
||||
static void
|
||||
simple_read_cb(int fd, short event, void *arg)
|
||||
simple_read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
@ -123,7 +123,7 @@ simple_read_cb(int fd, short event, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
basic_read_cb(int fd, short event, void *data)
|
||||
basic_read_cb(evutil_socket_t fd, short event, void *data)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
@ -157,12 +157,12 @@ basic_read_cb(int fd, short event, void *data)
|
||||
}
|
||||
|
||||
static void
|
||||
dummy_read_cb(int fd, short event, void *arg)
|
||||
dummy_read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
simple_write_cb(int fd, short event, void *arg)
|
||||
simple_write_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
int len;
|
||||
|
||||
@ -174,7 +174,7 @@ simple_write_cb(int fd, short event, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
multiple_write_cb(int fd, short event, void *arg)
|
||||
multiple_write_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct event *ev = arg;
|
||||
int len;
|
||||
@ -207,7 +207,7 @@ multiple_write_cb(int fd, short event, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
multiple_read_cb(int fd, short event, void *arg)
|
||||
multiple_read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct event *ev = arg;
|
||||
int len;
|
||||
@ -229,7 +229,7 @@ multiple_read_cb(int fd, short event, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
timeout_cb(int fd, short event, void *arg)
|
||||
timeout_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct timeval tv;
|
||||
int diff;
|
||||
@ -254,7 +254,7 @@ struct both {
|
||||
};
|
||||
|
||||
static void
|
||||
combined_read_cb(int fd, short event, void *arg)
|
||||
combined_read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct both *both = arg;
|
||||
char buf[128];
|
||||
@ -272,7 +272,7 @@ combined_read_cb(int fd, short event, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
combined_write_cb(int fd, short event, void *arg)
|
||||
combined_write_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct both *both = arg;
|
||||
char buf[128];
|
||||
@ -380,7 +380,7 @@ test_simplewrite(void)
|
||||
}
|
||||
|
||||
static void
|
||||
simpleread_multiple_cb(int fd, short event, void *arg)
|
||||
simpleread_multiple_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
if (++called == 2)
|
||||
test_ok = 1;
|
||||
@ -517,7 +517,7 @@ test_simpletimeout(void)
|
||||
}
|
||||
|
||||
static void
|
||||
periodic_timeout_cb(int fd, short event, void *arg)
|
||||
periodic_timeout_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
int *count = arg;
|
||||
|
||||
@ -556,14 +556,14 @@ struct persist_active_timeout_called {
|
||||
};
|
||||
|
||||
static void
|
||||
activate_cb(int fd, short event, void *arg)
|
||||
activate_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct event *ev = arg;
|
||||
event_active(ev, EV_READ, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
persist_active_timeout_cb(int fd, short event, void *arg)
|
||||
persist_active_timeout_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct persist_active_timeout_called *c = arg;
|
||||
if (c->n < 15) {
|
||||
@ -624,7 +624,7 @@ struct common_timeout_info {
|
||||
};
|
||||
|
||||
static void
|
||||
common_timeout_cb(int fd, short event, void *arg)
|
||||
common_timeout_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct common_timeout_info *ti = arg;
|
||||
++ti->count;
|
||||
@ -709,12 +709,12 @@ end:
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
static void signal_cb(int fd, short event, void *arg);
|
||||
static void signal_cb(evutil_socket_t fd, short event, void *arg);
|
||||
|
||||
extern struct event_base *current_base;
|
||||
|
||||
static void
|
||||
child_signal_cb(int fd, short event, void *arg)
|
||||
child_signal_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct timeval tv;
|
||||
int *pint = arg;
|
||||
@ -803,7 +803,7 @@ signal_cb_sa(int sig)
|
||||
}
|
||||
|
||||
static void
|
||||
signal_cb(int fd, short event, void *arg)
|
||||
signal_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct event *ev = arg;
|
||||
|
||||
@ -1055,7 +1055,7 @@ signal_cb_swp(int sig, short event, void *arg)
|
||||
event_loopexit(NULL);
|
||||
}
|
||||
static void
|
||||
timeout_cb_swp(int fd, short event, void *arg)
|
||||
timeout_cb_swp(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
if (called == -1) {
|
||||
struct timeval tv = {5, 0};
|
||||
@ -1261,14 +1261,14 @@ end:
|
||||
}
|
||||
|
||||
static void
|
||||
break_cb(int fd, short events, void *arg)
|
||||
break_cb(evutil_socket_t fd, short events, void *arg)
|
||||
{
|
||||
test_ok = 1;
|
||||
event_loopbreak();
|
||||
}
|
||||
|
||||
static void
|
||||
fail_cb(int fd, short events, void *arg)
|
||||
fail_cb(evutil_socket_t fd, short events, void *arg)
|
||||
{
|
||||
test_ok = 0;
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ end:
|
||||
|
||||
static struct event *readd_test_event_last_added = NULL;
|
||||
static void
|
||||
re_add_read_cb(int fd, short event, void *arg)
|
||||
re_add_read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
@ -1362,7 +1362,7 @@ struct test_pri_event {
|
||||
};
|
||||
|
||||
static void
|
||||
test_priorities_cb(int fd, short what, void *arg)
|
||||
test_priorities_cb(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct test_pri_event *pri = arg;
|
||||
struct timeval tv;
|
||||
@ -1440,7 +1440,7 @@ test_priorities(void)
|
||||
|
||||
|
||||
static void
|
||||
test_multiple_cb(int fd, short event, void *arg)
|
||||
test_multiple_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
if (event & EV_READ)
|
||||
test_ok |= 1;
|
||||
@ -1477,7 +1477,7 @@ int evtag_encode_tag(struct evbuffer *evbuf, ev_uint32_t number);
|
||||
int evtag_decode_tag(ev_uint32_t *pnumber, struct evbuffer *evbuf);
|
||||
|
||||
static void
|
||||
read_once_cb(int fd, short event, void *arg)
|
||||
read_once_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
@ -1845,7 +1845,7 @@ end:
|
||||
}
|
||||
|
||||
static void
|
||||
read_called_once_cb(int fd, short event, void *arg)
|
||||
read_called_once_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
tt_int_op(event, ==, EV_READ);
|
||||
called += 1;
|
||||
@ -1854,7 +1854,7 @@ end:
|
||||
}
|
||||
|
||||
static void
|
||||
timeout_called_once_cb(int fd, short event, void *arg)
|
||||
timeout_called_once_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
tt_int_op(event, ==, EV_TIMEOUT);
|
||||
called += 100;
|
||||
@ -2003,7 +2003,7 @@ end:
|
||||
#endif
|
||||
|
||||
static void
|
||||
many_event_cb(int fd, short event, void *arg)
|
||||
many_event_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
int *calledp = arg;
|
||||
*calledp += 1;
|
||||
|
@ -52,7 +52,7 @@
|
||||
static int was_et = 0;
|
||||
|
||||
static void
|
||||
read_cb(int fd, short event, void *arg)
|
||||
read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
char buf;
|
||||
int len;
|
||||
|
@ -127,7 +127,7 @@ http_connect(const char *address, u_short port)
|
||||
#endif
|
||||
struct sockaddr *sa;
|
||||
int slen;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
|
||||
#ifdef WIN32
|
||||
if (!(he = gethostbyname(address))) {
|
||||
@ -314,7 +314,7 @@ http_chunked_cb(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
http_complete_write(int fd, short what, void *arg)
|
||||
http_complete_write(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct bufferevent *bev = arg;
|
||||
const char *http_request = "host\r\n"
|
||||
@ -328,7 +328,7 @@ http_basic_test(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
|
||||
@ -485,7 +485,7 @@ http_badreq_readcb(struct bufferevent *bev, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
http_badreq_successcb(int fd, short what, void *arg)
|
||||
http_badreq_successcb(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
event_debug(("%s: called (what=%04x, arg=%p)", __func__, what, arg));
|
||||
event_loopexit(NULL);
|
||||
@ -496,7 +496,7 @@ http_bad_request_test(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
|
||||
@ -609,7 +609,7 @@ static void
|
||||
http_delete_test(void)
|
||||
{
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
|
||||
@ -1440,7 +1440,7 @@ static void
|
||||
http_failure_test(void)
|
||||
{
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
|
||||
@ -1486,7 +1486,7 @@ close_detect_done(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
close_detect_launch(int fd, short what, void *arg)
|
||||
close_detect_launch(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct evhttp_connection *evcon = arg;
|
||||
struct evhttp_request *req;
|
||||
@ -1659,7 +1659,7 @@ http_base_test(void)
|
||||
{
|
||||
struct event_base *tmp;
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
|
||||
@ -1727,7 +1727,7 @@ static void
|
||||
http_incomplete_writecb(struct bufferevent *bev, void *arg)
|
||||
{
|
||||
if (arg != NULL) {
|
||||
int fd = *(int *)arg;
|
||||
evutil_socket_t fd = *(evutil_socket_t *)arg;
|
||||
/* terminate the write side to simulate EOF */
|
||||
shutdown(fd, SHUT_WR);
|
||||
}
|
||||
@ -1742,7 +1742,7 @@ static void
|
||||
_http_incomplete_test(int use_timeout)
|
||||
{
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
struct timeval tv_start, tv_end;
|
||||
@ -1944,7 +1944,7 @@ static void
|
||||
http_chunk_out_test(void)
|
||||
{
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
struct timeval tv_start, tv_end;
|
||||
@ -2198,7 +2198,7 @@ http_connection_retry_done(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
http_make_web_server(int fd, short what, void *arg)
|
||||
http_make_web_server(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
short port = -1;
|
||||
http = http_setup(&port, NULL);
|
||||
@ -2522,7 +2522,7 @@ http_data_length_constraints_test(void)
|
||||
struct terminate_state {
|
||||
struct evhttp_request *req;
|
||||
struct bufferevent *bev;
|
||||
int fd;
|
||||
evutil_socket_t fd;
|
||||
int gotclosecb: 1;
|
||||
} terminate_state;
|
||||
|
||||
@ -2577,7 +2577,7 @@ terminate_chunked_cb(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
terminate_chunked_client(int fd, short event, void *arg)
|
||||
terminate_chunked_client(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct terminate_state *state = arg;
|
||||
bufferevent_free(state->bev);
|
||||
@ -2599,7 +2599,7 @@ http_terminate_chunked_test(void)
|
||||
struct timeval tv;
|
||||
const char *http_request;
|
||||
short port = -1;
|
||||
int fd = -1;
|
||||
evutil_socket_t fd = -1;
|
||||
|
||||
test_ok = 0;
|
||||
|
||||
|
@ -46,7 +46,7 @@ struct cond_wait {
|
||||
};
|
||||
|
||||
static void
|
||||
basic_timeout(int fd, short what, void *arg)
|
||||
basic_timeout(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct cond_wait *cw = arg;
|
||||
assert(pthread_mutex_lock(&cw->lock) == 0);
|
||||
|
@ -587,7 +587,7 @@ struct _rpc_hook_ctx {
|
||||
static int hook_pause_cb_called=0;
|
||||
|
||||
static void
|
||||
rpc_hook_pause_cb(int fd, short what, void *arg)
|
||||
rpc_hook_pause_cb(evutil_socket_t fd, short what, void *arg)
|
||||
{
|
||||
struct _rpc_hook_ctx *ctx = arg;
|
||||
++hook_pause_cb_called;
|
||||
|
@ -34,7 +34,7 @@ int test_okay = 1;
|
||||
int called = 0;
|
||||
|
||||
static void
|
||||
read_cb(int fd, short event, void *arg)
|
||||
read_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
char buf[256];
|
||||
int len;
|
||||
|
@ -37,7 +37,7 @@ rand_int(int n)
|
||||
}
|
||||
|
||||
static void
|
||||
time_cb(int fd, short event, void *arg)
|
||||
time_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
struct timeval tv;
|
||||
int i, j;
|
||||
|
@ -38,7 +38,7 @@ int test_okay = 1;
|
||||
int called = 0;
|
||||
|
||||
static void
|
||||
write_cb(int fd, short event, void *arg)
|
||||
write_cb(evutil_socket_t fd, short event, void *arg)
|
||||
{
|
||||
const char *test = "test string";
|
||||
int len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user