@@ -42,24 +42,14 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b
42
42
ZVAL_STRINGL (& z_cons , "__construct" , 11 );
43
43
44
44
/* init connections */
45
- for (zend_hash_internal_pointer_reset (hosts ); zend_hash_has_more_elements (hosts ) == SUCCESS ; zend_hash_move_forward (hosts ))
46
- {
47
- if ((zpData = zend_hash_get_current_data (hosts )) == NULL || Z_TYPE_P (zpData ) != IS_STRING )
48
- {
45
+ for (zend_hash_internal_pointer_reset (hosts );
46
+ zend_hash_has_more_elements (hosts ) == SUCCESS ;
47
+ zend_hash_move_forward (hosts )
48
+ ) {
49
+ if ((zpData = zend_hash_get_current_data (hosts )) == NULL || Z_TYPE_P (zpData ) != IS_STRING ) {
49
50
zval_dtor (& z_cons );
50
- for (i = 0 ;i < ra -> count ;i ++ ) {
51
- zval_dtor (& ra -> redis [i ]);
52
- efree (ra -> hosts [i ]);
53
- }
54
- efree (ra -> redis );
55
- efree (ra -> hosts );
56
- zval_dtor (& ra -> z_pure_cmds );
57
- zval_dtor (& ra -> z_dist );
58
- zval_dtor (& ra -> z_fun );
59
- efree (ra );
60
- return NULL ;
61
- }
62
-
51
+ return NULL ;
52
+ }
63
53
64
54
/* default values */
65
55
host = Z_STRVAL_P (zpData );
@@ -272,15 +262,12 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
272
262
sapi_module .treat_data (PARSE_STRING , estrdup (iptr ), & z_params_retry_interval TSRMLS_CC );
273
263
}
274
264
if ((z_data = zend_hash_str_find (Z_ARRVAL (z_params_retry_interval ), name , name_len )) != NULL ) {
275
- if (Z_TYPE_P (z_data ) == IS_LONG || Z_TYPE_P (z_data ) == IS_STRING ) {
276
- if (Z_TYPE_P (z_data ) == IS_LONG ) {
277
- l_retry_interval = Z_LVAL_P (z_data );
278
- }
279
- else {
280
- l_retry_interval = atol (Z_STRVAL_P (z_data ));
281
- }
282
- }
283
- }
265
+ if (Z_TYPE_P (z_data ) == IS_LONG ) {
266
+ l_retry_interval = Z_LVAL_P (z_data );
267
+ } else if (Z_TYPE_P (z_data ) == IS_STRING ) {
268
+ l_retry_interval = atol (Z_STRVAL_P (z_data ));
269
+ }
270
+ }
284
271
285
272
/* find pconnect option */
286
273
array_init (& z_params_pconnect );
@@ -310,19 +297,14 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
310
297
sapi_module .treat_data (PARSE_STRING , estrdup (iptr ), & z_params_connect_timeout TSRMLS_CC );
311
298
}
312
299
if ((z_data = zend_hash_str_find (Z_ARRVAL (z_params_connect_timeout ), name , name_len )) != NULL ) {
313
- if (Z_TYPE_P (z_data ) == IS_DOUBLE ||
314
- Z_TYPE_P (z_data ) == IS_STRING ||
315
- Z_TYPE_P (z_data ) == IS_LONG
316
- ) {
317
- if (Z_TYPE_P (z_data ) == IS_DOUBLE ) {
318
- d_connect_timeout = Z_DVAL_P (z_data );
319
- } else if (Z_TYPE_P (z_data ) == IS_LONG ) {
320
- d_connect_timeout = Z_LVAL_P (z_data );
321
- } else {
322
- d_connect_timeout = atof (Z_STRVAL_P (z_data ));
323
- }
324
- }
325
- }
300
+ if (Z_TYPE_P (z_data ) == IS_DOUBLE ) {
301
+ d_connect_timeout = Z_DVAL_P (z_data );
302
+ } else if (Z_TYPE_P (z_data ) == IS_STRING ) {
303
+ d_connect_timeout = atof (Z_STRVAL_P (z_data ));
304
+ } else if (Z_TYPE_P (z_data ) == IS_LONG ) {
305
+ d_connect_timeout = Z_LVAL_P (z_data );
306
+ }
307
+ }
326
308
327
309
/* create RedisArray object */
328
310
ra = ra_make_array (hHosts , & z_fun , & z_dist , hPrev , b_index , b_pconnect , l_retry_interval , b_lazy_connect , d_connect_timeout TSRMLS_CC );
@@ -351,7 +333,7 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
351
333
RedisArray *
352
334
ra_make_array (HashTable * hosts , zval * z_fun , zval * z_dist , HashTable * hosts_prev , zend_bool b_index , zend_bool b_pconnect , long retry_interval , zend_bool b_lazy_connect , double connect_timeout TSRMLS_DC ) {
353
335
354
- int count ;
336
+ int i , count ;
355
337
RedisArray * ra ;
356
338
357
339
if (!hosts ) return NULL ;
@@ -368,13 +350,20 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
368
350
ra -> pconnect = b_pconnect ;
369
351
ra -> connect_timeout = connect_timeout ;
370
352
371
- /* init array data structures */
372
- ra_init_function_table (ra );
353
+ if (ra_load_hosts (ra , hosts , retry_interval , b_lazy_connect TSRMLS_CC ) == NULL ) {
354
+ for (i = 0 ; i < ra -> count ; ++ i ) {
355
+ zval_dtor (& ra -> redis [i ]);
356
+ efree (ra -> hosts [i ]);
357
+ }
358
+ efree (ra -> redis );
359
+ efree (ra -> hosts );
360
+ efree (ra );
361
+ return NULL ;
362
+ }
363
+ ra -> prev = hosts_prev ? ra_make_array (hosts_prev , z_fun , z_dist , NULL , b_index , b_pconnect , retry_interval , b_lazy_connect , connect_timeout TSRMLS_CC ) : NULL ;
373
364
374
- if (NULL == ra_load_hosts (ra , hosts , retry_interval , b_lazy_connect TSRMLS_CC )) {
375
- return NULL ;
376
- }
377
- ra -> prev = hosts_prev ? ra_make_array (hosts_prev , z_fun , z_dist , NULL , b_index , b_pconnect , retry_interval , b_lazy_connect , connect_timeout TSRMLS_CC ) : NULL ;
365
+ /* init array data structures */
366
+ ra_init_function_table (ra );
378
367
379
368
/* Set hash function and distribtor if provided */
380
369
ZVAL_ZVAL (& ra -> z_fun , z_fun , 1 , 0 );
0 commit comments