From 4fe952e87f0de333dd06a1b3b33ed7c8e1eb0cf2 Mon Sep 17 00:00:00 2001 From: erickson Date: Sun, 19 Jun 2005 17:57:55 +0000 Subject: [PATCH] more tweaking to point to the right header files, etc. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@361 9efc2488-bf62-4759-914b-345cdb29e865 --- src/gateway/mod_ils_gateway.c | 19 +++++++++------ src/libstack/Makefile | 6 ++--- src/libstack/osrf_app_session.c | 2 +- src/libstack/osrf_app_session.h | 2 +- src/libstack/osrf_config.h | 47 ++++++++++++++++++++++++++++++++---- src/libstack/osrf_message.c | 7 ++---- src/libstack/osrf_message.h | 16 +++++++++++- src/libstack/osrf_stack.c | 2 +- src/libstack/osrf_stack.h | 1 + src/libstack/osrf_system.c | 2 +- src/libstack/osrf_system.h | 3 +++ src/libstack/string_array.c | 2 +- src/libtransport/Makefile | 6 ++--- src/libtransport/basic_client.c | 2 +- src/libtransport/component.c | 10 +++++++- src/libtransport/transport_client.h | 3 +++ src/libtransport/transport_message.h | 5 ++-- src/libtransport/transport_session.h | 4 ++- src/libtransport/transport_socket.h | 4 +-- src/perlmods/OpenSRF/Transport.pm | 6 ++++- src/perlmods/OpenSRF/UnixServer.pm | 1 + src/router/Makefile | 3 +-- src/router/router.h | 5 +++- src/srfsh/srfsh.c | 2 +- src/srfsh/srfsh.h | 3 +++ 25 files changed, 122 insertions(+), 41 deletions(-) diff --git a/src/gateway/mod_ils_gateway.c b/src/gateway/mod_ils_gateway.c index 19d51a9..4738258 100644 --- a/src/gateway/mod_ils_gateway.c +++ b/src/gateway/mod_ils_gateway.c @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA /* our stuff */ #include "opensrf/transport_client.h" -#include "opensrf/generic_utils.h" #include "opensrf/osrf_message.h" #include "opensrf/osrf_app_session.h" #include "opensrf/string_array.h" @@ -45,15 +44,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define MODULE_NAME "ils_gateway_module" +/* struct session_list_struct { - //char* service; osrf_app_session* session; struct session_list_struct* next; int serve_count; }; typedef struct session_list_struct session_list; -/* the global session cache */ static session_list* the_list = NULL; static void del_session( char* service ) { @@ -89,8 +87,7 @@ static void del_session( char* service ) { } -/* find a session in the list */ -/* if(update) we add 1 to the serve_count */ +// if(update) we add 1 to the serve_count static osrf_app_session* find_session( char* service, int update ) { session_list* item = the_list; @@ -115,7 +112,6 @@ static osrf_app_session* find_session( char* service, int update ) { return NULL; } -/* add a session to the list */ static void add_session( char* service, osrf_app_session* session ) { if(!session) return; @@ -138,6 +134,7 @@ static void add_session( char* service, osrf_app_session* session ) { the_list = new_item; } } +*/ static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) { if( ! osrf_system_bootstrap_client( @@ -264,6 +261,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { info_handler( "param %s", string_array_get_string(sarray,k)); } + /* osrf_app_session* session = find_session(service,1); if(!session) { @@ -271,11 +269,15 @@ static int mod_ils_gateway_method_handler (request_rec *r) { session = osrf_app_client_session_init(service); add_session(service, session); } + */ + + osrf_app_session* session = osrf_app_client_session_init(service); debug_handler("MOD session service: %s", session->remote_service ); /* connect to the remote service */ + /* if(!osrf_app_session_connect(session)) { exception = json_object_new_object(); json_object_object_add( exception, "is_err", json_object_new_int(1)); @@ -286,6 +288,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { json_object_put(exception); return OK; } + */ int req_id = osrf_app_session_make_request( session, NULL, method, 1, sarray ); string_array_destroy(sarray); @@ -296,7 +299,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { buffer_add(result_data, "["); /* gather result data */ - while((omsg = osrf_app_session_request_recv( session, req_id, 30 ))) { + while((omsg = osrf_app_session_request_recv( session, req_id, 60 ))) { if( omsg->result_string ) { buffer_add(result_data, omsg->result_string); @@ -364,6 +367,8 @@ static int mod_ils_gateway_method_handler (request_rec *r) { osrf_app_session_request_finish( session, req_id ); debug_handler("gateway process message successfully"); + + osrf_app_session_destroy(session); return OK; } diff --git a/src/libstack/Makefile b/src/libstack/Makefile index ec9fcd6..7eea68b 100644 --- a/src/libstack/Makefile +++ b/src/libstack/Makefile @@ -1,9 +1,9 @@ CC_OPTS += -DASSUME_STATELESS EXE_LD_OPTS += -lxml2 -lopensrf_transport -lopensrf_stack -lobjson -ljson -lc_utils -SOURCES = osrf_message.c osrf_app_session.c osrf_stack.c osrf_system.c -TARGETS = osrf_message.o osrf_app_session.o osrf_stack.o osrf_system.o -HEADERS = osrf_message.h osrf_app_session.h osrf_stack.h osrf_system.h +SOURCES = osrf_message.c osrf_app_session.c osrf_stack.c osrf_system.c osrf_config.c +TARGETS = osrf_message.o osrf_app_session.o osrf_stack.o osrf_system.o osrf_config.o +HEADERS = osrf_message.h osrf_app_session.h osrf_stack.h osrf_system.h osrf_config.h all: lib diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index 22bea76..673af7e 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -1,4 +1,4 @@ -#include "opensrf/osrf_app_session.h" +#include "osrf_app_session.h" #include /* the global app_session cache */ diff --git a/src/libstack/osrf_app_session.h b/src/libstack/osrf_app_session.h index 0ddd72b..de25dc4 100644 --- a/src/libstack/osrf_app_session.h +++ b/src/libstack/osrf_app_session.h @@ -1,9 +1,9 @@ #include "libjson/json.h" #include "opensrf/transport_client.h" -#include "opensrf/generic_utils.h" #include "osrf_message.h" #include "osrf_system.h" #include "string_array.h" +#include "osrf_config.h" #ifndef OSRF_APP_SESSION #define OSRF_APP_SESSION diff --git a/src/libstack/osrf_config.h b/src/libstack/osrf_config.h index 1d6385f..c6bb5a3 100644 --- a/src/libstack/osrf_config.h +++ b/src/libstack/osrf_config.h @@ -1,13 +1,50 @@ #include -#include "opensrf/transport_client.h" -#include "opensrf/transport_message.h" -#include "osrf_message.h" -#include "opensrf/generic_utils.h" +#include +#include +#include +#include +#include "logging.h" +#include "utils.h" -char* osrf_config_value(char* path); +/* libxml stuff for the config reader */ +#include +#include +#include +//#include +#include + +#include "utils.h" + +#ifndef GENERIC_UTILS_H +#define GENERIC_UTILS_H + +#define equals(a,b) !strcmp(a,b) + +// --------------------------------------------------------------------------------- +// Config file module +// --------------------------------------------------------------------------------- +struct config_reader_struct { + xmlDocPtr config_doc; + xmlXPathContextPtr xpathCx; + char* name; + struct config_reader_struct* next; +}; +typedef struct config_reader_struct config_reader; +config_reader* conf_reader; +//void config_reader_init( char* config_file ); +void config_reader_init( char* name, char* config_file ); + +void config_reader_free(); + +// allocastes a char*. FREE me. +char* config_value( const char* config_name, const char* xp_query, ... ); + + +char* osrf_config_value(char* path); void _osrf_config_grab_config(); +#endif diff --git a/src/libstack/osrf_message.c b/src/libstack/osrf_message.c index 873826f..4d8c152 100644 --- a/src/libstack/osrf_message.c +++ b/src/libstack/osrf_message.c @@ -1,13 +1,10 @@ -#include "opensrf/osrf_message.h" - -#include "utils.h" -#include "objson/object.h" -#include "objson/json_parser.h" +#include "osrf_message.h" /* default to true */ int parse_json_result = 1; int parse_json_params = 1; +/* utility function for debugging a DOM doc */ static void recurse_doc( xmlNodePtr node ) { if( node == NULL ) return; debug_handler("Recurse: %s => %s", node->name, node->content ); diff --git a/src/libstack/osrf_message.h b/src/libstack/osrf_message.h index 5c32c2d..ffe94c2 100644 --- a/src/libstack/osrf_message.h +++ b/src/libstack/osrf_message.h @@ -1,6 +1,20 @@ #include "libjson/json.h" -#include "opensrf/generic_utils.h" #include "string_array.h" +#include "utils.h" +#include "logging.h" +#include "osrf_config.h" +#include "objson/object.h" +#include "objson/json_parser.h" + + +/* libxml stuff for the config reader */ +#include +#include +#include +#include +#include + + #ifndef osrf_message_h #define osrf_message_h diff --git a/src/libstack/osrf_stack.c b/src/libstack/osrf_stack.c index b2cda4a..0848a6f 100644 --- a/src/libstack/osrf_stack.c +++ b/src/libstack/osrf_stack.c @@ -1,4 +1,4 @@ -#include "opensrf/osrf_stack.h" +#include "osrf_stack.h" osrf_message* _do_client( osrf_app_session*, osrf_message* ); osrf_message* _do_server( osrf_app_session*, osrf_message* ); diff --git a/src/libstack/osrf_stack.h b/src/libstack/osrf_stack.h index 23b358e..6c5cedc 100644 --- a/src/libstack/osrf_stack.h +++ b/src/libstack/osrf_stack.h @@ -1,6 +1,7 @@ #include "opensrf/transport_client.h" #include "osrf_message.h" #include "osrf_app_session.h" +#include "osrf_config.h" #ifndef OSRF_STACK_H #define OSRF_STACK_H diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index 662e21b..65b2837 100644 --- a/src/libstack/osrf_system.c +++ b/src/libstack/osrf_system.c @@ -1,4 +1,4 @@ -#include "opensrf/osrf_system.h" +#include "osrf_system.h" transport_client* global_client; diff --git a/src/libstack/osrf_system.h b/src/libstack/osrf_system.h index 7247d3a..5f42728 100644 --- a/src/libstack/osrf_system.h +++ b/src/libstack/osrf_system.h @@ -1,4 +1,7 @@ #include "opensrf/transport_client.h" +#include "utils.h" +#include "logging.h" +#include "osrf_config.h" #ifndef OSRF_SYSTEM_H #define OSRF_SYSTEM_H diff --git a/src/libstack/string_array.c b/src/libstack/string_array.c index f98815f..8290a43 100644 --- a/src/libstack/string_array.c +++ b/src/libstack/string_array.c @@ -1,4 +1,4 @@ -#include "opensrf/string_array.h" +#include "string_array.h" /* int main() { diff --git a/src/libtransport/Makefile b/src/libtransport/Makefile index a2fb8df..50687b5 100644 --- a/src/libtransport/Makefile +++ b/src/libtransport/Makefile @@ -3,9 +3,9 @@ LD_OPTS += -lxml2 -lopensrf_transport -lc_utils -SOURCES = generic_utils.c transport_socket.c transport_session.c transport_message.c transport_client.c -TARGETS = generic_utils.o transport_socket.o transport_message.o transport_session.o transport_client.o -HEADERS = generic_utils.h transport_socket.h transport_message.h transport_session.h transport_client.h +SOURCES = transport_socket.c transport_session.c transport_message.c transport_client.c +TARGETS = transport_socket.o transport_message.o transport_session.o transport_client.o +HEADERS = transport_socket.h transport_message.h transport_session.h transport_client.h all: lib diff --git a/src/libtransport/basic_client.c b/src/libtransport/basic_client.c index d2413bf..817b502 100644 --- a/src/libtransport/basic_client.c +++ b/src/libtransport/basic_client.c @@ -1,4 +1,4 @@ -#include "opensrf/transport_client.h" +#include "transport_client.h" #include "signal.h" pid_t pid; diff --git a/src/libtransport/component.c b/src/libtransport/component.c index 952b6b4..3bc81f6 100644 --- a/src/libtransport/component.c +++ b/src/libtransport/component.c @@ -1,10 +1,18 @@ -#include "opensrf/transport_client.h" +#include "transport_client.h" #include "signal.h" +/* +void print_stuff(void* blah, char* data) { + fprintf(stderr, "Received from socket: %s\n", data); +} +*/ + /* connects and registers with the router */ int main( int argc, char** argv ) { + + if( argc < 5 ) { fatal_handler( "Usage: %s ", argv[0] ); } diff --git a/src/libtransport/transport_client.h b/src/libtransport/transport_client.h index 7453f3a..837e2f7 100644 --- a/src/libtransport/transport_client.h +++ b/src/libtransport/transport_client.h @@ -1,4 +1,7 @@ #include "transport_session.h" +#include "utils.h" +#include "logging.h" + #include #ifndef TRANSPORT_CLIENT_H diff --git a/src/libtransport/transport_message.h b/src/libtransport/transport_message.h index 413c112..a0dc7ff 100644 --- a/src/libtransport/transport_message.h +++ b/src/libtransport/transport_message.h @@ -1,5 +1,3 @@ -#include "generic_utils.h" - #include #include #include @@ -8,6 +6,9 @@ #include #include +#include "utils.h" +#include "logging.h" + #ifndef TRANSPORT_MESSAGE_H #define TRANSPORT_MESSAGE_H diff --git a/src/libtransport/transport_session.h b/src/libtransport/transport_session.h index 44f6df7..373ec1e 100644 --- a/src/libtransport/transport_session.h +++ b/src/libtransport/transport_session.h @@ -5,7 +5,9 @@ // --------------------------------------------------------------------------------- #include "transport_socket.h" #include "transport_message.h" -#include "generic_utils.h" + +#include "utils.h" +#include "logging.h" #include "sha.h" diff --git a/src/libtransport/transport_socket.h b/src/libtransport/transport_socket.h index 927fbad..dd1f146 100644 --- a/src/libtransport/transport_socket.h +++ b/src/libtransport/transport_socket.h @@ -1,10 +1,10 @@ -#include "generic_utils.h" - #include #include #include #include +#include "utils.h" +#include "logging.h" //--------------------------------------------------------------- // WIN32 //--------------------------------------------------------------- diff --git a/src/perlmods/OpenSRF/Transport.pm b/src/perlmods/OpenSRF/Transport.pm index 5c4afa5..f669dbe 100644 --- a/src/perlmods/OpenSRF/Transport.pm +++ b/src/perlmods/OpenSRF/Transport.pm @@ -139,7 +139,11 @@ sub handler { } else { $app_session->reset; $app_session->state( $app_session->DISCONNECTED ); - $app_session->push_resend( $app_session->app_request( $doc->documentElement->firstChild->threadTrace ) ); + # below will lead to infinite looping, should return an exception + #$app_session->push_resend( $app_session->app_request( + # $doc->documentElement->firstChild->threadTrace ) ); + $logger->debug( + "Got Jabber error on client connection $remote_id, nothing we can do..", ERROR ); return 1; } } diff --git a/src/perlmods/OpenSRF/UnixServer.pm b/src/perlmods/OpenSRF/UnixServer.pm index b8b1402..69ba09c 100644 --- a/src/perlmods/OpenSRF/UnixServer.pm +++ b/src/perlmods/OpenSRF/UnixServer.pm @@ -72,6 +72,7 @@ sub process_request { $0 = "$0*"; if( ! $data or ! defined( $data ) or $data eq "" ) { + close($self->{server}->{client}); $logger->debug("Unix child received empty data from socket", ERROR); $0 = $orig; return; diff --git a/src/router/Makefile b/src/router/Makefile index e67c1e7..9fdc8a2 100644 --- a/src/router/Makefile +++ b/src/router/Makefile @@ -3,8 +3,7 @@ LD_OPTS += -lc_utils -lxml2 -lopensrf_stack -ljson -lobjson LP = ../libtransport -LIB_SOURCES = $(LP)/generic_utils.c $(LP)/transport_socket.c \ - $(LP)/transport_session.c $(LP)/transport_message.c $(LP)/transport_client.c +LIB_SOURCES = $(LP)/transport_socket.c $(LP)/transport_session.c $(LP)/transport_message.c $(LP)/transport_client.c all: router diff --git a/src/router/router.h b/src/router/router.h index 3d04508..837b883 100644 --- a/src/router/router.h +++ b/src/router/router.h @@ -1,7 +1,10 @@ #include "opensrf/transport_client.h" #include "opensrf/transport_message.h" #include "opensrf/osrf_message.h" -#include "opensrf/generic_utils.h" + +#include "utils.h" +#include "logging.h" +#include "osrf_config.h" #include #include diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index 3a7c41e..9b8fa66 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -750,7 +750,7 @@ int do_math( int count, int style ) { json_object_array_add(params, json_object_new_string("2")); char* methods[] = { "add", "sub", "mult", "div" }; - char* answers[] = { "3", "-1", "2", "0.500000" }; + char* answers[] = { "3", "-1", "2", "0.5" }; float times[ count * 4 ]; memset(times,0,count*4); diff --git a/src/srfsh/srfsh.h b/src/srfsh/srfsh.h index 13bde43..5fec410 100644 --- a/src/srfsh/srfsh.h +++ b/src/srfsh/srfsh.h @@ -6,6 +6,7 @@ #include #include "md5.h" +#include "utils.h" #include @@ -14,6 +15,8 @@ #include + + #define SRFSH_PORT 5222 #define COMMAND_BUFSIZE 4096 -- 2.11.0