[svn-commits] rizzo: branch rizzo/astobj2 r47972 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Nov 23 10:56:32 MST 2006


Author: rizzo
Date: Thu Nov 23 11:56:32 2006
New Revision: 47972

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47972
Log:
start profiling the path for incoming packets.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47972&r1=47971&r2=47972
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Thu Nov 23 11:56:32 2006
@@ -15190,10 +15190,11 @@
 	return res;
 }
 
-/*! \brief Read data from SIP socket
-\note sipsock_read locks the owner channel while we are processing the SIP message
-\return 1 on error, 0 on success
-\note Successful messages is connected to SIP call and forwarded to handle_request() 
+/*!
+ * Read data from SIP socket. Called from the do_monitor() thread in ast_io_wait()
+ * \return 1 on error, 0 on success
+ * \note sipsock_read locks the owner channel while we are processing the SIP message
+ * \note Successful messages is connected to SIP call and forwarded to handle_request() 
 */
 static int sipsock_read(int *id, int fd, short events, void *ignore)
 {
@@ -15206,15 +15207,25 @@
 	int recount = 0;
 	int lockretry;
 	int buflen = sizeof(req.data) - 1; /* leave an extra byte at the end for '\0' */
-
+	static int prof_memset = -1, prof_recv = -1, prof_parse = -1;
+
+	if (prof_memset == -1) {	/* allocate profiling counters */
+		prof_memset = ast_add_profile("sip_read-memset", 0);
+		prof_recv = ast_add_profile("sip_read-recvfrom", 0);
+		prof_parse = ast_add_profile("sip_read-parse", 0);
+	}
+	ast_mark(prof_memset, 1);
 	memset(&req, 0, sizeof(req));
+	ast_mark(prof_memset, 0);
 	/*
 	 * There is a short window during a reload when recvfrom
 	 * might fail because __sipsock is being closed and reopened.
 	 * Just live with it, it is not fatal, the network could have
 	 * dropped the packet anyways.
 	 */
+	ast_mark(prof_recv, 1);
 	res = recvfrom(__sipsock, req.data, buflen, 0, (struct sockaddr *)&sin, &len);
+	ast_mark(prof_recv, 0);
 	if (res < 0) {
 #if !defined(__FreeBSD__)
 		if (errno == EAGAIN)
@@ -15236,8 +15247,10 @@
 	if (ast_test_flag(&req, SIP_PKT_DEBUG))
 		ast_verbose("\n<--- SIP read from %s:%d --->\n%s\n<------------->\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), req.data);
 
+	ast_mark(prof_parse, 1);
 	parse_request(&req);
 	req.method = find_sip_method(req.rlPart1);
+	ast_mark(prof_parse, 0);
 
 	if (ast_test_flag(&req, SIP_PKT_DEBUG))
 		ast_verbose("--- (%d headers %d lines)%s ---\n", req.headers, req.lines, (req.headers + req.lines == 0) ? " Nat keepalive" : "");



More information about the svn-commits mailing list