diff libfreeDiameter/sessions.c @ 291:2d3a799ad29c

Cache the session pointer in answers when it was present in queries
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 10 May 2010 14:10:51 +0900
parents 5df55136361b
children ec67c5096eeb
line wrap: on
line diff
--- a/libfreeDiameter/sessions.c	Fri May 07 16:33:12 2010 +0900
+++ b/libfreeDiameter/sessions.c	Mon May 10 14:10:51 2010 +0900
@@ -711,15 +711,26 @@
 	/* Get the session object */
 	CHECK_FCT( fd_sess_fromsid ( (char *) sid, len, session, new) );
 	
-	/* Update the msg refcount */
-	CHECK_POSIX( pthread_mutex_lock(&(*session)->stlock) );
-	(*session)->msg_cnt++;
-	CHECK_POSIX( pthread_mutex_unlock(&(*session)->stlock) );
+	/* Increase count */
+	CHECK_FCT( fd_sess_ref_msg ( *session ) );
 	
 	/* Done */
 	return 0;
 }
 
+int fd_sess_ref_msg ( struct session * session )
+{
+	TRACE_ENTRY("%p", session);
+	CHECK_PARAMS( VALIDATE_SI(session) );
+
+	/* Update the msg refcount */
+	CHECK_POSIX( pthread_mutex_lock(&session->stlock) );
+	session->msg_cnt++;
+	CHECK_POSIX( pthread_mutex_unlock(&session->stlock) );
+	
+	return 0;
+}
+
 int fd_sess_reclaim_msg ( struct session ** session )
 {
 	int reclaim;
"Welcome to our mercurial repository"