From ab20d094273411957fb73dcfde6ae3ce5687e268 Mon Sep 17 00:00:00 2001 From: scottmk Date: Mon, 14 Dec 2009 20:38:44 +0000 Subject: [PATCH 1/1] 1. In osrf_app_session.[ch]: Create a new function osrfAppSessionSendRequest(), similar to osrfAppSessionMakeRequest() but without the param_strings parameter. 2. Replace the old function with the new one in srfsh.c. M include/opensrf/osrf_app_session.h M src/libopensrf/osrf_app_session.c M src/srfsh/srfsh.c git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1873 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/osrf_app_session.h | 12 ++++++++++-- src/libopensrf/osrf_app_session.c | 31 +++++++++++++++++++++++++++--- src/srfsh/srfsh.c | 4 ++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/include/opensrf/osrf_app_session.h b/include/opensrf/osrf_app_session.h index 79de92f..8c2f4d5 100644 --- a/include/opensrf/osrf_app_session.h +++ b/include/opensrf/osrf_app_session.h @@ -103,14 +103,22 @@ char* osrf_app_session_set_locale( osrfAppSession*, const char* ); /** returns a session from the global session hash */ osrfAppSession* osrf_app_session_find_session( const char* session_id ); -/** Builds a new app_request object with the given payload andn returns +/** Builds a new app_request object with the given payload and returns the id of the request. This id is then used to perform work on the - requeset. + request. DEPRECATED; use osrfAppSessionSendRequest() instead. */ int osrfAppSessionMakeRequest( osrfAppSession* session, const jsonObject* params, const char* method_name, int protocol, osrfStringArray* param_strings); +/** Builds a new app_request object with the given payload and returns + the id of the request. This id is then used to perform work on the + request. + */ +int osrfAppSessionSendRequest( + osrfAppSession* session, const jsonObject* params, + const char* method_name, int protocol ); + /** Sets the given request to complete state */ void osrf_app_session_set_complete( osrfAppSession* session, int request_id ); diff --git a/src/libopensrf/osrf_app_session.c b/src/libopensrf/osrf_app_session.c index 2709d69..ba43416 100644 --- a/src/libopensrf/osrf_app_session.c +++ b/src/libopensrf/osrf_app_session.c @@ -161,7 +161,7 @@ void osrf_app_session_request_reset_timeout( osrfAppSession* session, int req_id } /** - Checke the receive queue for messages. If any are found, the first + Checks the receive queue for messages. If any are found, the first is popped off and returned. Otherwise, this method will wait at most timeout seconds for a message to appear in the receive queue. Once it arrives it is returned. If no messages arrive in the timeout provided, null is returned. @@ -466,6 +466,9 @@ osrfAppSession* osrf_app_server_session_init( @param param_strings Another way of specifying the parameters for the method. @return The request ID of the resulting REQUEST message, or -1 upon error. + DEPRECATED. Use osrfAppSessionSendRequest() instead. It is identical except that it + doesn't use the param_strings argument, which is redundant, confusing, and unused. + If @a params is non-NULL, use it to specify the parameters to the method. Otherwise use @a param_strings. @@ -489,6 +492,27 @@ int osrfAppSessionMakeRequest( method_name, protocol, param_strings, NULL ); } +/** + @brief Create a REQUEST message, send it, and save it for future reference. + @param session Pointer to the current session, which has the addressing information. + @param params One way of specifying the parameters for the method. + @param method_name The name of the method to be called. + @param protocol Protocol. + @return The request ID of the resulting REQUEST message, or -1 upon error. + + If @a params points to a JSON_ARRAY, then pass each element of the array as a separate + parameter. If @a params points to any other kind of jsonObject, pass it as a single + parameter. + + This function is a thin wrapper for osrfAppSessionMakeLocaleRequest(). +*/ +int osrfAppSessionSendRequest( osrfAppSession* session, const jsonObject* params, + const char* method_name, int protocol ) { + + return osrfAppSessionMakeLocaleRequest( session, params, + method_name, protocol, NULL, NULL ); +} + /** @brief Create a REQUEST message, send it, and save it for future reference. @param session Pointer to the current session, which has the addressing information. @@ -499,8 +523,9 @@ int osrfAppSessionMakeRequest( @param locale Pointer to a locale string. @return The request ID of the resulting REQUEST message, or -1 upon error. - See the discussion of osrfAppSessionMakeRequest(), which at this writing is the only - place that calls this function. + See the discussion of osrfAppSessionSendRequest(), which at this writing is the only + place that calls this function, except for the similar but deprecated function + osrfAppSessionMakeRequest(). At this writing, the @a param_strings and @a locale parameters are always NULL. */ diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index b3013f5..1d394e9 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -789,7 +789,7 @@ int send_request( const char* server, double start = get_timestamp_millis(); - int req_id = osrfAppSessionMakeRequest( session, params, method, 1, NULL ); + int req_id = osrfAppSessionSendRequest( session, params, method, 1 ); jsonObjectFree(params); osrfMessage* omsg = osrfAppSessionRequestRecv( session, req_id, recv_timeout ); @@ -1092,7 +1092,7 @@ static int do_math( int count, int style ) { ++running; double start = get_timestamp_millis(); - int req_id = osrfAppSessionMakeRequest( session, params, methods[j], 1, NULL ); + int req_id = osrfAppSessionSendRequest( session, params, methods[j], 1 ); osrfMessage* omsg = osrfAppSessionRequestRecv( session, req_id, 5 ); double end = get_timestamp_millis(); -- 2.43.2