Browse code

core: wheel timer advertised as secondary timer

- safety checks when running wtimer functions

Daniel-Constantin Mierla authored on 21/01/2016 13:44:44
Showing 1 changed files
... ...
@@ -304,7 +304,7 @@ int sr_wtimer_init(void)
304 304
 	if(_sr_wtimer!=NULL)
305 305
 		return 0;
306 306
 	_sr_wtimer = (sr_wtimer_t *)pkg_malloc(sizeof(sr_wtimer_t));
307
-	if(_sr_wtimer!=NULL) {
307
+	if(_sr_wtimer==NULL) {
308 308
 		LM_ERR("no more pkg memory\n");
309 309
 		return -1;
310 310
 	}
... ...
@@ -320,7 +320,7 @@ int sr_wtimer_init(void)
320 320
 int sr_wtimer_add(timer_function* f, void* param, int interval)
321 321
 {
322 322
 	sr_wtimer_node_t *wt;
323
-	if(_sr_wtimer!=NULL) {
323
+	if(_sr_wtimer==NULL) {
324 324
 		LM_ERR("wtimer not intialized\n");
325 325
 		return -1;
326 326
 	}
... ...
@@ -351,7 +351,7 @@ void sr_wtimer_exec(unsigned int ticks, void *param)
351 351
 	uint32_t i;
352 352
 	uint32_t c;
353 353
 
354
-	if(_sr_wtimer!=NULL) {
354
+	if(_sr_wtimer==NULL) {
355 355
 		LM_ERR("wtimer not intialized\n");
356 356
 		return;
357 357
 	}
... ...
@@ -376,12 +376,12 @@ void sr_wtimer_exec(unsigned int ticks, void *param)
376 376
  */
377 377
 int sr_wtimer_start(void)
378 378
 {
379
-	if(_sr_wtimer!=NULL) {
379
+	if(_sr_wtimer==NULL) {
380 380
 		LM_ERR("wtimer not intialized\n");
381 381
 		return -1;
382 382
 	}
383 383
 
384
-	if(fork_sync_timer(-1 /*PROC_TIMER*/, "WTIMER", 1,
384
+	if(fork_sync_timer(-1 /*PROC_TIMER*/, "secondary timer", 1,
385 385
 				sr_wtimer_exec, NULL, 1)<0) {
386 386
 		LM_ERR("wtimer starting failed\n");
387 387
 		return -1;