[Opensrf-commits] r1853 - trunk/src/router (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Nov 15 13:15:35 EST 2009


Author: scottmk
Date: 2009-11-15 13:15:31 -0500 (Sun, 15 Nov 2009)
New Revision: 1853

Modified:
   trunk/src/router/osrf_router.c
Log:
Replace the the call to osrf_message_deserialize()
with a call to osrfMessageDeserialize().

M    src/router/osrf_router.c


Modified: trunk/src/router/osrf_router.c
===================================================================
--- trunk/src/router/osrf_router.c	2009-11-15 17:57:33 UTC (rev 1852)
+++ trunk/src/router/osrf_router.c	2009-11-15 18:15:31 UTC (rev 1853)
@@ -46,6 +46,8 @@
 	osrfStringArray* trustedClients;
 	/** Array of server domains that we allow to register, etc. with us. */
 	osrfStringArray* trustedServers;
+	/** List of osrfMessages to be returned from osrfMessageDeserialize() */
+	osrfList* message_list;
 
 	transport_client* connection;
 };
@@ -167,6 +169,7 @@
 	router->classes = osrfNewHash();
 	osrfHashSetCallback(router->classes, &osrfRouterClassFree);
 	router->class_itr = osrfNewHashIterator( router->classes );
+	router->message_list = NULL;   // We'll allocate one later
 
 	// Prepare to connect to Jabber, as a non-component, over TCP (not UNIX domain).
 	router->connection = client_init( domain, port, NULL, 0 );
@@ -684,6 +687,7 @@
 
 	osrfStringArrayFree( router->trustedClients );
 	osrfStringArrayFree( router->trustedServers );
+	osrfListFree( router->message_list );
 
 	client_free( router->connection );
 	free(router);
@@ -772,22 +776,15 @@
 */
 static void osrfRouterHandleAppRequest( osrfRouter* router, const transport_message* msg ) {
 
-	int T = 32;
-	osrfMessage* arr[T];
-	
-	// Initialize pointer array to all NULLs
-	int i;
-	for( i = 0; i < T; ++i )
-		arr[ i ] = NULL;
-
-	// Translate the JSON into an array of pointers to osrfMessage
-	int num_msgs = osrf_message_deserialize( msg->body, arr, T );
+	// Translate the JSON into a list of osrfMessages
+	router->message_list = osrfMessageDeserialize( msg->body, router->message_list );
 	osrfMessage* omsg = NULL;
 
 	// Process each osrfMessage
-	for( i = 0; i < num_msgs; i++ ) {
+	int i;
+	for( i = 0; i < router->message_list->size; ++i ) {
 
-		omsg = arr[i];
+		omsg = osrfListGetIndex( router->message_list, i );
 		if( omsg ) {
 
 			switch( omsg->m_type ) {



More information about the opensrf-commits mailing list