mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Check against EVUTIL_INVALID_SOCKET
This commit is contained in:
parent
3f799ab675
commit
5485887c47
@ -391,7 +391,7 @@ test_simpleclose_rw(void *ptr)
|
||||
{
|
||||
/* Test that a close of FD is detected as a read and as a write. */
|
||||
struct event_base *base = event_base_new();
|
||||
evutil_socket_t pair1[2]={-1,-1}, pair2[2] = {-1, -1};
|
||||
evutil_socket_t pair1[2]={EVUTIL_INVALID_SOCKET,EVUTIL_INVALID_SOCKET}, pair2[2] = {EVUTIL_INVALID_SOCKET, EVUTIL_INVALID_SOCKET};
|
||||
evutil_socket_t *to_close[2];
|
||||
struct event *rev=NULL, *wev=NULL, *closeev=NULL;
|
||||
struct timeval tv;
|
||||
|
@ -249,7 +249,7 @@ void *
|
||||
basic_test_setup(const struct testcase_t *testcase)
|
||||
{
|
||||
struct event_base *base = NULL;
|
||||
evutil_socket_t spair[2] = { -1, -1 };
|
||||
evutil_socket_t spair[2] = { EVUTIL_INVALID_SOCKET, EVUTIL_INVALID_SOCKET };
|
||||
struct basic_test_data *data = NULL;
|
||||
|
||||
#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED)
|
||||
|
@ -1731,7 +1731,7 @@ test_evutil_win_socketpair(void *arg)
|
||||
struct basic_test_data *data = arg;
|
||||
const int inet = strstr(data->setup_data, "inet") != NULL;
|
||||
int family = inet ? AF_INET : AF_UNIX;
|
||||
evutil_socket_t fd[2] = { -1, -1 };
|
||||
evutil_socket_t fd[2] = { EVUTIL_INVALID_SOCKET, EVUTIL_INVALID_SOCKET };
|
||||
int r;
|
||||
int type;
|
||||
ev_socklen_t typelen;
|
||||
|
@ -282,7 +282,7 @@ test_bufferevent_zlib(void *arg)
|
||||
char buffer[8333];
|
||||
z_stream *z_input, *z_output;
|
||||
int i, r;
|
||||
evutil_socket_t pair[2] = {-1, -1};
|
||||
evutil_socket_t pair[2] = {EVUTIL_INVALID_SOCKET, EVUTIL_INVALID_SOCKET};
|
||||
(void)arg;
|
||||
|
||||
infilter_calls = outfilter_calls = readcb_finished = writecb_finished
|
||||
|
@ -165,7 +165,7 @@ main(int argc, char **argv)
|
||||
struct event* timeout = NULL;
|
||||
struct event_base* base = NULL;
|
||||
|
||||
evutil_socket_t pair[2];
|
||||
evutil_socket_t pair[2] = {EVUTIL_INVALID_SOCKET, EVUTIL_INVALID_SOCKET};
|
||||
struct timeval tv;
|
||||
struct cpu_usage_timer timer;
|
||||
|
||||
@ -188,12 +188,16 @@ main(int argc, char **argv)
|
||||
|
||||
/* Initialize a timeout to terminate the test */
|
||||
timeout = evtimer_new(base,timeout_cb,&timeout);
|
||||
if (timeout == NULL)
|
||||
if (timeout == NULL) {
|
||||
perror("evtimer_new");
|
||||
goto err;
|
||||
}
|
||||
/* and watch for writability on one end of the pipe */
|
||||
ev = event_new(base,pair[1],EV_WRITE | EV_PERSIST, write_cb, &ev);
|
||||
if (ev == NULL)
|
||||
if (ev == NULL) {
|
||||
perror("event_new");
|
||||
goto err;
|
||||
}
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 500*1000;
|
||||
|
||||
@ -228,9 +232,9 @@ err:
|
||||
event_free(ev);
|
||||
if (timeout)
|
||||
event_free(timeout);
|
||||
if (pair[0] >= 0)
|
||||
if (pair[0] != EVUTIL_INVALID_SOCKET)
|
||||
evutil_closesocket(pair[0]);
|
||||
if (pair[1] >= 0)
|
||||
if (pair[1] != EVUTIL_INVALID_SOCKET)
|
||||
evutil_closesocket(pair[1]);
|
||||
if (base)
|
||||
event_base_free(base);
|
||||
|
Loading…
x
Reference in New Issue
Block a user