1. In an earlier patch to osrf_settings_host_value_object(), we
contrived to abort the program deliberately instead of crashing with
a segmentation violation. The current patch applies the same
treatment to the similar function osrf_settings_host_value(),
although I don't know that anyone has ever reported a problem at
this spot. I rearranged the error message a bit so that it would
be distinct from the other one.
2. If the config pointer is null, it's because osrf_settings_retrieve()
was unable to populate it, or was never called. There are two ways
it might fail: it might not get an osrf_message from
osrf_app_session_request_recv(), or the osrf_message it gets might
not have the _result_content member populated. I added a couple of
log messages to distinguish between these possibilities. Maybe they
will make diagnosis easier.
3. The latter change also plugs a small memory leak. If we get an
osrf_message but it has no _result_content, the present code neglects
to free the osrf_message.
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@939
9efc2488-bf62-4759-914b-
345cdb29e865
char* osrf_settings_host_value(char* format, ...) {
VA_LIST_TO_STRING(format);
+
+ if( ! config ) {
+ const char * msg = "NULL config pointer";
+ fprintf( stderr, "osrf_settings_host_value: %s\n", msg );
+ osrfLogError( OSRF_LOG_MARK, msg );
+ exit( 99 );
+ }
+
jsonObject* o = jsonObjectFindPath(config->config, VA_BUF);
char* val = jsonObjectToSimpleString(o);
jsonObjectFree(o);
osrf_message* omsg = osrf_app_session_request_recv( session, req_id, 60 );
jsonObjectFree(params);
- if(omsg && omsg->_result_content) {
+ if(!omsg) {
+ osrfLogError( OSRF_LOG_MARK, "No osrf_message received from host %s (timeout?)", hostname);
+ } else if(!omsg->_result_content) {
+ osrf_message_free(omsg);
+ osrfLogError(
+ OSRF_LOG_MARK,
+ "NULL or non-existant osrf_message result content received from host %s, "
+ "broken message or no settings for host",
+ hostname
+ );
+ } else {
config = osrf_settings_new_host_config(hostname);
config->config = jsonObjectClone(omsg->_result_content);
osrf_message_free(omsg);