Defines | Functions

modules/tm/timer.c File Reference

TM :: timer support. More...

#include "defs.h"
#include "config.h"
#include "h_table.h"
#include "timer.h"
#include "../../dprint.h"
#include "lock.h"
#include "t_stats.h"
#include "../../hash_func.h"
#include "../../config.h"
#include "../../parser/parser_f.h"
#include "../../ut.h"
#include "../../timer_ticks.h"
#include "../../compiler_opt.h"
#include "../../sr_compat.h"
#include "t_funcs.h"
#include "t_reply.h"
#include "t_cancel.h"
#include "t_hooks.h"
Include dependency graph for modules/tm/timer.c:

Go to the source code of this file.

Defines

Functions


Detailed Description

TM timer support. It has been designed for high performance using some techniques of which timer users need to be aware.

The following example shows it:

PROCESS1 TIMER PROCESS

So be careful when writing the timer handlers. Currently defined timers don't hurt if they hit delayed, I hope at least. Retransmission timer may results in a useless retransmission -- not too bad. FR timer not too bad either as timer processing uses a REPLY mutex making it safe to other processing affecting transaction state. Wait timer not bad either -- processes putting a transaction on wait don't do anything with it anymore.

Example when it does not hurt:

PROCESS1 TIMER PROCESS

The rule of thumb is don't touch data you put under a timer. Create data, put them under a timer, and let them live until they are safely destroyed from wait/delete timer. The only safe place to manipulate the data is from timer process in which delayed timers cannot hit (all timers are processed sequentially).

A "bad example" -- rewriting content of retransmission buffer in an unprotected way is bad because a delayed retransmission timer might hit. Thats why our reply retransmission procedure is enclosed in a REPLY_LOCK.

Definition in file modules/tm/timer.c.


Define Documentation

#define IF_IS_TIMER_NAME (   cell_member,
  cfg_name 
)
Value:
if ((name->len == sizeof(cfg_name)-1) && \
                (memcmp(name->s, cfg_name, sizeof(cfg_name)-1)==0)) { \
                        SIZE_FIT_CHECK(cell_member, t, cfg_name); \
        }

Internal macro for timer_fixup(), performs size fit check if the timer name matches

Definition at line 238 of file modules/tm/timer.c.

Referenced by timer_fixup(), and timer_fixup_ms().

#define SIZE_FIT_CHECK (   cell_member,
  val,
  cfg_name 
)
Value:
if (MAX_UVAR_VALUE(((struct cell*)0)->cell_member) <= (val)){ \
                ERR("tm_init_timers: " cfg_name " too big: %lu (%lu ticks) " \
                                "- max %lu (%lu ticks) \n", TICKS_TO_MS((unsigned long)(val)),\
                                (unsigned long)(val), \
                                TICKS_TO_MS(MAX_UVAR_VALUE(((struct cell*)0)->cell_member)), \
                                MAX_UVAR_VALUE(((struct cell*)0)->cell_member)); \
                goto error; \
        }

Check helper for configuration framework values for internal use The val should be unsigned or positive, use <= instead of < to get read of gcc warning when sizeof(cell_member)==sizeof(val) (Note that this limits maximum value to max. type -1)

Definition at line 169 of file modules/tm/timer.c.

Referenced by tm_init_timers().


Function Documentation

int timer_fixup ( void *  handle,
str gname,
str name,
void **  val 
)

Fixup function for the timer values, (called by the configuration framework)

Parameters:
handle not used
gname not used
name not used
val fixed timer value
Returns:
0 on success, -1 on error

Definition at line 255 of file modules/tm/timer.c.

References IF_IS_TIMER_NAME, and MS_TO_TICKS.

int timer_fixup_ms ( void *  handle,
str gname,
str name,
void **  val 
)

(called by the configuration framework) It checks if the value fits in the tm structures

Definition at line 282 of file modules/tm/timer.c.

References IF_IS_TIMER_NAME.