osrf_app_session* session, int req_id ){
if(session == NULL) return;
+ debug_handler("Finishing request %d", req_id );
osrf_app_request* req = _osrf_app_session_get_request( session, req_id );
if(req == NULL) return;
_osrf_app_session_remove_request( req->session, req );
if( req->result != NULL ) {
debug_handler("app_request receive already has a message, returning it");
/* pop off the first message in the list */
- osrf_message* tmp_msg = req->result->next;
- req->result = tmp_msg;
- return req->result;
+ osrf_message* tmp_msg = req->result;
+ req->result = req->result->next;
+ return tmp_msg;
}
time_t start = time(NULL);
remaining -= (int) (time(NULL) - start);
}
+ debug_handler("Returning NULL from app_request_recv after timeout");
return NULL;
}
return 0;
}
- debug_handler( "The first request in the request queue has tt [%d]", req->request_id );
-
while( req != NULL ) {
if(req->request_id == msg->thread_trace) {
debug_handler( "Found app_request for tt [%d]", msg->thread_trace );
}
int osrf_app_session_request_resend( osrf_app_session* session, int req_id ) {
+ debug_handler("In reqeust resend searching for resend-able messages");
osrf_app_request* req = _osrf_app_session_get_request( session, req_id );
return _osrf_app_request_resend( req );
}
osrf_app_session* session, int req_id, int timeout ) {
if(req_id < 0 || session == NULL)
return NULL;
+ debug_handler("somebody callled recv");
osrf_app_request* req = _osrf_app_session_get_request( session, req_id );
return _osrf_app_request_recv( req, timeout );
}
#include "opensrf/osrf_message.h"
+/* default to true */
+int parse_json = 1;
osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol ) {
msg->protocol = protocol;
msg->next = NULL;
msg->is_exception = 0;
+ msg->parse_json = parse_json;
return msg;
}
+void osrf_message_set_json_parse( int ibool ) {
+ parse_json = ibool;
+}
+
+
void osrf_message_set_request_info( osrf_message* msg, char* method_name, json* json_params ) {
if( msg == NULL || method_name == NULL )
fatal_handler( "Bad params to osrf_message_set_request_params()" );
}
-void osrf_message_set_result_content( osrf_message* msg, json* result_content ) {
- if( msg == NULL )
- fatal_handler( "Bad params to osrf_message_set_result_content()" );
- msg->result_string = strdup(json_object_to_json_string(result_content));
+void osrf_message_set_result_content( osrf_message* msg, char* json_string ) {
+ if( msg == NULL || json_string == NULL)
+ warning_handler( "Bad params to osrf_message_set_result_content()" );
+
+ msg->result_string = strdup(json_string);
debug_handler("Setting result_string to %s\n", msg->result_string );
- msg->result_content = json_tokener_parse(msg->result_string);
+
+ debug_handler( "Message Parse JSON is set to: %d", msg->parse_json );
+
+ if(msg->parse_json)
+ msg->result_content = json_tokener_parse(msg->result_string);
}
xmlNodePtr cur_node = message_node->children;
osrf_message* new_msg = safe_malloc(sizeof(osrf_message));
+ new_msg->parse_json = parse_json;
while( cur_node ) {
xmlChar* r_name = xmlGetProp( result_nodes, BAD_CAST "name" );
if(r_name) {
if( !strcmp((char*)r_name,"oilsScalar") && result_nodes->children->content ) {
- new_msg->result_string = strdup(result_nodes->children->content);
- new_msg->result_content = json_tokener_parse(result_nodes->children->content);
+ osrf_message_set_result_content( new_msg, result_nodes->children->content);
}
xmlFree(r_name);
}
int osrf_stack_process( transport_client* client, int timeout ) {
transport_message* msg = client_recv( client, timeout );
if(msg == NULL) return 0;
+ debug_handler( "Received message from transport code from %s", msg->sender );
int status = osrf_stack_transport_handler( msg );
/* see if there are multiple message to be received */
while(1) {
transport_message* m = client_recv( client, 0 );
- if(m) status = osrf_stack_transport_handler( m );
- else break;
+ if(m) {
+ debug_handler( "Received additional message from transport code from %s", msg->sender );
+ status = osrf_stack_transport_handler( m );
+ } else {
+ debug_handler( "osrf_stack_process returning with only 1 received message" );
+ break;
+ }
}
return status;