@@ -1772,7 +1772,6 @@ PHP_METHOD(Memcached, addServers)
1772
1772
Returns the list of the memcache servers in use */
1773
1773
PHP_METHOD (Memcached , getServerList )
1774
1774
{
1775
- zval * array ;
1776
1775
struct callbackContext context = {0 };
1777
1776
memcached_server_function callbacks [1 ];
1778
1777
MEMC_METHOD_INIT_VARS ;
@@ -1785,7 +1784,6 @@ PHP_METHOD(Memcached, getServerList)
1785
1784
1786
1785
callbacks [0 ] = php_memc_do_serverlist_callback ;
1787
1786
array_init (return_value );
1788
- context .array = array ;
1789
1787
context .return_value = return_value ;
1790
1788
memcached_server_cursor (m_obj -> memc , callbacks , & context , 1 );
1791
1789
}
@@ -1833,7 +1831,6 @@ PHP_METHOD(Memcached, getStats)
1833
1831
{
1834
1832
memcached_stat_st * stats ;
1835
1833
memcached_return status ;
1836
- zval * entry ;
1837
1834
struct callbackContext context = {0 };
1838
1835
memcached_server_function callbacks [1 ];
1839
1836
MEMC_METHOD_INIT_VARS ;
@@ -1857,7 +1854,6 @@ PHP_METHOD(Memcached, getStats)
1857
1854
1858
1855
callbacks [0 ] = php_memc_do_stats_callback ;
1859
1856
context .i = 0 ;
1860
- context .entry = entry ;
1861
1857
context .stats = stats ;
1862
1858
context .return_value = return_value ;
1863
1859
memcached_server_cursor (m_obj -> memc , callbacks , & context , 1 );
@@ -2349,13 +2345,14 @@ ZEND_RSRC_DTOR_FUNC(php_memc_dtor)
2349
2345
static memcached_return php_memc_do_serverlist_callback (const memcached_st * ptr , memcached_server_instance_st instance , void * in_context )
2350
2346
{
2351
2347
struct callbackContext * context = (struct callbackContext * ) in_context ;
2348
+ zval * array ;
2352
2349
2353
- MAKE_STD_ZVAL (context -> array );
2354
- array_init (context -> array );
2355
- add_assoc_string (context -> array , "host" , instance -> hostname , 1 );
2356
- add_assoc_long (context -> array , "port" , instance -> port );
2357
- add_assoc_long (context -> array , "weight" , instance -> weight );
2358
- add_next_index_zval (context -> return_value , context -> array );
2350
+ MAKE_STD_ZVAL (array );
2351
+ array_init (array );
2352
+ add_assoc_string (array , "host" , instance -> hostname , 1 );
2353
+ add_assoc_long (array , "port" , instance -> port );
2354
+ add_assoc_long (array , "weight" , instance -> weight );
2355
+ add_next_index_zval (context -> return_value , array );
2359
2356
return MEMCACHED_SUCCESS ;
2360
2357
}
2361
2358
@@ -2364,37 +2361,38 @@ static memcached_return php_memc_do_stats_callback(const memcached_st *ptr, memc
2364
2361
char * hostport = NULL ;
2365
2362
int hostport_len ;
2366
2363
struct callbackContext * context = (struct callbackContext * ) in_context ;
2364
+ zval * entry ;
2367
2365
hostport_len = spprintf (& hostport , 0 , "%s:%d" , instance -> hostname , instance -> port );
2368
2366
2369
- MAKE_STD_ZVAL (context -> entry );
2370
- array_init (context -> entry );
2371
-
2372
- add_assoc_long (context -> entry , "pid" , context -> stats [context -> i ].pid );
2373
- add_assoc_long (context -> entry , "uptime" , context -> stats [context -> i ].uptime );
2374
- add_assoc_long (context -> entry , "threads" , context -> stats [context -> i ].threads );
2375
- add_assoc_long (context -> entry , "time" , context -> stats [context -> i ].time );
2376
- add_assoc_long (context -> entry , "pointer_size" , context -> stats [context -> i ].pointer_size );
2377
- add_assoc_long (context -> entry , "rusage_user_seconds" , context -> stats [context -> i ].rusage_user_seconds );
2378
- add_assoc_long (context -> entry , "rusage_user_microseconds" , context -> stats [context -> i ].rusage_user_microseconds );
2379
- add_assoc_long (context -> entry , "rusage_system_seconds" , context -> stats [context -> i ].rusage_system_seconds );
2380
- add_assoc_long (context -> entry , "rusage_system_microseconds" , context -> stats [context -> i ].rusage_system_microseconds );
2381
- add_assoc_long (context -> entry , "curr_items" , context -> stats [context -> i ].curr_items );
2382
- add_assoc_long (context -> entry , "total_items" , context -> stats [context -> i ].total_items );
2383
- add_assoc_long (context -> entry , "limit_maxbytes" , context -> stats [context -> i ].limit_maxbytes );
2384
- add_assoc_long (context -> entry , "curr_connections" , context -> stats [context -> i ].curr_connections );
2385
- add_assoc_long (context -> entry , "total_connections" , context -> stats [context -> i ].total_connections );
2386
- add_assoc_long (context -> entry , "connection_structures" , context -> stats [context -> i ].connection_structures );
2387
- add_assoc_long (context -> entry , "bytes" , context -> stats [context -> i ].bytes );
2388
- add_assoc_long (context -> entry , "cmd_get" , context -> stats [context -> i ].cmd_get );
2389
- add_assoc_long (context -> entry , "cmd_set" , context -> stats [context -> i ].cmd_set );
2390
- add_assoc_long (context -> entry , "get_hits" , context -> stats [context -> i ].get_hits );
2391
- add_assoc_long (context -> entry , "get_misses" , context -> stats [context -> i ].get_misses );
2392
- add_assoc_long (context -> entry , "evictions" , context -> stats [context -> i ].evictions );
2393
- add_assoc_long (context -> entry , "bytes_read" , context -> stats [context -> i ].bytes_read );
2394
- add_assoc_long (context -> entry , "bytes_written" , context -> stats [context -> i ].bytes_written );
2395
- add_assoc_stringl (context -> entry , "version" , context -> stats [context -> i ].version , strlen (context -> stats [context -> i ].version ), 1 );
2396
-
2397
- add_assoc_zval_ex (context -> return_value , hostport , hostport_len + 1 , context -> entry );
2367
+ MAKE_STD_ZVAL (entry );
2368
+ array_init (entry );
2369
+
2370
+ add_assoc_long (entry , "pid" , context -> stats [context -> i ].pid );
2371
+ add_assoc_long (entry , "uptime" , context -> stats [context -> i ].uptime );
2372
+ add_assoc_long (entry , "threads" , context -> stats [context -> i ].threads );
2373
+ add_assoc_long (entry , "time" , context -> stats [context -> i ].time );
2374
+ add_assoc_long (entry , "pointer_size" , context -> stats [context -> i ].pointer_size );
2375
+ add_assoc_long (entry , "rusage_user_seconds" , context -> stats [context -> i ].rusage_user_seconds );
2376
+ add_assoc_long (entry , "rusage_user_microseconds" , context -> stats [context -> i ].rusage_user_microseconds );
2377
+ add_assoc_long (entry , "rusage_system_seconds" , context -> stats [context -> i ].rusage_system_seconds );
2378
+ add_assoc_long (entry , "rusage_system_microseconds" , context -> stats [context -> i ].rusage_system_microseconds );
2379
+ add_assoc_long (entry , "curr_items" , context -> stats [context -> i ].curr_items );
2380
+ add_assoc_long (entry , "total_items" , context -> stats [context -> i ].total_items );
2381
+ add_assoc_long (entry , "limit_maxbytes" , context -> stats [context -> i ].limit_maxbytes );
2382
+ add_assoc_long (entry , "curr_connections" , context -> stats [context -> i ].curr_connections );
2383
+ add_assoc_long (entry , "total_connections" , context -> stats [context -> i ].total_connections );
2384
+ add_assoc_long (entry , "connection_structures" , context -> stats [context -> i ].connection_structures );
2385
+ add_assoc_long (entry , "bytes" , context -> stats [context -> i ].bytes );
2386
+ add_assoc_long (entry , "cmd_get" , context -> stats [context -> i ].cmd_get );
2387
+ add_assoc_long (entry , "cmd_set" , context -> stats [context -> i ].cmd_set );
2388
+ add_assoc_long (entry , "get_hits" , context -> stats [context -> i ].get_hits );
2389
+ add_assoc_long (entry , "get_misses" , context -> stats [context -> i ].get_misses );
2390
+ add_assoc_long (entry , "evictions" , context -> stats [context -> i ].evictions );
2391
+ add_assoc_long (entry , "bytes_read" , context -> stats [context -> i ].bytes_read );
2392
+ add_assoc_long (entry , "bytes_written" , context -> stats [context -> i ].bytes_written );
2393
+ add_assoc_stringl (entry , "version" , context -> stats [context -> i ].version , strlen (context -> stats [context -> i ].version ), 1 );
2394
+
2395
+ add_assoc_zval_ex (context -> return_value , hostport , hostport_len + 1 , entry );
2398
2396
efree (hostport );
2399
2397
2400
2398
/* Increment the server count in our context structure. Failure to do so will cause only the stats for the last server to get displayed. */
0 commit comments