changeset 340:81821e9f6988

Fix issue on session cleanup callback parameters -- thanks Souheil for reporting.
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 28 Jun 2010 11:20:48 +0900
parents ba59301627b9
children 2bf23d10bc6f
files extensions/app_radgw/rgwx_echodrop.c freeDiameter/tests/testsess.c include/freeDiameter/libfreeDiameter.h libfreeDiameter/sessions.c
diffstat 4 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/app_radgw/rgwx_echodrop.c	Fri Jun 25 15:46:22 2010 +0900
+++ b/extensions/app_radgw/rgwx_echodrop.c	Mon Jun 28 11:20:48 2010 +0900
@@ -38,7 +38,7 @@
 #include "rgwx_echodrop.h"
 
 /* If a session is destroyed, empty the list of ed_saved_attribute */
-static void state_delete(void * arg) {
+static void state_delete(void * arg, char * sid) {
 	struct fd_list * list = (struct fd_list *)arg;
 	
 	CHECK_PARAMS_DO( list, return );
--- a/freeDiameter/tests/testsess.c	Fri Jun 25 15:46:22 2010 +0900
+++ b/freeDiameter/tests/testsess.c	Mon Jun 28 11:20:48 2010 +0900
@@ -46,7 +46,7 @@
 	int  *  freed;	/* location where to write the freed status */
 };
 
-static void mycleanup( char * sid, struct mystate * data )
+static void mycleanup( struct mystate * data, char * sid )
 {
 	/* sanity */
 	CHECK( 1, sid ? 1 : 0 );
@@ -267,8 +267,8 @@
 		CHECK( 0, fd_sess_state_retrieve( hdl1, sess2, &tms ) );
 		CHECK( NULL, tms );
 		
-		mycleanup(str1, ms[0]);
-		mycleanup(str1, ms[1]);
+		mycleanup(ms[0], str1);
+		mycleanup(ms[1], str1);
 		
 		/* Now create 6 states */
 		memset(&freed[0], 0, sizeof(freed));
@@ -349,7 +349,7 @@
 		/* Check the last data can still be retrieved */
 		CHECK( 0, fd_sess_state_retrieve( hdl1, sess1, &tms ) );
 		CHECK( 0, fd_sess_getsid(sess1, &str1) );
-		mycleanup(str1, tms);
+		mycleanup(tms, str1);
 	}
 	
 	
--- a/include/freeDiameter/libfreeDiameter.h	Fri Jun 25 15:46:22 2010 +0900
+++ b/include/freeDiameter/libfreeDiameter.h	Mon Jun 28 11:20:48 2010 +0900
@@ -1526,11 +1526,12 @@
  *  EINVAL 	: A parameter is invalid.
  *  ENOMEM	: Not enough memory to complete the operation
  */
-int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(char * sid, session_state * state) );
+int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state * state, char * sid) );
 /* Macro to avoid casting everywhere */
 #define fd_sess_handler_create( _handler, _cleanup ) \
-	fd_sess_handler_create_internal( (_handler), (void (*)(char *, session_state *))(_cleanup) )
+	fd_sess_handler_create_internal( (_handler), (void (*)(session_state *, char *))(_cleanup) )
 
+	
 /*
  * FUNCTION:	fd_sess_handler_destroy
  *
--- a/libfreeDiameter/sessions.c	Fri Jun 25 15:46:22 2010 +0900
+++ b/libfreeDiameter/sessions.c	Mon Jun 28 11:20:48 2010 +0900
@@ -68,7 +68,7 @@
 struct session_handler {
 	int		  eyec;	/* An eye catcher also used to ensure the object is valid, must be SH_EYEC */
 	int		  id;	/* A unique integer to identify this handler */
-	void 		(*cleanup)(char *, session_state *); /* The cleanup function to be called for cleaning a state */
+	void 		(*cleanup)(session_state *, char *); /* The cleanup function to be called for cleaning a state */
 };
 
 static int 		hdl_id = 0;				/* A global counter to initialize the id field */
@@ -246,7 +246,7 @@
 }
 
 /* Create a new handler */
-int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(char * sid, session_state * state) )
+int fd_sess_handler_create_internal ( struct session_handler ** handler, void (*cleanup)(session_state * state, char * sid) )
 {
 	struct session_handler *new;
 	
@@ -317,7 +317,7 @@
 	while (!FD_IS_LIST_EMPTY(&deleted_states)) {
 		struct state * st = (struct state *)(deleted_states.next->o);
 		TRACE_DEBUG(FULL, "Calling cleanup handler for session '%s' and data %p", st->sid, st->state);
-		(*del->cleanup)(st->sid, st->state);
+		(*del->cleanup)(st->state, st->sid);
 		free(st->sid);
 		fd_list_unlink(&st->chain);
 		free(st);
@@ -575,7 +575,7 @@
 		struct state * st = (struct state *)(sess->states.next->o);
 		fd_list_unlink(&st->chain);
 		TRACE_DEBUG(FULL, "Calling handler %p cleanup for state registered with session '%s'", st->hdl, sess->sid);
-		(*st->hdl->cleanup)(sess->sid, st->state);
+		(*st->hdl->cleanup)(st->state, sess->sid);
 		free(st);
 	}
 	
"Welcome to our mercurial repository"