From ba81b3390f802b8942f04ae9ab7afc71325fbba6 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 2 Nov 2005 16:18:14 +0000 Subject: [PATCH] cleaned up the code some git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@563 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_transgroup.c | 35 ++++++++++------------------------- src/libstack/osrf_transgroup.h | 3 +-- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/libstack/osrf_transgroup.c b/src/libstack/osrf_transgroup.c index 30508d3..42f0190 100644 --- a/src/libstack/osrf_transgroup.c +++ b/src/libstack/osrf_transgroup.c @@ -13,6 +13,7 @@ osrfTransportGroupNode* osrfNewTransportGroupNode( node->username = strdup(username); node->password = strdup(password); node->domain = strdup(domain); + node->resource = strdup(resource); node->active = 0; node->lastsent = 0; node->connection = client_init( domain, port, NULL, 0 ); @@ -21,8 +22,8 @@ osrfTransportGroupNode* osrfNewTransportGroupNode( } -osrfTransportGroup* osrfNewTransportGroup( char* router, osrfTransportGroupNode* nodes[], int count ) { - if(!nodes || !router || count < 1) return NULL; +osrfTransportGroup* osrfNewTransportGroup( osrfTransportGroupNode* nodes[], int count ) { + if(!nodes || count < 1) return NULL; osrfTransportGroup* grp = safe_malloc(sizeof(osrfTransportGroup)); grp->nodes = osrfNewHash(); @@ -95,10 +96,9 @@ int osrfTransportGroupSend( osrfTransportGroup* grp, transport_message* msg ) { char* firstdomain = NULL; char newrcp[1024]; - int updateRecip = 1; /* if we don't host this domain, don't update the recipient but send it as is */ - if(osrfHashGet(grp->nodes, domain)) updateRecip = 0; + if(!osrfHashGet(grp->nodes, domain)) updateRecip = 0; osrfTransportGroupNode* node; @@ -120,14 +120,13 @@ int osrfTransportGroupSend( osrfTransportGroup* grp, transport_message* msg ) { } /* update the recipient domain if necessary */ - bzero(newrcp, 1024); - if(updateRecip) - sprintf(newrcp, "%s@%s/%s", msgrecip, node->domain, msgres); - else - sprintf(newrcp, msg->recipient); - free(msg->recipient); - msg->recipient = strdup(newrcp); + if(updateRecip) { + bzero(newrcp, 1024); + sprintf(newrcp, "%s@%s/%s", msgrecip, node->domain, msgres); + free(msg->recipient); + msg->recipient = strdup(newrcp); + } if( (client_send_message( node->connection, msg )) == 0 ) return 0; @@ -215,18 +214,4 @@ void osrfTransportGroupSetInactive( osrfTransportGroup* grp, char* domain ) { if(node) node->active = 0; } -/* -osrfTransportGroupNode* __osrfTransportGroupFindNode( osrfTransportGroup* grp, char* domain ) { - if(!(grp && grp->list && domain)) return NULL; - int i = 0; - osrfTransportGroupNode* node = NULL; - - while( (node = (osrfTransportGroupNode*) osrfListGetIndex( grp->list, i++ )) ) - if(!strcmp(node->domain, domain)) return node; - return NULL; -} -*/ - - - diff --git a/src/libstack/osrf_transgroup.h b/src/libstack/osrf_transgroup.h index 242d4be..a8f433b 100644 --- a/src/libstack/osrf_transgroup.h +++ b/src/libstack/osrf_transgroup.h @@ -47,10 +47,9 @@ osrfTransportGroupNode* osrfNewTransportGroupNode( /** Allocates and initializes a new transport group. The first node in the array is the default node for client connections. - @param router The router name shared accross the networks @param nodes The nodes in the group. */ -osrfTransportGroup* osrfNewTransportGroup( char* router, osrfTransportGroupNode* nodes[], int count ); +osrfTransportGroup* osrfNewTransportGroup( osrfTransportGroupNode* nodes[], int count ); /** Attempts to connect all of the nodes in this group. -- 2.11.0