Module: sip-router
Branch: tmp/k3.0_sr_backports
Commit: 6b109fa2ae51e1b5676d163f015c8cda7ea4eef6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6b109fa…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Feb 1 18:20:10 2010 +0100
core: stats events cbs are called only if USE_CORE_STATS is defined
Use macros instead of triggering directly various SREV_CORE_STATS
callbacks. This way if compiled without core stats support
(USE_CORE_STATS), there will be no performance impact (the macros
will be empty). All the macros are defined in core_stats.h.
---
core_stats.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++
forward.c | 11 ++++--
parser/msg_parser.c | 4 +-
parser/parse_uri.c | 4 +-
receive.c | 13 ++++---
5 files changed, 117 insertions(+), 14 deletions(-)
diff --git a/core_stats.h b/core_stats.h
new file mode 100644
index 0000000..729d73e
--- /dev/null
+++ b/core_stats.h
@@ -0,0 +1,99 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/** macros used for various core statistics.
+ * (if USE_CORE_STATS is not defined they won't do anything)
+ * @file core_stats.h
+ * @ingroup core
+ */
+/*
+ * History:
+ * --------
+ * 2010-02-01 initial version (andrei)
+*/
+
+#ifndef __core_stats_h
+#define __core_stats_h
+
+/* define USE_CORE_STATS to enable statistics events
+ (SREV_CORE_STATS callbacks) */
+/*#define USE_CORE_STATS */
+
+#ifndef USE_CORE_STATS
+
+#define STATS_REQ_FWD_DROP()
+#define STATS_REQ_FWD_OK()
+#define STATS_RPL_FWD_DROP()
+#define STATS_RPL_FWD_OK()
+#define STATS_BAD_MSG()
+#define STATS_BAD_RPL()
+#define STATS_BAD_URI()
+#define STATS_BAD_MSG_HDR()
+
+#else /* USE_CORE_STATS */
+
+#include "events.h"
+
+/** called each time a received request is dropped.
+ * The request might be dropped explicitly (e.g. pre script callback)
+ * or there might be an error while trying to forward it (e.g. send).
+ */
+#define STATS_REQ_FWD_DROP() sr_event_exec(SREV_CORE_STATS, (void*)3)
+
+
+/** called each time forwarding a request succeeds (send).*/
+#define STATS_REQ_FWD_OK() sr_event_exec(SREV_CORE_STATS, (void*)1)
+
+
+/** called each time forwarding a reply fails.
+ * The reply forwarding might fail due to send errors,
+ * pre script callbacks (module denying forwarding) or explicit script
+ * drop (drop or module function returning 0).
+ */
+#define STATS_RPL_FWD_DROP() sr_event_exec(SREV_CORE_STATS, (void*)4)
+
+
+/* called each time forwarding a reply succeeds. */
+#define STATS_RPL_FWD_OK() sr_event_exec(SREV_CORE_STATS, (void*)2)
+
+
+/** called each time a received request is too bad to process.
+ * For now it's called in case the message does not have any via.
+ */
+#define STATS_BAD_MSG() sr_event_exec(SREV_CORE_STATS, (void*)5)
+
+
+/** called each time a received reply is too bad to process.
+ * For now it's called in case the message does not have any via.
+ */
+#define STATS_BAD_RPL() sr_event_exec(SREV_CORE_STATS, (void*)6)
+
+
+/** called each time uri parsing fails. */
+#define STATS_BAD_URI() sr_event_exec(SREV_CORE_STATS, (void*)7)
+
+
+/** called each time parsing some header fails. */
+#define STATS_BAD_MSG_HDR() sr_event_exec(SREV_CORE_STATS, (void*)8)
+
+
+
+#endif /* USE_CORE_STATS */
+
+#endif /*__core_stats_h*/
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/forward.c b/forward.c
index 3a4fbf4..4b88780 100644
--- a/forward.c
+++ b/forward.c
@@ -94,6 +94,7 @@
#include "dst_blacklist.h"
#endif
#include "compiler_opt.h"
+#include "core_stats.h"
#ifdef DEBUG_DMALLOC
#include <dmalloc.h>
@@ -582,10 +583,12 @@ end:
#endif
if (buf) pkg_free(buf);
/* received_buf & line_buf will be freed in receive_msg by free_lump_list*/
+#if defined STATS_REQ_FWD_OK || defined STATS_REQ_FWD_DROP
if(ret==0)
- sr_event_exec(SREV_CORE_STATS, (void*)1);
+ STATS_REQ_FWD_OK();
else
- sr_event_exec(SREV_CORE_STATS, (void*)3);
+ STATS_REQ_FWD_DROP();
+#endif /* STATS_REQ_FWD_* */
return ret;
}
@@ -740,7 +743,7 @@ int forward_reply(struct sip_msg* msg)
#endif
if (msg_send(&dst, new_buf, new_len)<0)
{
- sr_event_exec(SREV_CORE_STATS, (void*)4);
+ STATS_RPL_FWD_DROP();
goto error;
}
#ifdef STATS
@@ -751,7 +754,7 @@ int forward_reply(struct sip_msg* msg)
msg->via2->host.len, msg->via2->host.s,
(unsigned short) msg->via2->port);
- sr_event_exec(SREV_CORE_STATS, (void*)2);
+ STATS_RPL_FWD_OK();
pkg_free(new_buf);
skip:
return 0;
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index 48f666c..1cb530c 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -54,7 +54,7 @@
#include "../data_lump_rpl.h"
#include "../mem/mem.h"
#include "../error.h"
-#include "../events.h"
+#include "../core_stats.h"
#include "../globals.h"
#include "parse_hname2.h"
#include "parse_uri.h"
@@ -279,7 +279,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
return tmp;
error:
DBG("get_hdr_field: error exit\n");
- sr_event_exec(SREV_CORE_STATS, (void*)8);
+ STATS_BAD_MSG_HDR();
hdr->type=HDR_ERROR_T;
hdr->len=tmp-hdr->name.s;
return tmp;
diff --git a/parser/parse_uri.c b/parser/parse_uri.c
index efcc54b..47cb1bc 100644
--- a/parser/parse_uri.c
+++ b/parser/parse_uri.c
@@ -50,7 +50,7 @@
#include "../ut.h" /* q_memchr */
/* #endif */
#include "../error.h"
-#include "../events.h"
+#include "../core_stats.h"
/* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i)
* len= len of uri
@@ -1224,7 +1224,7 @@ error_bug:
error_exit:
ser_error=E_BAD_URI;
uri->type=ERROR_URI_T;
- sr_event_exec(SREV_CORE_STATS, (void*)7);
+ STATS_BAD_URI();
return E_BAD_URI;
}
diff --git a/receive.c b/receive.c
index 60eefa7..2496e41 100644
--- a/receive.c
+++ b/receive.c
@@ -64,6 +64,7 @@
#include "tcp_server.h" /* for tcpconn_add_alias */
#include "tcp_options.h" /* for access to tcp_accept_aliases*/
#include "cfg/cfg.h"
+#include "core_stats.h"
#ifdef DEBUG_DMALLOC
#include <mem/dmalloc.h>
@@ -149,7 +150,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
/* no via, send back error ? */
LOG(L_ERR, "ERROR: receive_msg: no via found in request\n");
- sr_event_exec(SREV_CORE_STATS, (void*)5);
+ STATS_BAD_MSG();
goto error02;
}
/* check if necessary to add receive?->moved to forward_req */
@@ -184,7 +185,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
*/
if (exec_pre_script_cb(msg, REQUEST_CB_TYPE)==0 )
{
- sr_event_exec(SREV_CORE_STATS, (void*)3);
+ STATS_REQ_FWD_DROP();
goto end; /* drop the request */
}
@@ -212,7 +213,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
/* no via, send back error ? */
LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
- sr_event_exec(SREV_CORE_STATS, (void*)6);
+ STATS_BAD_RPL();
goto error02;
}
@@ -230,8 +231,8 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
*/
if (exec_pre_script_cb(msg, ONREPLY_CB_TYPE)==0 )
{
- sr_event_exec(SREV_CORE_STATS, (void*)4);
- goto end; /* drop the request */
+ STATS_RPL_FWD_DROP();
+ goto end; /* drop the reply */
}
/* exec the onreply routing script */
@@ -246,7 +247,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
}else
#endif /* NO_ONREPLY_ROUTE_ERROR */
if (unlikely(ret==0 || (ctx.run_flags&DROP_R_F))){
- sr_event_exec(SREV_CORE_STATS, (void*)4);
+ STATS_RPL_FWD_DROP();
goto skip_send_reply; /* drop the message, no error */
}
}
Revision: 5971
http://openser.svn.sourceforge.net/openser/?rev=5971&view=rev
Author: mariuszbihlei
Date: 2010-02-01 14:39:47 +0000 (Mon, 01 Feb 2010)
Log Message:
-----------
The mhomed implementation works by calling a socket()/connect()/getsockname()/close()
to find out the interface in a multihomed system.
Because mhomed works only for UDP sockets, a major performance improvement is shown
if we use the same socket for multiple connects(possible for UDP sockets), thus completly removing the socket() call
and the close() call.(well, except for the first time)
The CPU load(user+system) shown in a mhomed environment on a stateless router, with a call rate of 6000 calls/s
is 46.1% load in the case of this patched version, versus 63.54% load in the case of the original
version.
Modified Paths:
--------------
branches/1.5/forward.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Hello,
the master branch got a new module named mtree. It is able to load
database records in the form of (key,value) and index them in shared
memory trees based on key. One db table is loaded in one mtree, you can
define as many trees as you need.
The typical use case is to load arbitrary data related to DIDs or
prefixes, offering very fast lookup even with large number of records.
The value can be string or digested in a runtime structure, so far being
able to digest dstid:weight values, useful for prefix matching on weight
rather than longest match.
The trees are read only, with option to reload via mi command (rpc to be
added soon). Online readme at:
http://sip-router.org/docbook/sip-router/branch/master/modules/mtree/mtree.…
Cheers,
Daniel
--
Daniel-Constantin Mierla
eLearning class for Kamailio 3.0.0
Starting Feb 8, 2010
* http://www.asipto.com/