Defines | Functions | Variables

tm/sip_msg.h File Reference

TM :: Message cloning functionality. More...

#include "defs.h"
#include "../../parser/msg_parser.h"
#include "../../mem/shm_mem.h"
#include "../../atomic_ops.h"
Include dependency graph for tm/sip_msg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

Functions

Variables


Detailed Description

Cloning a message into shared memory (TM keeps a snapshot of messages in memory); note that many operations, which allocate pkg memory (such as parsing) cannot be used with a cloned message -- it would result in linking pkg structures to shmem msg and eventually in a memory error.

The cloned message is stored in a single memory fragment to save too many shm_mallocs -- these are expensive as they not only take lookup in fragment table but also a shmem lock operation (the same for shm_free)

Allow postponing the cloning of SIP msg: t_newtran() copies the requests to shm mem without the lumps, and t_forward_nonack() clones the lumps later when it is called the first time.

Definition in file tm/sip_msg.h.


Define Documentation

#define _sip_msg_free (   _free_func,
  _p_msg 
)
Value:
do{ \
                        if (_p_msg->first_line.type==SIP_REPLY) { \
                                _free_func( (_p_msg) ); \
                        } else { \
                                membar_depends(); \
                                if ((_p_msg)->add_rm) \
                                        _free_func((_p_msg)->add_rm); \
                                else if ((_p_msg)->body_lumps) \
                                        _free_func((_p_msg)->body_lumps); \
                                else if ((_p_msg)->reply_lump) \
                                        _free_func((_p_msg)->reply_lump); \
                                                                          \
                                _free_func( (_p_msg) ); \
                        } \
                }while(0)

msg is a reply: one memory block was allocated

msg is a request: two memory blocks were allocated:

  • one for the sip_msg struct
  • another one for the lumps which is linked to add_rm, body_lumps, or reply_lump

Definition at line 70 of file tm/sip_msg.h.


Function Documentation

int save_msg_lumps ( struct sip_msg shm_msg,
struct sip_msg pkg_msg 
)
Parameters:
shm_msg SIP message in shared memory
pkg_msg SIP message in private memory
Returns:
0 on success, -1 on error

Definition at line 110 of file tm/sip_msg.c.

References sip_msg::add_rm, sip_msg::body_lumps, sip_msg::first_line, FL_SHM_CLONE, lumps_are_cloned, METHOD_ACK, sip_msg::msg_flags, msg_lump_cloner(), and sip_msg::reply_lump.

Here is the call graph for this function:

struct sip_msg* sip_msg_cloner ( struct sip_msg org_msg,
int *  sip_msg_len 
) [read]
Warning:
Cloner does not clone all hdr_field headers (From, To, etc.). Pointers will reference pkg memory. Dereferencing will crash ser!
Parameters:
org_msg Original SIP message
sip_msg_len Length of the SIP message
Returns:
Cloned SIP message, or NULL on error

Definition at line 86 of file tm/sip_msg.c.

References sip_msg::first_line, and sip_msg_shm_clone().

Here is the call graph for this function: