@@ -3645,8 +3645,8 @@ static PHP_METHOD(swoole_server, bind) {
3645
3645
RETURN_FALSE;
3646
3646
}
3647
3647
3648
- Connection *conn = serv->get_connection_by_session_id (fd);
3649
- if (conn == nullptr || conn-> active == 0 ) {
3648
+ Connection *conn = serv->get_connection_verify (fd);
3649
+ if (conn == nullptr ) {
3650
3650
RETURN_FALSE;
3651
3651
}
3652
3652
@@ -3751,10 +3751,10 @@ static PHP_METHOD(swoole_server, getClientList) {
3751
3751
RETURN_FALSE;
3752
3752
}
3753
3753
3754
- zend_long start_fd = 0 ;
3754
+ zend_long start_session_id = 0 ;
3755
3755
zend_long find_count = 10 ;
3756
3756
3757
- if (zend_parse_parameters (ZEND_NUM_ARGS (), " |ll" , &start_fd , &find_count) == FAILURE) {
3757
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), " |ll" , &start_session_id , &find_count) == FAILURE) {
3758
3758
RETURN_FALSE;
3759
3759
}
3760
3760
@@ -3766,12 +3766,13 @@ static PHP_METHOD(swoole_server, getClientList) {
3766
3766
3767
3767
// copy it out to avoid being overwritten by other processes
3768
3768
int serv_max_fd = serv->get_maxfd ();
3769
+ int start_fd;
3769
3770
3770
- if (start_fd == 0 ) {
3771
+ if (start_session_id == 0 ) {
3771
3772
start_fd = serv->get_minfd ();
3772
3773
} else {
3773
- Connection *conn = serv->get_connection_by_session_id (start_fd );
3774
- if (!conn) {
3774
+ Connection *conn = serv->get_connection_verify (start_session_id );
3775
+ if (!serv-> is_valid_connection ( conn) ) {
3775
3776
RETURN_FALSE;
3776
3777
}
3777
3778
start_fd = conn->fd ;
@@ -3786,10 +3787,10 @@ static PHP_METHOD(swoole_server, getClientList) {
3786
3787
Connection *conn;
3787
3788
3788
3789
for (; fd <= serv_max_fd; fd++) {
3789
- swTrace (" maxfd=%d, fd=%d, find_count=%ld, start_fd=%ld" , serv_max_fd, fd, find_count, start_fd );
3790
+ swTrace (" maxfd=%d, fd=%d, find_count=%ld, start_fd=%ld" , serv_max_fd, fd, find_count, start_session_id );
3790
3791
conn = serv->get_connection (fd);
3791
3792
3792
- if (conn-> active && ! conn-> closed ) {
3793
+ if (serv-> is_valid_connection ( conn) ) {
3793
3794
#ifdef SW_USE_OPENSSL
3794
3795
if (conn->ssl && !conn->ssl_ready ) {
3795
3796
continue ;
@@ -3842,18 +3843,14 @@ static PHP_METHOD(swoole_server, exists) {
3842
3843
RETURN_FALSE;
3843
3844
}
3844
3845
3845
- zend_long fd ;
3846
+ zend_long session_id ;
3846
3847
3847
3848
ZEND_PARSE_PARAMETERS_START (1 , 1 )
3848
- Z_PARAM_LONG (fd )
3849
+ Z_PARAM_LONG (session_id )
3849
3850
ZEND_PARSE_PARAMETERS_END_EX (RETURN_FALSE);
3850
3851
3851
- Connection *conn = serv->get_connection_by_session_id (fd);
3852
- if (!conn) {
3853
- RETURN_FALSE;
3854
- }
3855
- // connection is closed
3856
- if (conn->active == 0 || conn->closed ) {
3852
+ Connection *conn = serv->get_connection_verify (session_id);
3853
+ if (!conn || conn->closed ) {
3857
3854
RETURN_FALSE;
3858
3855
} else {
3859
3856
RETURN_TRUE;
@@ -3867,19 +3864,15 @@ static PHP_METHOD(swoole_server, protect) {
3867
3864
RETURN_FALSE;
3868
3865
}
3869
3866
3870
- zend_long fd ;
3867
+ zend_long session_id ;
3871
3868
zend_bool value = 1 ;
3872
3869
3873
- if (zend_parse_parameters (ZEND_NUM_ARGS (), " l|b" , &fd , &value) == FAILURE) {
3870
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), " l|b" , &session_id , &value) == FAILURE) {
3874
3871
RETURN_FALSE;
3875
3872
}
3876
3873
3877
- Connection *conn = serv->get_connection_by_session_id (fd);
3878
- if (!conn) {
3879
- RETURN_FALSE;
3880
- }
3881
- // connection is closed
3882
- if (conn->active == 0 || conn->closed ) {
3874
+ Connection *conn = serv->get_connection_verify (session_id);
3875
+ if (!conn || conn->closed ) {
3883
3876
RETURN_FALSE;
3884
3877
} else {
3885
3878
conn->protect = value;
0 commit comments