@@ -584,7 +584,7 @@ http_bad_request_test(void *arg)
584
584
struct basic_test_data * data = arg ;
585
585
struct timeval tv ;
586
586
struct bufferevent * bev = NULL ;
587
- evutil_socket_t fd ;
587
+ evutil_socket_t fd = -1 ;
588
588
const char * http_request ;
589
589
ev_uint16_t port = 0 , port2 = 0 ;
590
590
@@ -658,6 +658,8 @@ http_bad_request_test(void *arg)
658
658
evhttp_free (http );
659
659
if (bev )
660
660
bufferevent_free (bev );
661
+ if (fd >= 0 )
662
+ evutil_closesocket (fd );
661
663
}
662
664
663
665
static struct evhttp_connection * delayed_client ;
@@ -704,7 +706,7 @@ http_delete_test(void *arg)
704
706
{
705
707
struct basic_test_data * data = arg ;
706
708
struct bufferevent * bev ;
707
- evutil_socket_t fd ;
709
+ evutil_socket_t fd = -1 ;
708
710
const char * http_request ;
709
711
ev_uint16_t port = 0 ;
710
712
@@ -737,7 +739,8 @@ http_delete_test(void *arg)
737
739
738
740
tt_int_op (test_ok , = = , 2 );
739
741
end :
740
- ;
742
+ if (fd >= 0 )
743
+ evutil_closesocket (fd );
741
744
}
742
745
743
746
static void
@@ -785,7 +788,7 @@ http_on_complete_test(void *arg)
785
788
{
786
789
struct basic_test_data * data = arg ;
787
790
struct bufferevent * bev ;
788
- evutil_socket_t fd ;
791
+ evutil_socket_t fd = -1 ;
789
792
const char * http_request ;
790
793
ev_uint16_t port = 0 ;
791
794
@@ -794,6 +797,7 @@ http_on_complete_test(void *arg)
794
797
http = http_setup (& port , data -> base , 0 );
795
798
796
799
fd = http_connect ("127.0.0.1" , port );
800
+ tt_int_op (fd , >=, 0 );
797
801
798
802
/* Stupid thing to send a request */
799
803
bev = bufferevent_socket_new (data -> base , fd , 0 );
@@ -811,13 +815,13 @@ http_on_complete_test(void *arg)
811
815
event_base_dispatch (data -> base );
812
816
813
817
bufferevent_free (bev );
814
- evutil_closesocket (fd );
815
818
816
819
evhttp_free (http );
817
820
818
821
tt_int_op (test_ok , = = , 4 );
819
822
end :
820
- ;
823
+ if (fd >= 0 )
824
+ evutil_closesocket (fd );
821
825
}
822
826
823
827
static void
@@ -844,7 +848,7 @@ http_allowed_methods_test(void *arg)
844
848
{
845
849
struct basic_test_data * data = arg ;
846
850
struct bufferevent * bev1 , * bev2 , * bev3 ;
847
- evutil_socket_t fd1 , fd2 , fd3 ;
851
+ evutil_socket_t fd1 = -1 , fd2 = -1 , fd3 = -1 ;
848
852
const char * http_request ;
849
853
char * result1 = NULL , * result2 = NULL , * result3 = NULL ;
850
854
ev_uint16_t port = 0 ;
@@ -915,9 +919,6 @@ http_allowed_methods_test(void *arg)
915
919
bufferevent_free (bev1 );
916
920
bufferevent_free (bev2 );
917
921
bufferevent_free (bev3 );
918
- evutil_closesocket (fd1 );
919
- evutil_closesocket (fd2 );
920
- evutil_closesocket (fd3 );
921
922
922
923
evhttp_free (http );
923
924
@@ -940,6 +941,12 @@ http_allowed_methods_test(void *arg)
940
941
free (result2 );
941
942
if (result3 )
942
943
free (result3 );
944
+ if (fd1 >= 0 )
945
+ evutil_closesocket (fd1 );
946
+ if (fd2 >= 0 )
947
+ evutil_closesocket (fd2 );
948
+ if (fd3 >= 0 )
949
+ evutil_closesocket (fd3 );
943
950
}
944
951
945
952
static void http_request_done (struct evhttp_request * , void * );
@@ -1851,7 +1858,7 @@ http_failure_test(void *arg)
1851
1858
{
1852
1859
struct basic_test_data * data = arg ;
1853
1860
struct bufferevent * bev ;
1854
- evutil_socket_t fd ;
1861
+ evutil_socket_t fd = -1 ;
1855
1862
const char * http_request ;
1856
1863
ev_uint16_t port = 0 ;
1857
1864
@@ -1874,13 +1881,13 @@ http_failure_test(void *arg)
1874
1881
event_base_dispatch (data -> base );
1875
1882
1876
1883
bufferevent_free (bev );
1877
- evutil_closesocket (fd );
1878
1884
1879
1885
evhttp_free (http );
1880
1886
1881
1887
tt_int_op (test_ok , = = , 2 );
1882
1888
end :
1883
- ;
1889
+ if (fd >= 0 )
1890
+ evutil_closesocket (fd );
1884
1891
}
1885
1892
1886
1893
static void
@@ -2749,7 +2756,8 @@ http_incomplete_test_(struct basic_test_data *data, int use_timeout)
2749
2756
2750
2757
tt_int_op (test_ok , = = , 2 );
2751
2758
end :
2752
- ;
2759
+ if (fd >= 0 )
2760
+ evutil_closesocket (fd );
2753
2761
}
2754
2762
static void
2755
2763
http_incomplete_test (void * arg )
0 commit comments