2828#include "utils/s2n_safety.h"
2929
3030static const float minimum_send_percent = 5.0 ;
31- static const uint32_t max_client_run_time = 300 ;
3231
33- #define LESS_THAN_ELAPSED_SECONDS (start_time , max_time ) ((start_time - time(0)) < max_time)
34- #define MIN_PERCENT_COMPLETE (remaining , total ) ((((total - remaining) / (total * 1.0)) * 100.0) > minimum_send_percent)
32+ #define MIN_PERCENT_COMPLETE (remaining , total ) ((((total - remaining) / (total * 1.0)) * 100.0) > minimum_send_percent)
3533
3634int mock_client (struct s2n_test_io_pair * io_pair , uint8_t * expected_data , uint32_t size )
3735{
@@ -46,8 +44,6 @@ int mock_client(struct s2n_test_io_pair *io_pair, uint8_t *expected_data, uint32
4644 * CI/CD pipelines might never complete */
4745 int should_block = 1 ;
4846
49- time_t start_time = time (0 );
50-
5147 /* Give the server a chance to listen */
5248 sleep (1 );
5349
@@ -66,7 +62,7 @@ int mock_client(struct s2n_test_io_pair *io_pair, uint8_t *expected_data, uint32
6662
6763 /* Receive 10MB of data */
6864 uint32_t remaining = size ;
69- while (remaining && LESS_THAN_ELAPSED_SECONDS ( start_time , max_client_run_time ) ) {
65+ while (remaining ) {
7066 int r = s2n_recv (client_conn , ptr , remaining , & blocked );
7167 if (r < 0 ) {
7268 return 1 ;
@@ -82,7 +78,7 @@ int mock_client(struct s2n_test_io_pair *io_pair, uint8_t *expected_data, uint32
8278 int shutdown_rc = -1 ;
8379 do {
8480 shutdown_rc = s2n_shutdown (client_conn , & blocked );
85- } while (shutdown_rc != 0 && LESS_THAN_ELAPSED_SECONDS ( start_time , max_client_run_time ) );
81+ } while (shutdown_rc != 0 );
8682
8783 for (size_t i = 0 ; i < size ; i ++ ) {
8884 if (buffer [i ] != expected_data [i ]) {
@@ -108,8 +104,6 @@ int mock_client_iov(struct s2n_test_io_pair *io_pair, struct iovec *iov, uint32_
108104 int total_size = 0 , i ;
109105 int should_block = 1 ;
110106
111- time_t start_time = time (0 );
112-
113107 for (i = 0 ; i < iov_size ; i ++ ) {
114108 total_size += iov [i ].iov_len ;
115109 }
@@ -133,7 +127,7 @@ int mock_client_iov(struct s2n_test_io_pair *io_pair, struct iovec *iov, uint32_
133127 }
134128
135129 uint32_t remaining = total_size ;
136- while (remaining && LESS_THAN_ELAPSED_SECONDS ( start_time , max_client_run_time ) ) {
130+ while (remaining ) {
137131 int r = s2n_recv (client_conn , & buffer [buffer_offs ], remaining , & blocked );
138132 if (r < 0 ) {
139133 return 1 ;
@@ -147,7 +141,7 @@ int mock_client_iov(struct s2n_test_io_pair *io_pair, struct iovec *iov, uint32_
147141 }
148142
149143 remaining = iov [0 ].iov_len ;
150- while (remaining && LESS_THAN_ELAPSED_SECONDS ( start_time , max_client_run_time ) ) {
144+ while (remaining ) {
151145 int r = s2n_recv (client_conn , & buffer [buffer_offs ], remaining , & blocked );
152146 if (r < 0 ) {
153147 return 1 ;
@@ -159,7 +153,7 @@ int mock_client_iov(struct s2n_test_io_pair *io_pair, struct iovec *iov, uint32_
159153 int shutdown_rc = -1 ;
160154 do {
161155 shutdown_rc = s2n_shutdown (client_conn , & blocked );
162- } while (shutdown_rc != 0 && LESS_THAN_ELAPSED_SECONDS ( start_time , max_client_run_time ) );
156+ } while (shutdown_rc != 0 );
163157
164158 for (i = 0 , buffer_offs = 0 ; i < iov_size ; i ++ ) {
165159 if (memcmp (iov [i ].iov_base , & buffer [buffer_offs ], iov [i ].iov_len )) {
0 commit comments