@@ -61,12 +61,19 @@ static void cp_add_fail_into_mem(zval *conf, char *data_source);
61
61
zval_ptr_dtor(&exception);\
62
62
}while(0);
63
63
64
+ #define CP_TEST_RETURN_FALSE (flag ) ({if(flag==CP_CONNECT_PING){ \
65
+ if(EG(exception)){ \
66
+ zval *exception = EG(exception);\
67
+ zval_ptr_dtor(&exception); \
68
+ EG(exception) = NULL;\
69
+ }\
70
+ return CP_FALSE; \
71
+ }});
72
+
64
73
#define CP_SEND_EXCEPTION do{zval *str;CP_SEND_EXCEPTION_ARGS(&str);zval_ptr_dtor(&str);}while(0);
65
74
#define CP_INTERNAL_NORMAL_SEND_RETURN (send_data )({CP_INTERNAL_NORMAL_SEND(send_data);return CP_TRUE;})
66
75
#define CP_INTERNAL_ERROR_SEND_RETURN (send_data ) ({ CP_INTERNAL_ERROR_SEND(send_data);return CP_FALSE;})
67
76
#define CP_SEND_EXCEPTION_RETURN do{CP_SEND_EXCEPTION;return CP_FALSE;}while(0);
68
-
69
- #define CP_TEST_RETURN_FALSE (flag ) ({if(flag==CP_CONNECT_PING){EG(exception) = NULL;return CP_FALSE;}})
70
77
#define CP_TEST_RETURN_TRUE (flag ) ({if(flag==CP_CONNECT_PING)return CP_TRUE;})
71
78
72
79
#include "zend_exceptions.h"
@@ -406,12 +413,18 @@ int pdo_proxy_connect(zval *args, int flag) {
406
413
if (zend_hash_find (Z_ARRVAL_P (args ), ZEND_STRS ("username" ), (void * * ) & username ) == SUCCESS )
407
414
{
408
415
tmp_pass [1 ] = username ;
416
+ } else
417
+ {
418
+ CP_INTERNAL_ERROR_SEND_RETURN ("username null!" );
409
419
}
410
420
411
421
zval * * password ;
412
422
if (zend_hash_find (Z_ARRVAL_P (args ), ZEND_STRS ("password" ), (void * * ) & password ) == SUCCESS )
413
423
{
414
424
tmp_pass [2 ] = password ;
425
+ } else
426
+ {
427
+ CP_INTERNAL_ERROR_SEND_RETURN ("password null!" );
415
428
}
416
429
417
430
zval * * options ;
@@ -442,6 +455,8 @@ int pdo_proxy_connect(zval *args, int flag) {
442
455
CP_SEND_EXCEPTION_RETURN ;
443
456
} else
444
457
{
458
+ if (flag == CP_CONNECT_PING )
459
+ zval_ptr_dtor (& new_obj );
445
460
CP_TEST_RETURN_TRUE (flag );
446
461
//存起來
447
462
if (zend_hash_add (& pdo_object_table , Z_STRVAL_PP (data_source ), Z_STRLEN_PP (data_source ), (void * ) & new_obj , sizeof (zval * ), NULL ) == SUCCESS )
@@ -650,17 +665,23 @@ int redis_proxy_connect(zval *data_source, zval *args, int flag) {
650
665
651
666
if (zend_hash_find (CG (class_table ), ZEND_STRS ("redis" ), (void * * ) & redis_ce ) == FAILURE )
652
667
{
653
- cpLog ("redis class ce error\n " );
668
+ CP_INTERNAL_ERROR_SEND_RETURN ("redis extension is not install " );
654
669
}
655
670
object_init_ex (new_obj , * redis_ce );
656
671
657
672
if (zend_hash_index_find (Z_ARRVAL_P (ex_arr ), 0 , (void * * ) & ip ) == SUCCESS )
658
673
{
659
674
tmp_pass [0 ] = ip ;
675
+ } else
676
+ {
677
+ CP_INTERNAL_ERROR_SEND_RETURN ("redis ip null!" );
660
678
}
661
679
if (zend_hash_index_find (Z_ARRVAL_P (ex_arr ), 1 , (void * * ) & port ) == SUCCESS )
662
680
{
663
681
tmp_pass [1 ] = port ;
682
+ } else
683
+ {
684
+ CP_INTERNAL_ERROR_SEND_RETURN ("redis ip null!" );
664
685
}
665
686
666
687
zval * timeout ;
@@ -696,7 +717,13 @@ int redis_proxy_connect(zval *data_source, zval *args, int flag) {
696
717
cp_add_fail_into_mem (args , Z_STRVAL_P (data_source ));
697
718
CP_SEND_EXCEPTION_RETURN ;
698
719
}
699
- CP_TEST_RETURN_TRUE (flag );
720
+ if (flag == CP_CONNECT_PING )
721
+ {
722
+ zval_ptr_dtor (& new_obj );
723
+ zval_ptr_dtor (& ex_arr );
724
+ return CP_TRUE ;
725
+ }
726
+
700
727
if (zend_hash_index_find (Z_ARRVAL_P (ex_arr ), 2 , (void * * ) & db ) == SUCCESS )
701
728
{
702
729
if (!cp_redis_select (new_obj , db ))
@@ -826,11 +853,13 @@ static void cp_add_fail_into_mem(zval *o_arg, char *data_source) {
826
853
zval * arr = CP_PING_GET_PRO (CPGL .ping_mem_addr );
827
854
if (Z_TYPE_P (arr ) == IS_NULL )
828
855
{
829
- zval first_arr ;
830
- array_init (& first_arr );
856
+ zval * first_arr ;
857
+ MAKE_STD_ZVAL (first_arr );
858
+ array_init (first_arr );
831
859
add_assoc_long (args , "count" , 1 );
832
- add_assoc_zval (& first_arr , data_source , args );
833
- cp_ser_and_setpro (& first_arr );
860
+ add_assoc_zval (first_arr , data_source , args );
861
+ cp_ser_and_setpro (first_arr );
862
+ zval_ptr_dtor (& first_arr );
834
863
} else if (Z_TYPE_P (arr ) != IS_BOOL )
835
864
{
836
865
zval * * zval_source ;
0 commit comments