From 61a3674b9e678e495e60377e35fc43ea3ec850eb Mon Sep 17 00:00:00 2001 From: scottmk Date: Sun, 15 Nov 2009 18:15:31 +0000 Subject: [PATCH 1/1] Replace the the call to osrf_message_deserialize() with a call to osrfMessageDeserialize(). M src/router/osrf_router.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1853 9efc2488-bf62-4759-914b-345cdb29e865 --- src/router/osrf_router.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/router/osrf_router.c b/src/router/osrf_router.c index 19f1ebe..b847807 100644 --- a/src/router/osrf_router.c +++ b/src/router/osrf_router.c @@ -46,6 +46,8 @@ struct osrfRouterStruct { 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 @@ osrfRouter* osrfNewRouter( 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 @@ void osrfRouterFree( osrfRouter* router ) { osrfStringArrayFree( router->trustedClients ); osrfStringArrayFree( router->trustedServers ); + osrfListFree( router->message_list ); client_free( router->connection ); free(router); @@ -772,22 +776,15 @@ static int _osrfRouterFillFDSet( osrfRouter* router, fd_set* set ) { */ 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 ) { -- 2.43.2