[Freeswitch-svn] [commit] r4999 - in freeswitch/trunk/src: . include include/private mod/applications/mod_commands

Freeswitch SVN mikej at freeswitch.org
Sat Apr 21 21:25:02 EDT 2007


Author: mikej
Date: Sat Apr 21 21:25:02 2007
New Revision: 4999

Modified:
   freeswitch/trunk/src/include/private/switch_core.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/trunk/src/switch_core_session.c

Log:
add cumulative count of sessions from switch startup.  Resolves http://jira.freeswitch.org/browse/FSCORE-18.  Updated patch to change data type of session_id to avoid rollover (wouldn't that be nice) and added - 1 to accurately reflect count.  Thanks bkw for the patch.

Modified: freeswitch/trunk/src/include/private/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core.h	Sat Apr 21 21:25:02 2007
@@ -83,7 +83,7 @@
 
 
 struct switch_core_session {
-	uint32_t id;
+	switch_size_t id;
 	char name[80];
 	switch_session_flag_t flags;
 	int thread_running;

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Sat Apr 21 21:25:02 2007
@@ -442,6 +442,12 @@
 SWITCH_DECLARE(uint32_t) switch_core_session_count(void);
 
 /*! 
+  \brief Provide the current session_id
+  \return the total number of allocated sessions since core startup
+*/
+SWITCH_DECLARE(switch_size_t) switch_core_session_id(void);
+
+/*! 
   \brief Allocate and return a new session from the core based on a given endpoint module name
   \param endpoint_name the name of the endpoint module
   \param pool the pool to use

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Sat Apr 21 21:25:02 2007
@@ -84,6 +84,7 @@
 						   duration.sec, duration.sec == 1 ? "" : "s", duration.ms, duration.ms == 1 ? "" : "s", duration.mms,
 						   duration.mms == 1 ? "" : "s");
 
+	stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" sessions since startup\n", switch_core_session_id() - 1 );
 	stream->write_function(stream, "%d sessions\n", switch_core_session_count());
 
 	if (html) {

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Sat Apr 21 21:25:02 2007
@@ -40,7 +40,7 @@
 	switch_mutex_t *session_table_mutex;
 	uint32_t session_count;
 	uint32_t session_limit;
-	uint32_t session_id;
+	switch_size_t session_id;
 } runtime;
 
 
@@ -820,6 +820,12 @@
 	return runtime.session_count;
 }
 
+SWITCH_DECLARE(switch_size_t) switch_core_session_id(void)
+{
+	return runtime.session_id;
+}
+
+
 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t **pool)
 {
 	const switch_endpoint_interface_t *endpoint_interface;



More information about the Freeswitch-svn mailing list