| 249 | |
| 250 | |
| 251 | int init_stats_collector(void) |
| 252 | { |
| 253 | module_stats *dy_mod; |
| 254 | |
| 255 | /* init the collector */ |
| 256 | collector = (stats_collector*)shm_malloc_unsafe(sizeof(stats_collector)); |
| 257 | if (collector==0) { |
| 258 | LM_ERR("no more shm mem\n"); |
| 259 | goto error; |
| 260 | } |
| 261 | memset( collector, 0 , sizeof(stats_collector)); |
| 262 | |
| 263 | /* |
| 264 | * register shm statistics in an unsafe manner, as some allocators |
| 265 | * would actually attempt to update these statistics |
| 266 | * during their "safe" allocations -- Liviu |
| 267 | */ |
| 268 | if (__register_module_stats( "shmem", shm_stats, 1) != 0) { |
| 269 | LM_ERR("failed to register sh_mem statistics\n"); |
| 270 | goto error; |
| 271 | } |
| 272 | |
| 273 | if (__register_module_stats( "rpmem", rpm_stats, 1) != 0) { |
| 274 | LM_ERR("failed to register rp_mem statistics\n"); |
| 275 | goto error; |
| 276 | } |
| 277 | |
| 278 | stats_ready = 1; |
| 279 | |
| 280 | #ifdef NO_ATOMIC_OPS |
| 281 | /* init BIG (really BIG) lock */ |
| 282 | stat_lock = lock_alloc(); |
| 283 | if (stat_lock==0 || lock_init( stat_lock )==0 ) { |
| 284 | LM_ERR("failed to init the really BIG lock\n"); |
| 285 | goto error; |
| 286 | } |
| 287 | #endif |
| 288 | |
| 289 | collector->rwl = (void*)lock_init_rw(); |
| 290 | if (collector->rwl==NULL) { |
| 291 | LM_ERR("failed to create RW lock dynamic stats\n"); |
| 292 | goto error; |
| 293 | } |
| 294 | |
| 295 | /* register MI commands */ |
| 296 | if (register_mi_mod( "statistics", mi_stat_cmds)<0) { |
| 297 | LM_ERR("unable to register MI cmds\n"); |
| 298 | goto error; |
| 299 | } |
| 300 | |
| 301 | /* register core statistics */ |
| 302 | if (register_module_stats( "core", core_stats)!=0 ) { |
| 303 | LM_ERR("failed to register core statistics\n"); |
| 304 | goto error; |
| 305 | } |
| 306 | |
| 307 | /* register network-level statistics */ |
| 308 | if (register_module_stats( "net", net_stats)!=0 ) { |
no test coverage detected