@@ -67,7 +67,7 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts TSRMLS_DC)
6767 call_user_function (& redis_ce -> function_table , & ra -> redis [i ], & z_cons , & z_ret , 0 , NULL TSRMLS_CC );
6868
6969 /* create socket */
70- redis_sock = redis_sock_create (host , host_len , port , 0 , 0 , NULL ); /* TODO: persistence? */
70+ redis_sock = redis_sock_create (host , host_len , port , 0 , ra -> pconnect , NULL ); /* TODO: persistence? */
7171
7272 /* connect */
7373 redis_sock_server_open (redis_sock , 1 TSRMLS_CC );
@@ -157,9 +157,10 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
157157 zval * z_params_funs , * * z_data_pp , * z_fun = NULL , * z_dist = NULL ;
158158 zval * z_params_index ;
159159 zval * z_params_autorehash ;
160+ zval * z_params_pconnect ;
160161 RedisArray * ra = NULL ;
161162
162- zend_bool b_index = 0 , b_autorehash = 0 ;
163+ zend_bool b_index = 0 , b_autorehash = 0 , b_pconnect ;
163164 HashTable * hHosts = NULL , * hPrev = NULL ;
164165
165166 /* find entry */
@@ -222,8 +223,18 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
222223 }
223224 }
224225
226+ /* pconnect option */
227+ MAKE_STD_ZVAL (z_params_pconnect );
228+ array_init (z_params_pconnect );
229+ sapi_module .treat_data (PARSE_STRING , estrdup (INI_STR ("redis.arrays.pconnect" )), z_params_pconnect TSRMLS_CC );
230+ if (zend_hash_find (Z_ARRVAL_P (z_params_pconnect ), name , strlen (name ) + 1 , (void * * ) & z_data_pp ) != FAILURE ) {
231+ if (Z_TYPE_PP (z_data_pp ) == IS_STRING && strncmp (Z_STRVAL_PP (z_data_pp ), "1" , 1 ) == 0 ) {
232+ b_pconnect = 1 ;
233+ }
234+ }
235+
225236 /* create RedisArray object */
226- ra = ra_make_array (hHosts , z_fun , z_dist , hPrev , b_index TSRMLS_CC );
237+ ra = ra_make_array (hHosts , z_fun , z_dist , hPrev , b_index , b_pconnect TSRMLS_CC );
227238 ra -> auto_rehash = b_autorehash ;
228239
229240 /* cleanup */
@@ -242,7 +253,7 @@ RedisArray *ra_load_array(const char *name TSRMLS_DC) {
242253}
243254
244255RedisArray *
245- ra_make_array (HashTable * hosts , zval * z_fun , zval * z_dist , HashTable * hosts_prev , zend_bool b_index TSRMLS_DC ) {
256+ ra_make_array (HashTable * hosts , zval * z_fun , zval * z_dist , HashTable * hosts_prev , zend_bool b_index , zend_bool b_pconnect TSRMLS_DC ) {
246257
247258 int count = zend_hash_num_elements (hosts );
248259
@@ -256,14 +267,15 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
256267 ra -> z_multi_exec = NULL ;
257268 ra -> index = b_index ;
258269 ra -> auto_rehash = 0 ;
270+ ra -> pconnect = b_pconnect ;
259271
260272 /* init array data structures */
261273 ra_init_function_table (ra );
262274
263275 if (NULL == ra_load_hosts (ra , hosts TSRMLS_CC )) {
264276 return NULL ;
265277 }
266- ra -> prev = hosts_prev ? ra_make_array (hosts_prev , z_fun , z_dist , NULL , b_index TSRMLS_CC ) : NULL ;
278+ ra -> prev = hosts_prev ? ra_make_array (hosts_prev , z_fun , z_dist , NULL , b_index , b_pconnect TSRMLS_CC ) : NULL ;
267279
268280 /* copy function if provided */
269281 if (z_fun ) {
0 commit comments