[Opensrf-commits] r1209 - in trunk: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jan 6 21:32:27 EST 2008


Author: miker
Date: 2008-01-06 21:08:10 -0500 (Sun, 06 Jan 2008)
New Revision: 1209

Modified:
   trunk/include/opensrf/osrf_stack.h
   trunk/src/libopensrf/osrf_stack.c
Log:
Patch from Scott McKellar:

1. I moved almost everything from the header into the implementation
file, since it isn't referenced elsewhere.  All that's left is one
prototype and some nested #includes.

2. I moved the nested #includes inside the compilation guard.

3. Except for osrf_stack_transport_handler(), all functions are now
static.

4. I applied the const qualifier to the second parameter of
osrf_stack_transport_handler().

5. I plugged a memory leak in osrf_stack_transport_handler().  When
unable to open a session, we were returning without freeing the
input message.



Modified: trunk/include/opensrf/osrf_stack.h
===================================================================
--- trunk/include/opensrf/osrf_stack.h	2008-01-07 02:04:54 UTC (rev 1208)
+++ trunk/include/opensrf/osrf_stack.h	2008-01-07 02:08:10 UTC (rev 1209)
@@ -1,3 +1,6 @@
+#ifndef OSRF_STACK_H
+#define OSRF_STACK_H
+
 #include <opensrf/transport_client.h>
 #include <opensrf/osrf_message.h>
 #include <opensrf/osrf_app_session.h>
@@ -2,16 +5,5 @@
 
-#ifndef OSRF_STACK_H
-#define OSRF_STACK_H
+osrfAppSession*  osrf_stack_transport_handler( transport_message* msg,
+		const char* my_service );
 
-/* the max number of oilsMessage blobs present in any one root packet */
-#define OSRF_MAX_MSGS_PER_PACKET 256
-// -----------------------------------------------------------------------------
-
-int osrf_stack_process( transport_client* client, int timeout, int* msg_received );
-osrfAppSession*  osrf_stack_transport_handler( transport_message* msg, char* my_service );
-int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg );
-int osrf_stack_application_handler( osrf_app_session* session, osrf_message* msg );
-
-
-
 #endif

Modified: trunk/src/libopensrf/osrf_stack.c
===================================================================
--- trunk/src/libopensrf/osrf_stack.c	2008-01-07 02:04:54 UTC (rev 1208)
+++ trunk/src/libopensrf/osrf_stack.c	2008-01-07 02:08:10 UTC (rev 1209)
@@ -1,13 +1,20 @@
 #include <opensrf/osrf_stack.h>
 #include <opensrf/osrf_application.h>
 
-osrf_message* _do_client( osrf_app_session*, osrf_message* );
-osrf_message* _do_server( osrf_app_session*, osrf_message* );
+/* the max number of oilsMessage blobs present in any one root packet */
+#define OSRF_MAX_MSGS_PER_PACKET 256
+// -----------------------------------------------------------------------------
 
+static int osrf_stack_process( transport_client* client, int timeout, int* msg_received );
+static int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg );
+static int osrf_stack_application_handler( osrf_app_session* session, osrf_message* msg );
+static osrf_message* _do_client( osrf_app_session*, osrf_message* );
+static osrf_message* _do_server( osrf_app_session*, osrf_message* );
+
 /* tell osrf_app_session where the stack entry is */
 int (*osrf_stack_entry_point) (transport_client*, int, int*)  = &osrf_stack_process;
 
-int osrf_stack_process( transport_client* client, int timeout, int* msg_received ) {
+static int osrf_stack_process( transport_client* client, int timeout, int* msg_received ) {
 	if( !client ) return -1;
 	transport_message* msg = NULL;
 	if(msg_received) *msg_received = 0;
@@ -34,7 +41,8 @@
 // -----------------------------------------------------------------------------
 // Entry point into the stack
 // -----------------------------------------------------------------------------
-osrfAppSession* osrf_stack_transport_handler( transport_message* msg, char* my_service ) { 
+osrfAppSession* osrf_stack_transport_handler( transport_message* msg,
+		const char* my_service ) {
 
 	if(!msg) return NULL;
 
@@ -60,8 +68,11 @@
 	if( !session && my_service ) 
 		session = osrf_app_server_session_init( msg->thread, my_service, msg->sender);
 
-	if( !session ) return NULL;
-
+	if( !session ) {
+		message_free( msg );
+		return NULL;
+	}
+	
 	if(!msg->is_error)
 		osrfLogDebug( OSRF_LOG_MARK, "Session [%s] found or built", session->session_id );
 
@@ -108,7 +119,7 @@
 	return session;
 }
 
-int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg ) {
+static int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg ) {
 	if(session == NULL || msg == NULL)
 		return 0;
 
@@ -133,7 +144,7 @@
 /** If we return a message, that message should be passed up the stack, 
   * if we return NULL, we're finished for now...
   */
-osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) {
+static osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) {
 	if(session == NULL || msg == NULL)
 		return NULL;
 
@@ -201,7 +212,7 @@
 /** If we return a message, that message should be passed up the stack, 
   * if we return NULL, we're finished for now...
   */
-osrf_message* _do_server( osrf_app_session* session, osrf_message* msg ) {
+static osrf_message* _do_server( osrf_app_session* session, osrf_message* msg ) {
 
 	if(session == NULL || msg == NULL) return NULL;
 
@@ -240,7 +251,7 @@
 
 
 
-int osrf_stack_application_handler( osrf_app_session* session, osrf_message* msg ) {
+static int osrf_stack_application_handler( osrf_app_session* session, osrf_message* msg ) {
 	if(session == NULL || msg == NULL) return 0;
 
 	if(msg->m_type == RESULT && session->type == OSRF_SESSION_CLIENT) {



More information about the opensrf-commits mailing list