Module: sip-router
Branch: master
Commit: 949e1f3c3e1f1afa02c696403399a093905c3f0a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=949e1f3…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Sep 19 15:45:43 2013 +0200
parser: refactored a bit sip_msg_t struct for extra fields needed per process
- a new structure to keep cached decoded flow for outbound, previously
was declared inline
- easier to reset it for shm clone and tm faked environment
- new fields that are needed inside the sip_msg_t but not cloned in shm,
must be added in the msg_ldata_t structure, accessible via ldv field
---
parser/msg_parser.c | 11 +++++++++++
parser/msg_parser.h | 25 +++++++++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index 02ad583..1631401 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -734,6 +734,7 @@ void free_sip_msg(struct sip_msg* const msg)
if (msg->add_rm) free_lump_list(msg->add_rm);
if (msg->body_lumps) free_lump_list(msg->body_lumps);
if (msg->reply_lump) free_reply_lump(msg->reply_lump);
+ msg_ldata_reset(msg);
/* don't free anymore -- now a pointer to a static buffer */
# ifdef DYN_BUF
pkg_free(msg->buf);
@@ -952,6 +953,16 @@ void reset_ua(struct sip_msg* const msg)
msg->location_ua.len = 0;
}
+/**
+ * reset content of msg->ldv (msg_ldata_t structure)
+ */
+void msg_ldata_reset(sip_msg_t *msg)
+{
+ if(msg==NULL)
+ return;
+ memset(&msg->ldv, 0, sizeof(msg_ldata_t));
+}
+
hdr_field_t* get_hdr(const sip_msg_t* const msg, const enum _hdr_types_t ht)
{
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 08b76ed..d6df9b3 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -253,6 +253,19 @@ typedef struct msg_body {
/* pre-declaration, to include sys/time.h in .c */
struct timeval;
+/* structure for cached decoded flow for outbound */
+typedef struct ocd_flow {
+ int decoded;
+ struct receive_info rcv;
+} ocd_flow_t;
+
+/* structure holding fields that don't have to be cloned in shm
+ * - its content is memset'ed to in shm clone
+ * - add to msg_ldata_reset() if a field uses dynamic memory */
+typedef struct msg_ldata {
+ ocd_flow_t flow;
+} msg_ldata_t;
+
/*! \brief The SIP message */
typedef struct sip_msg {
unsigned int id; /*!< message id, unique/process*/
@@ -363,10 +376,9 @@ typedef struct sip_msg {
str ruid;
str location_ua;
- struct {
- int decoded;
- struct receive_info rcv;
- } flow;
+ /* structure with fields that are needed for local processing
+ * - not cloned to shm, reset to 0 in the clone */
+ msg_ldata_t ldv;
/* IMPORTANT: when adding new fields in this structure (sip_msg_t),
* be sure it is freed in free_sip_msg() and it is cloned or reset
@@ -514,4 +526,9 @@ int msg_ctx_id_match(const sip_msg_t* const msg, const msg_ctx_id_t*
const mid);
*/
int msg_set_time(sip_msg_t* const msg);
+/**
+ * reset content of msg->ldv (msg_ldata_t structure)
+ */
+void msg_ldata_reset(sip_msg_t*);
+
#endif