@@ -201,7 +201,7 @@ static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int typ
201
201
}
202
202
/* }}} */
203
203
204
- static int fpm_sockets_new_listening_socket (struct fpm_worker_pool_s * wp , struct sockaddr * sa , int socklen ) /* {{{ */
204
+ static int fpm_sockets_new_listening_socket (struct fpm_worker_pool_s * wp , struct sockaddr * sa , socklen_t socklen ) /* {{{ */
205
205
{
206
206
int flags = 1 ;
207
207
int sock ;
@@ -219,7 +219,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
219
219
}
220
220
221
221
if (wp -> listen_address_domain == FPM_AF_UNIX ) {
222
- if (fpm_socket_unix_test_connect ((struct sockaddr_un * )sa , socklen ) == 0 ) {
222
+ if (! fpm_socket_unix_test_connect ((struct sockaddr_un * )sa , socklen )) {
223
223
zlog (ZLOG_ERROR , "Another FPM instance seems to already listen on %s" , ((struct sockaddr_un * ) sa )-> sun_path );
224
224
close (sock );
225
225
return -1 ;
@@ -272,7 +272,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
272
272
}
273
273
/* }}} */
274
274
275
- static int fpm_sockets_get_listening_socket (struct fpm_worker_pool_s * wp , struct sockaddr * sa , int socklen ) /* {{{ */
275
+ static int fpm_sockets_get_listening_socket (struct fpm_worker_pool_s * wp , struct sockaddr * sa , socklen_t socklen ) /* {{{ */
276
276
{
277
277
int sock ;
278
278
@@ -418,7 +418,7 @@ static zend_result fpm_socket_setfib_init(void)
418
418
}
419
419
#endif
420
420
421
- int fpm_sockets_init_main (void )
421
+ bool fpm_sockets_init_main (void )
422
422
{
423
423
unsigned i , lq_len ;
424
424
struct fpm_worker_pool_s * wp ;
@@ -428,12 +428,12 @@ int fpm_sockets_init_main(void)
428
428
struct listening_socket_s * ls ;
429
429
430
430
if (0 == fpm_array_init (& sockets_list , sizeof (struct listening_socket_s ), 10 )) {
431
- return -1 ;
431
+ return false ;
432
432
}
433
433
434
434
#ifdef SO_SETFIB
435
435
if (fpm_socket_setfib_init () == FAILURE ) {
436
- return -1 ;
436
+ return false ;
437
437
}
438
438
#endif
439
439
@@ -486,17 +486,17 @@ int fpm_sockets_init_main(void)
486
486
487
487
case FPM_AF_UNIX :
488
488
if (0 > fpm_unix_resolve_socket_permissions (wp )) {
489
- return -1 ;
489
+ return false ;
490
490
}
491
491
wp -> listening_socket = fpm_socket_af_unix_listening_socket (wp );
492
492
break ;
493
493
}
494
494
495
495
if (wp -> listening_socket == -1 ) {
496
- return -1 ;
496
+ return false ;
497
497
}
498
498
499
- if (wp -> listen_address_domain == FPM_AF_INET && fpm_socket_get_listening_queue (wp -> listening_socket , NULL , & lq_len ) >= 0 ) {
499
+ if (wp -> listen_address_domain == FPM_AF_INET && fpm_socket_get_listening_queue (wp -> listening_socket , NULL , & lq_len )) {
500
500
fpm_scoreboard_update (-1 , -1 , -1 , (int )lq_len , -1 , -1 , 0 , FPM_SCOREBOARD_ACTION_SET , wp -> scoreboard );
501
501
}
502
502
}
@@ -518,10 +518,7 @@ int fpm_sockets_init_main(void)
518
518
}
519
519
}
520
520
521
- if (!fpm_cleanup_add (FPM_CLEANUP_ALL , fpm_sockets_cleanup , 0 )) {
522
- return -1 ;
523
- }
524
- return 0 ;
521
+ return fpm_cleanup_add (FPM_CLEANUP_ALL , fpm_sockets_cleanup , 0 );
525
522
}
526
523
527
524
#if HAVE_FPM_LQ
@@ -530,18 +527,18 @@ int fpm_sockets_init_main(void)
530
527
531
528
#include <netinet/tcp.h>
532
529
533
- int fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
530
+ bool fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
534
531
{
535
532
struct tcp_info info ;
536
533
socklen_t len = sizeof (info );
537
534
538
535
if (0 > getsockopt (sock , IPPROTO_TCP , TCP_INFO , & info , & len )) {
539
536
zlog (ZLOG_SYSERROR , "failed to retrieve TCP_INFO for socket" );
540
- return -1 ;
537
+ return false ;
541
538
}
542
539
#if defined(__FreeBSD__ ) || defined(__NetBSD__ )
543
540
if (info .__tcpi_sacked == 0 ) {
544
- return -1 ;
541
+ return false ;
545
542
}
546
543
547
544
if (cur_lq ) {
@@ -554,7 +551,7 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
554
551
#else
555
552
/* kernel >= 2.6.24 return non-zero here, that means operation is supported */
556
553
if (info .tcpi_sacked == 0 ) {
557
- return -1 ;
554
+ return false ;
558
555
}
559
556
560
557
if (cur_lq ) {
@@ -566,21 +563,21 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
566
563
}
567
564
#endif
568
565
569
- return 0 ;
566
+ return true ;
570
567
}
571
568
572
569
#elif defined(HAVE_LQ_TCP_CONNECTION_INFO )
573
570
574
571
#include <netinet/tcp.h>
575
572
576
- int fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
573
+ bool fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
577
574
{
578
575
struct tcp_connection_info info ;
579
576
socklen_t len = sizeof (info );
580
577
581
578
if (0 > getsockopt (sock , IPPROTO_TCP , TCP_CONNECTION_INFO , & info , & len )) {
582
579
zlog (ZLOG_SYSERROR , "failed to retrieve TCP_CONNECTION_INFO for socket" );
583
- return -1 ;
580
+ return false ;
584
581
}
585
582
586
583
if (cur_lq ) {
@@ -591,65 +588,65 @@ int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq)
591
588
* max_lq = 0 ;
592
589
}
593
590
594
- return 0 ;
591
+ return true ;
595
592
}
596
593
#endif
597
594
598
595
#ifdef HAVE_LQ_SO_LISTENQ
599
596
600
- int fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
597
+ bool fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
601
598
{
602
599
int val ;
603
600
socklen_t len = sizeof (val );
604
601
605
602
if (cur_lq ) {
606
603
if (0 > getsockopt (sock , SOL_SOCKET , SO_LISTENQLEN , & val , & len )) {
607
- return -1 ;
604
+ return false ;
608
605
}
609
606
610
607
* cur_lq = val ;
611
608
}
612
609
613
610
if (max_lq ) {
614
611
if (0 > getsockopt (sock , SOL_SOCKET , SO_LISTENQLIMIT , & val , & len )) {
615
- return -1 ;
612
+ return false ;
616
613
}
617
614
618
615
* max_lq = val ;
619
616
}
620
617
621
- return 0 ;
618
+ return true ;
622
619
}
623
620
624
621
#endif
625
622
626
623
#else
627
624
628
- int fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
625
+ bool fpm_socket_get_listening_queue (int sock , unsigned * cur_lq , unsigned * max_lq )
629
626
{
630
- return -1 ;
627
+ return false ;
631
628
}
632
629
633
630
#endif
634
631
635
- int fpm_socket_unix_test_connect (struct sockaddr_un * sock , size_t socklen ) /* {{{ */
632
+ bool fpm_socket_unix_test_connect (struct sockaddr_un * sock , size_t socklen ) /* {{{ */
636
633
{
637
634
int fd ;
638
635
639
636
if (!sock || sock -> sun_family != AF_UNIX ) {
640
- return -1 ;
637
+ return false ;
641
638
}
642
639
643
640
if ((fd = socket (AF_UNIX , SOCK_STREAM , 0 )) < 0 ) {
644
- return -1 ;
641
+ return false ;
645
642
}
646
643
647
644
if (connect (fd , (struct sockaddr * )sock , socklen ) == -1 ) {
648
645
close (fd );
649
- return -1 ;
646
+ return false ;
650
647
}
651
648
652
649
close (fd );
653
- return 0 ;
650
+ return true ;
654
651
}
655
652
/* }}} */
0 commit comments