xref: /freebsd/contrib/ntp/sntp/libevent/test/regress_zlib.c (revision a466cc55373fc3cf86837f09da729535b57e69a1)
12b15cb3dSCy Schubert /*
22b15cb3dSCy Schubert  * Copyright (c) 2008-2012 Niels Provos and Nick Mathewson
32b15cb3dSCy Schubert  *
42b15cb3dSCy Schubert  * Redistribution and use in source and binary forms, with or without
52b15cb3dSCy Schubert  * modification, are permitted provided that the following conditions
62b15cb3dSCy Schubert  * are met:
72b15cb3dSCy Schubert  * 1. Redistributions of source code must retain the above copyright
82b15cb3dSCy Schubert  *    notice, this list of conditions and the following disclaimer.
92b15cb3dSCy Schubert  * 2. Redistributions in binary form must reproduce the above copyright
102b15cb3dSCy Schubert  *    notice, this list of conditions and the following disclaimer in the
112b15cb3dSCy Schubert  *    documentation and/or other materials provided with the distribution.
122b15cb3dSCy Schubert  * 3. The name of the author may not be used to endorse or promote products
132b15cb3dSCy Schubert  *    derived from this software without specific prior written permission.
142b15cb3dSCy Schubert  *
152b15cb3dSCy Schubert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
162b15cb3dSCy Schubert  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
172b15cb3dSCy Schubert  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
182b15cb3dSCy Schubert  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
192b15cb3dSCy Schubert  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
202b15cb3dSCy Schubert  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
212b15cb3dSCy Schubert  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
222b15cb3dSCy Schubert  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
232b15cb3dSCy Schubert  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
242b15cb3dSCy Schubert  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
252b15cb3dSCy Schubert  */
262b15cb3dSCy Schubert 
272b15cb3dSCy Schubert /* The old tests here need assertions to work. */
282b15cb3dSCy Schubert #undef NDEBUG
292b15cb3dSCy Schubert 
302b15cb3dSCy Schubert #ifdef _WIN32
312b15cb3dSCy Schubert #include <winsock2.h>
322b15cb3dSCy Schubert #include <windows.h>
332b15cb3dSCy Schubert #endif
342b15cb3dSCy Schubert 
352b15cb3dSCy Schubert #include "event2/event-config.h"
362b15cb3dSCy Schubert 
372b15cb3dSCy Schubert #include <sys/types.h>
382b15cb3dSCy Schubert #ifndef _WIN32
392b15cb3dSCy Schubert #include <sys/socket.h>
402b15cb3dSCy Schubert #include <sys/wait.h>
412b15cb3dSCy Schubert #include <unistd.h>
422b15cb3dSCy Schubert #include <netdb.h>
432b15cb3dSCy Schubert #endif
442b15cb3dSCy Schubert #include <signal.h>
452b15cb3dSCy Schubert #include <stdio.h>
462b15cb3dSCy Schubert #include <stdlib.h>
472b15cb3dSCy Schubert #include <string.h>
482b15cb3dSCy Schubert 
492b15cb3dSCy Schubert #include <assert.h>
502b15cb3dSCy Schubert #include <errno.h>
512b15cb3dSCy Schubert 
522b15cb3dSCy Schubert #include "event2/util.h"
532b15cb3dSCy Schubert #include "event2/event.h"
542b15cb3dSCy Schubert #include "event2/event_compat.h"
552b15cb3dSCy Schubert #include "event2/buffer.h"
562b15cb3dSCy Schubert #include "event2/bufferevent.h"
572b15cb3dSCy Schubert 
582b15cb3dSCy Schubert #include "regress.h"
59a25439b6SCy Schubert #include "mm-internal.h"
602b15cb3dSCy Schubert 
612b15cb3dSCy Schubert /* zlib 1.2.4 and 1.2.5 do some "clever" things with macros.  Instead of
622b15cb3dSCy Schubert    saying "(defined(FOO) ? FOO : 0)" they like to say "FOO-0", on the theory
632b15cb3dSCy Schubert    that nobody will care if the compile outputs a no-such-identifier warning.
642b15cb3dSCy Schubert 
652b15cb3dSCy Schubert    Sorry, but we like -Werror over here, so I guess we need to define these.
662b15cb3dSCy Schubert    I hope that zlib 1.2.6 doesn't break these too.
672b15cb3dSCy Schubert */
682b15cb3dSCy Schubert #ifndef _LARGEFILE64_SOURCE
692b15cb3dSCy Schubert #define _LARGEFILE64_SOURCE 0
702b15cb3dSCy Schubert #endif
712b15cb3dSCy Schubert #ifndef _LFS64_LARGEFILE
722b15cb3dSCy Schubert #define _LFS64_LARGEFILE 0
732b15cb3dSCy Schubert #endif
742b15cb3dSCy Schubert #ifndef _FILE_OFFSET_BITS
752b15cb3dSCy Schubert #define _FILE_OFFSET_BITS 0
762b15cb3dSCy Schubert #endif
772b15cb3dSCy Schubert #ifndef off64_t
782b15cb3dSCy Schubert #define off64_t ev_int64_t
792b15cb3dSCy Schubert #endif
802b15cb3dSCy Schubert 
812b15cb3dSCy Schubert #include <zlib.h>
822b15cb3dSCy Schubert 
832b15cb3dSCy Schubert static int infilter_calls;
842b15cb3dSCy Schubert static int outfilter_calls;
852b15cb3dSCy Schubert static int readcb_finished;
862b15cb3dSCy Schubert static int writecb_finished;
872b15cb3dSCy Schubert static int errorcb_invoked;
882b15cb3dSCy Schubert 
892b15cb3dSCy Schubert /*
902b15cb3dSCy Schubert  * Zlib filters
912b15cb3dSCy Schubert  */
922b15cb3dSCy Schubert 
932b15cb3dSCy Schubert static void
zlib_deflate_free(void * ctx)942b15cb3dSCy Schubert zlib_deflate_free(void *ctx)
952b15cb3dSCy Schubert {
962b15cb3dSCy Schubert 	z_streamp p = ctx;
972b15cb3dSCy Schubert 
982b15cb3dSCy Schubert 	assert(deflateEnd(p) == Z_OK);
99a25439b6SCy Schubert 	mm_free(p);
1002b15cb3dSCy Schubert }
1012b15cb3dSCy Schubert 
1022b15cb3dSCy Schubert static void
zlib_inflate_free(void * ctx)1032b15cb3dSCy Schubert zlib_inflate_free(void *ctx)
1042b15cb3dSCy Schubert {
1052b15cb3dSCy Schubert 	z_streamp p = ctx;
1062b15cb3dSCy Schubert 
1072b15cb3dSCy Schubert 	assert(inflateEnd(p) == Z_OK);
108a25439b6SCy Schubert 	mm_free(p);
1092b15cb3dSCy Schubert }
1102b15cb3dSCy Schubert 
1112b15cb3dSCy Schubert static int
getstate(enum bufferevent_flush_mode state)1122b15cb3dSCy Schubert getstate(enum bufferevent_flush_mode state)
1132b15cb3dSCy Schubert {
1142b15cb3dSCy Schubert 	switch (state) {
1152b15cb3dSCy Schubert 	case BEV_FINISHED:
1162b15cb3dSCy Schubert 		return Z_FINISH;
1172b15cb3dSCy Schubert 	case BEV_FLUSH:
1182b15cb3dSCy Schubert 		return Z_SYNC_FLUSH;
1192b15cb3dSCy Schubert 	case BEV_NORMAL:
1202b15cb3dSCy Schubert 	default:
1212b15cb3dSCy Schubert 		return Z_NO_FLUSH;
1222b15cb3dSCy Schubert 	}
1232b15cb3dSCy Schubert }
1242b15cb3dSCy Schubert 
1252b15cb3dSCy Schubert /*
1262b15cb3dSCy Schubert  * The input filter is triggered only on new input read from the network.
1272b15cb3dSCy Schubert  * That means all input data needs to be consumed or the filter needs to
1282b15cb3dSCy Schubert  * initiate its own triggering via a timeout.
1292b15cb3dSCy Schubert  */
1302b15cb3dSCy Schubert static enum bufferevent_filter_result
zlib_input_filter(struct evbuffer * src,struct evbuffer * dst,ev_ssize_t lim,enum bufferevent_flush_mode state,void * ctx)1312b15cb3dSCy Schubert zlib_input_filter(struct evbuffer *src, struct evbuffer *dst,
1322b15cb3dSCy Schubert     ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx)
1332b15cb3dSCy Schubert {
1342b15cb3dSCy Schubert 	struct evbuffer_iovec v_in[1];
1352b15cb3dSCy Schubert 	struct evbuffer_iovec v_out[1];
1362b15cb3dSCy Schubert 	int nread, nwrite;
1372b15cb3dSCy Schubert 	int res, n;
1382b15cb3dSCy Schubert 
1392b15cb3dSCy Schubert 	z_streamp p = ctx;
1402b15cb3dSCy Schubert 
1412b15cb3dSCy Schubert 	do {
1422b15cb3dSCy Schubert 		/* let's do some decompression */
1432b15cb3dSCy Schubert 		n = evbuffer_peek(src, -1, NULL, v_in, 1);
1442b15cb3dSCy Schubert 		if (n) {
1452b15cb3dSCy Schubert 			p->avail_in = v_in[0].iov_len;
146*a466cc55SCy Schubert 			p->next_in = (unsigned char *)v_in[0].iov_base;
1472b15cb3dSCy Schubert 		} else {
1482b15cb3dSCy Schubert 			p->avail_in = 0;
1492b15cb3dSCy Schubert 			p->next_in = 0;
1502b15cb3dSCy Schubert 		}
1512b15cb3dSCy Schubert 
1522b15cb3dSCy Schubert 		evbuffer_reserve_space(dst, 4096, v_out, 1);
153*a466cc55SCy Schubert 		p->next_out = (unsigned char *)v_out[0].iov_base;
1542b15cb3dSCy Schubert 		p->avail_out = v_out[0].iov_len;
1552b15cb3dSCy Schubert 
1562b15cb3dSCy Schubert 		/* we need to flush zlib if we got a flush */
1572b15cb3dSCy Schubert 		res = inflate(p, getstate(state));
1582b15cb3dSCy Schubert 
1592b15cb3dSCy Schubert 		/* let's figure out how much was compressed */
1602b15cb3dSCy Schubert 		nread = v_in[0].iov_len - p->avail_in;
1612b15cb3dSCy Schubert 		nwrite = v_out[0].iov_len - p->avail_out;
1622b15cb3dSCy Schubert 
1632b15cb3dSCy Schubert 		evbuffer_drain(src, nread);
1642b15cb3dSCy Schubert 		v_out[0].iov_len = nwrite;
1652b15cb3dSCy Schubert 		evbuffer_commit_space(dst, v_out, 1);
1662b15cb3dSCy Schubert 
1672b15cb3dSCy Schubert 		if (res==Z_BUF_ERROR) {
1682b15cb3dSCy Schubert 			/* We're out of space, or out of decodeable input.
1692b15cb3dSCy Schubert 			   Only if nwrite == 0 assume the latter.
1702b15cb3dSCy Schubert 			 */
1712b15cb3dSCy Schubert 			if (nwrite == 0)
1722b15cb3dSCy Schubert 				return BEV_NEED_MORE;
1732b15cb3dSCy Schubert 		} else {
1742b15cb3dSCy Schubert 			assert(res == Z_OK || res == Z_STREAM_END);
1752b15cb3dSCy Schubert 		}
1762b15cb3dSCy Schubert 
1772b15cb3dSCy Schubert 	} while (evbuffer_get_length(src) > 0);
1782b15cb3dSCy Schubert 
1792b15cb3dSCy Schubert 	++infilter_calls;
1802b15cb3dSCy Schubert 
1812b15cb3dSCy Schubert 	return (BEV_OK);
1822b15cb3dSCy Schubert }
1832b15cb3dSCy Schubert 
1842b15cb3dSCy Schubert static enum bufferevent_filter_result
zlib_output_filter(struct evbuffer * src,struct evbuffer * dst,ev_ssize_t lim,enum bufferevent_flush_mode state,void * ctx)1852b15cb3dSCy Schubert zlib_output_filter(struct evbuffer *src, struct evbuffer *dst,
1862b15cb3dSCy Schubert     ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx)
1872b15cb3dSCy Schubert {
1882b15cb3dSCy Schubert 	struct evbuffer_iovec v_in[1];
1892b15cb3dSCy Schubert 	struct evbuffer_iovec v_out[1];
1902b15cb3dSCy Schubert 	int nread, nwrite;
1912b15cb3dSCy Schubert 	int res, n;
1922b15cb3dSCy Schubert 
1932b15cb3dSCy Schubert 	z_streamp p = ctx;
1942b15cb3dSCy Schubert 
1952b15cb3dSCy Schubert 	do {
1962b15cb3dSCy Schubert 		/* let's do some compression */
1972b15cb3dSCy Schubert 		n = evbuffer_peek(src, -1, NULL, v_in, 1);
1982b15cb3dSCy Schubert 		if (n) {
1992b15cb3dSCy Schubert 			p->avail_in = v_in[0].iov_len;
200*a466cc55SCy Schubert 			p->next_in = (unsigned char *)v_in[0].iov_base;
2012b15cb3dSCy Schubert 		} else {
2022b15cb3dSCy Schubert 			p->avail_in = 0;
2032b15cb3dSCy Schubert 			p->next_in = 0;
2042b15cb3dSCy Schubert 		}
2052b15cb3dSCy Schubert 
2062b15cb3dSCy Schubert 		evbuffer_reserve_space(dst, 4096, v_out, 1);
207*a466cc55SCy Schubert 		p->next_out = (unsigned char *)v_out[0].iov_base;
2082b15cb3dSCy Schubert 		p->avail_out = v_out[0].iov_len;
2092b15cb3dSCy Schubert 
2102b15cb3dSCy Schubert 		/* we need to flush zlib if we got a flush */
2112b15cb3dSCy Schubert 		res = deflate(p, getstate(state));
2122b15cb3dSCy Schubert 
2132b15cb3dSCy Schubert 		/* let's figure out how much was decompressed */
2142b15cb3dSCy Schubert 		nread = v_in[0].iov_len - p->avail_in;
2152b15cb3dSCy Schubert 		nwrite = v_out[0].iov_len - p->avail_out;
2162b15cb3dSCy Schubert 
2172b15cb3dSCy Schubert 		evbuffer_drain(src, nread);
2182b15cb3dSCy Schubert 		v_out[0].iov_len = nwrite;
2192b15cb3dSCy Schubert 		evbuffer_commit_space(dst, v_out, 1);
2202b15cb3dSCy Schubert 
2212b15cb3dSCy Schubert 		if (res==Z_BUF_ERROR) {
2222b15cb3dSCy Schubert 			/* We're out of space, or out of decodeable input.
2232b15cb3dSCy Schubert 			   Only if nwrite == 0 assume the latter.
2242b15cb3dSCy Schubert 			 */
2252b15cb3dSCy Schubert 			if (nwrite == 0)
2262b15cb3dSCy Schubert 				return BEV_NEED_MORE;
2272b15cb3dSCy Schubert 		} else {
2282b15cb3dSCy Schubert 			assert(res == Z_OK || res == Z_STREAM_END);
2292b15cb3dSCy Schubert 		}
2302b15cb3dSCy Schubert 
2312b15cb3dSCy Schubert 	} while (evbuffer_get_length(src) > 0);
2322b15cb3dSCy Schubert 
2332b15cb3dSCy Schubert 	++outfilter_calls;
2342b15cb3dSCy Schubert 
2352b15cb3dSCy Schubert 	return (BEV_OK);
2362b15cb3dSCy Schubert }
2372b15cb3dSCy Schubert 
2382b15cb3dSCy Schubert /*
2392b15cb3dSCy Schubert  * simple bufferevent test (over transparent zlib treatment)
2402b15cb3dSCy Schubert  */
2412b15cb3dSCy Schubert 
2422b15cb3dSCy Schubert static void
readcb(struct bufferevent * bev,void * arg)2432b15cb3dSCy Schubert readcb(struct bufferevent *bev, void *arg)
2442b15cb3dSCy Schubert {
2452b15cb3dSCy Schubert 	if (evbuffer_get_length(bufferevent_get_input(bev)) == 8333) {
2462b15cb3dSCy Schubert 		struct evbuffer *evbuf = evbuffer_new();
2472b15cb3dSCy Schubert 		assert(evbuf != NULL);
2482b15cb3dSCy Schubert 
2492b15cb3dSCy Schubert 		/* gratuitous test of bufferevent_read_buffer */
2502b15cb3dSCy Schubert 		bufferevent_read_buffer(bev, evbuf);
2512b15cb3dSCy Schubert 
2522b15cb3dSCy Schubert 		bufferevent_disable(bev, EV_READ);
2532b15cb3dSCy Schubert 
2542b15cb3dSCy Schubert 		if (evbuffer_get_length(evbuf) == 8333) {
2552b15cb3dSCy Schubert 			++readcb_finished;
2562b15cb3dSCy Schubert 		}
2572b15cb3dSCy Schubert 
2582b15cb3dSCy Schubert 		evbuffer_free(evbuf);
2592b15cb3dSCy Schubert 	}
2602b15cb3dSCy Schubert }
2612b15cb3dSCy Schubert 
2622b15cb3dSCy Schubert static void
writecb(struct bufferevent * bev,void * arg)2632b15cb3dSCy Schubert writecb(struct bufferevent *bev, void *arg)
2642b15cb3dSCy Schubert {
2652b15cb3dSCy Schubert 	if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) {
2662b15cb3dSCy Schubert 		++writecb_finished;
2672b15cb3dSCy Schubert 	}
2682b15cb3dSCy Schubert }
2692b15cb3dSCy Schubert 
2702b15cb3dSCy Schubert static void
errorcb(struct bufferevent * bev,short what,void * arg)2712b15cb3dSCy Schubert errorcb(struct bufferevent *bev, short what, void *arg)
2722b15cb3dSCy Schubert {
2732b15cb3dSCy Schubert 	errorcb_invoked = 1;
2742b15cb3dSCy Schubert }
2752b15cb3dSCy Schubert 
2762b15cb3dSCy Schubert void
test_bufferevent_zlib(void * arg)2772b15cb3dSCy Schubert test_bufferevent_zlib(void *arg)
2782b15cb3dSCy Schubert {
2792b15cb3dSCy Schubert 	struct bufferevent *bev1=NULL, *bev2=NULL;
2802b15cb3dSCy Schubert 	char buffer[8333];
281a25439b6SCy Schubert 	z_stream *z_input, *z_output;
2822b15cb3dSCy Schubert 	int i, r;
2832b15cb3dSCy Schubert 	evutil_socket_t pair[2] = {-1, -1};
2842b15cb3dSCy Schubert 	(void)arg;
2852b15cb3dSCy Schubert 
2862b15cb3dSCy Schubert 	infilter_calls = outfilter_calls = readcb_finished = writecb_finished
2872b15cb3dSCy Schubert 	    = errorcb_invoked = 0;
2882b15cb3dSCy Schubert 
2892b15cb3dSCy Schubert 	if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
2902b15cb3dSCy Schubert 		tt_abort_perror("socketpair");
2912b15cb3dSCy Schubert 	}
2922b15cb3dSCy Schubert 
2932b15cb3dSCy Schubert 	evutil_make_socket_nonblocking(pair[0]);
2942b15cb3dSCy Schubert 	evutil_make_socket_nonblocking(pair[1]);
2952b15cb3dSCy Schubert 
2962b15cb3dSCy Schubert 	bev1 = bufferevent_socket_new(NULL, pair[0], 0);
2972b15cb3dSCy Schubert 	bev2 = bufferevent_socket_new(NULL, pair[1], 0);
2982b15cb3dSCy Schubert 
299a25439b6SCy Schubert 	z_output = mm_calloc(sizeof(*z_output), 1);
300a25439b6SCy Schubert 	r = deflateInit(z_output, Z_DEFAULT_COMPRESSION);
3012b15cb3dSCy Schubert 	tt_int_op(r, ==, Z_OK);
302a25439b6SCy Schubert 	z_input = mm_calloc(sizeof(*z_input), 1);
303a25439b6SCy Schubert 	r = inflateInit(z_input);
3042b15cb3dSCy Schubert 	tt_int_op(r, ==, Z_OK);
3052b15cb3dSCy Schubert 
3062b15cb3dSCy Schubert 	/* initialize filters */
3072b15cb3dSCy Schubert 	bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter,
308a25439b6SCy Schubert 	    BEV_OPT_CLOSE_ON_FREE, zlib_deflate_free, z_output);
3092b15cb3dSCy Schubert 	bev2 = bufferevent_filter_new(bev2, zlib_input_filter,
310a25439b6SCy Schubert 	    NULL, BEV_OPT_CLOSE_ON_FREE, zlib_inflate_free, z_input);
3112b15cb3dSCy Schubert 	bufferevent_setcb(bev1, readcb, writecb, errorcb, NULL);
3122b15cb3dSCy Schubert 	bufferevent_setcb(bev2, readcb, writecb, errorcb, NULL);
3132b15cb3dSCy Schubert 
3142b15cb3dSCy Schubert 	bufferevent_disable(bev1, EV_READ);
3152b15cb3dSCy Schubert 	bufferevent_enable(bev1, EV_WRITE);
3162b15cb3dSCy Schubert 
3172b15cb3dSCy Schubert 	bufferevent_enable(bev2, EV_READ);
3182b15cb3dSCy Schubert 
3192b15cb3dSCy Schubert 	for (i = 0; i < (int)sizeof(buffer); i++)
3202b15cb3dSCy Schubert 		buffer[i] = i;
3212b15cb3dSCy Schubert 
3222b15cb3dSCy Schubert 	/* break it up into multiple buffer chains */
3232b15cb3dSCy Schubert 	bufferevent_write(bev1, buffer, 1800);
3242b15cb3dSCy Schubert 	bufferevent_write(bev1, buffer + 1800, sizeof(buffer) - 1800);
3252b15cb3dSCy Schubert 
3262b15cb3dSCy Schubert 	/* we are done writing - we need to flush everything */
3272b15cb3dSCy Schubert 	bufferevent_flush(bev1, EV_WRITE, BEV_FINISHED);
3282b15cb3dSCy Schubert 
3292b15cb3dSCy Schubert 	event_dispatch();
3302b15cb3dSCy Schubert 
3312b15cb3dSCy Schubert 	tt_want(infilter_calls);
3322b15cb3dSCy Schubert 	tt_want(outfilter_calls);
3332b15cb3dSCy Schubert 	tt_want(readcb_finished);
3342b15cb3dSCy Schubert 	tt_want(writecb_finished);
3352b15cb3dSCy Schubert 	tt_want(!errorcb_invoked);
3362b15cb3dSCy Schubert 
3372b15cb3dSCy Schubert 	test_ok = 1;
3382b15cb3dSCy Schubert end:
3392b15cb3dSCy Schubert 	if (bev1)
3402b15cb3dSCy Schubert 		bufferevent_free(bev1);
3412b15cb3dSCy Schubert 	if (bev2)
3422b15cb3dSCy Schubert 		bufferevent_free(bev2);
3432b15cb3dSCy Schubert 
3442b15cb3dSCy Schubert 	if (pair[0] >= 0)
3452b15cb3dSCy Schubert 		evutil_closesocket(pair[0]);
3462b15cb3dSCy Schubert 	if (pair[1] >= 0)
3472b15cb3dSCy Schubert 		evutil_closesocket(pair[1]);
3482b15cb3dSCy Schubert }
349