~alexlawn/php-redis/alex-redis-hmget

« back to all changes in this revision

Viewing changes to redis_cluster.c

  • Committer: GitHub
  • Author(s): Pavlo Yatsukhnenko
  • Date: 2016-09-21 06:18:15 UTC
  • mfrom: (536.1.1)
  • Revision ID: git-v1:1fa240478ff5c1be4dd769c759859b7f66db3526
Merge pull request #953 from yatsukhnenko/develop

Show diffs side-by-side

added added

removed removed

Lines of Context:
2093
2093
    ht_dist = cluster_dist_create();
2094
2094
 
2095
2095
    // Allocate args, and grab them
2096
 
    z_args = emalloc(sizeof(zval)*argc);
2097
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
2096
    z_args = emalloc(sizeof(zval) * argc);
 
2097
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
2098
2098
        efree(z_args);
2099
2099
        cluster_dist_free(ht_dist);
2100
2100
        RETURN_FALSE;
2247
2247
cluster_cmd_get_slot(redisCluster *c, zval *z_arg TSRMLS_DC) 
2248
2248
{
2249
2249
    int key_len, key_free;
2250
 
    zval **z_host, **z_port, *z_tmp = NULL;
 
2250
    zval *z_host, *z_port, *z_tmp = NULL;
2251
2251
    short slot;
2252
2252
    char *key;
2253
2253
 
2279
2279
            efree(z_tmp);
2280
2280
        }
2281
2281
    } else if (Z_TYPE_P(z_arg) == IS_ARRAY && 
2282
 
               zend_hash_index_find(Z_ARRVAL_P(z_arg),0,(void**)&z_host)!=FAILURE &&
2283
 
               zend_hash_index_find(Z_ARRVAL_P(z_arg),1,(void**)&z_port)!=FAILURE &&
2284
 
               Z_TYPE_PP(z_host)==IS_STRING && Z_TYPE_PP(z_port)==IS_LONG)
2285
 
    {
 
2282
                (z_host = zend_hash_index_find(Z_ARRVAL_P(z_arg), 0)) != NULL &&
 
2283
                (z_port = zend_hash_index_find(Z_ARRVAL_P(z_arg), 1)) != NULL &&
 
2284
                Z_TYPE_P(z_host) == IS_STRING && Z_TYPE_P(z_port) == IS_LONG
 
2285
        ) {
2286
2286
        /* Attempt to find this specific node by host:port */
2287
 
        slot = cluster_find_slot(c,(const char *)Z_STRVAL_PP(z_host),
2288
 
            (unsigned short)Z_LVAL_PP(z_port));
 
2287
        slot = cluster_find_slot(c,(const char *)Z_STRVAL_P(z_host),
 
2288
            (unsigned short)Z_LVAL_P(z_port));
2289
2289
 
2290
2290
        /* Inform the caller if they've passed bad data */
2291
2291
        if(slot < 0) { 
2292
2292
            php_error_docref(0 TSRMLS_CC, E_WARNING, "Unknown node %s:%ld",
2293
 
                Z_STRVAL_PP(z_host), Z_LVAL_PP(z_port));
 
2293
                Z_STRVAL_P(z_host), Z_LVAL_P(z_port));
2294
2294
        }
2295
2295
    } else {
2296
2296
        php_error_docref(0 TSRMLS_CC, E_WARNING,
2371
2371
    z_args = emalloc(argc * sizeof(zval));
2372
2372
 
2373
2373
    /* Grab args */
2374
 
    if(zend_get_parameters_array(ht, argc, z_args)==FAILURE) {
 
2374
    if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
2375
2375
        efree(z_args);
2376
2376
        RETURN_FALSE;
2377
2377
    }