@@ -331,6 +331,26 @@ static int calibrate(aeEventLoop *loop, long long id, void *data) {
331331 return AE_NOMORE ;
332332}
333333
334+ static int check_timeouts (aeEventLoop * loop , long long id , void * data ) {
335+ thread * thread = data ;
336+ connection * c = thread -> cs ;
337+ uint64_t now = time_us ();
338+
339+ uint64_t maxAge = now - (cfg .timeout * 1000 );
340+
341+ for (uint64_t i = 0 ; i < thread -> connections ; i ++ , c ++ ) {
342+ if (maxAge > c -> start ) {
343+ thread -> errors .timeout ++ ;
344+ }
345+ }
346+
347+ if (stop || now >= thread -> stop_at ) {
348+ aeStop (loop );
349+ }
350+
351+ return TIMEOUT_INTERVAL_MS ;
352+ }
353+
334354static int sample_rate (aeEventLoop * loop , long long id , void * data ) {
335355 thread * thread = data ;
336356
@@ -418,26 +438,6 @@ static int response_complete(http_parser *parser) {
418438 return 0 ;
419439}
420440
421- static int check_timeouts (aeEventLoop * loop , long long id , void * data ) {
422- thread * thread = data ;
423- connection * c = thread -> cs ;
424- uint64_t now = time_us ();
425-
426- uint64_t maxAge = now - (cfg .timeout * 1000 );
427-
428- for (uint64_t i = 0 ; i < thread -> connections ; i ++ , c ++ ) {
429- if (maxAge > c -> start ) {
430- thread -> errors .timeout ++ ;
431- }
432- }
433-
434- if (stop || now >= thread -> stop_at ) {
435- aeStop (loop );
436- }
437-
438- return TIMEOUT_INTERVAL_MS ;
439- }
440-
441441static void socket_connected (aeEventLoop * loop , int fd , void * data , int mask ) {
442442 connection * c = data ;
443443
@@ -450,8 +450,8 @@ static void socket_connected(aeEventLoop *loop, int fd, void *data, int mask) {
450450 http_parser_init (& c -> parser , HTTP_RESPONSE );
451451 c -> written = 0 ;
452452
453- aeCreateFileEvent (c -> thread -> loop , c -> fd , AE_READABLE , socket_readable , c );
454- aeCreateFileEvent (c -> thread -> loop , c -> fd , AE_WRITABLE , socket_writeable , c );
453+ aeCreateFileEvent (c -> thread -> loop , fd , AE_READABLE , socket_readable , c );
454+ aeCreateFileEvent (c -> thread -> loop , fd , AE_WRITABLE , socket_writeable , c );
455455
456456 return ;
457457
0 commit comments