[Opensrf-commits] r1724 - trunk/src/libopensrf (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jun 22 01:28:37 EDT 2009
Author: scottmk
Date: 2009-06-22 01:28:34 -0400 (Mon, 22 Jun 2009)
New Revision: 1724
Modified:
trunk/src/libopensrf/osrf_prefork.c
Log:
Fix a bug whereby, if there was only one <service> entry for the
public router in opensrf_core.xml, the service would fail to register.
Root cause: The code was expecting to see a list of services in a
JSON_ARRAY. But if there's only one service, it's represented as a
JSON_STRING.
Modified: trunk/src/libopensrf/osrf_prefork.c
===================================================================
--- trunk/src/libopensrf/osrf_prefork.c 2009-06-15 15:27:20 UTC (rev 1723)
+++ trunk/src/libopensrf/osrf_prefork.c 2009-06-22 05:28:34 UTC (rev 1724)
@@ -158,23 +158,31 @@
/** parses a single "complex" router configuration chunk */
static void osrf_prefork_parse_router_chunk(const char* appname, jsonObject* routerChunk) {
- char* routerName = jsonObjectGetString(jsonObjectGetKey(routerChunk, "name"));
- char* domain = jsonObjectGetString(jsonObjectGetKey(routerChunk, "domain"));
- jsonObject* services = jsonObjectGetKey(routerChunk, "services");
- osrfLogDebug(OSRF_LOG_MARK, "found router config with domain %s and name %s", routerName, domain);
+ char* routerName = jsonObjectGetString(jsonObjectGetKey(routerChunk, "name"));
+ char* domain = jsonObjectGetString(jsonObjectGetKey(routerChunk, "domain"));
+ jsonObject* services = jsonObjectGetKey(routerChunk, "services");
+ osrfLogDebug(OSRF_LOG_MARK, "found router config with domain %s and name %s", routerName, domain);
- if(services && services->type == JSON_HASH) {
- osrfLogDebug(OSRF_LOG_MARK, "investigating router information...");
- services = jsonObjectGetKey(services, "service");
- int j;
- for(j = 0; j < services->size; j++ ) {
- char* service = jsonObjectGetString(jsonObjectGetIndex(services, j));
- if(!strcmp(appname, service))
- osrf_prefork_send_router_registration(appname, routerName, domain);
- }
- } else {
- osrf_prefork_send_router_registration(appname, routerName, domain);
- }
+ if( services && services->type == JSON_HASH ) {
+ osrfLogDebug(OSRF_LOG_MARK, "investigating router information...");
+ jsonObject* service_obj = jsonObjectGetKey(services, "service");
+ if( !service_obj )
+ ; // do nothing (shouldn't happen)
+ else if( JSON_ARRAY == service_obj->type ) {
+ int j;
+ for(j = 0; j < service_obj->size; j++ ) {
+ const char* service = jsonObjectGetString(jsonObjectGetIndex(service_obj, j));
+ if( service && !strcmp( appname, service ))
+ osrf_prefork_send_router_registration(appname, routerName, domain);
+ }
+ }
+ else if( JSON_STRING == service_obj->type ) {
+ if( !strcmp(appname, jsonObjectGetString( service_obj )) )
+ osrf_prefork_send_router_registration(appname, routerName, domain);
+ }
+ } else {
+ osrf_prefork_send_router_registration(appname, routerName, domain);
+ }
}
static void osrf_prefork_register_routers( const char* appname ) {
More information about the opensrf-commits
mailing list