fixed bug where session id's were always coming up the same
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Mar 2005 21:01:42 +0000 (21:01 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Mar 2005 21:01:42 +0000 (21:01 +0000)
added some debugging

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@260 9efc2488-bf62-4759-914b-345cdb29e865

src/libstack/osrf_app_session.c
src/libstack/osrf_stack.c
src/libstack/osrf_system.c

index 620d18c..30e5b23 100644 (file)
@@ -216,6 +216,7 @@ void _osrf_app_session_remove_session( char* session_id ) {
 /** Allocates a initializes a new app_session */
 
 osrf_app_session* osrf_app_client_session_init( char* remote_service ) {
+
        osrf_app_session* session = safe_malloc(sizeof(osrf_app_session));      
 
        session->transport_handle = osrf_system_get_transport_client();
@@ -239,8 +240,9 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) {
        /* build a chunky, random session id */
        char id[256];
        memset(id,0,256);
-       srand((int)time(NULL));
-       sprintf(id, "%d.%d%d", rand(), (int)time(NULL), getpid());
+       //srand((int)time(NULL));
+
+       sprintf(id, "%lf.%d%d", get_timestamp_millis(), (int)time(NULL), getpid());
        session->session_id = strdup(id);
        debug_handler( "Building a new client session with id [%s]", session->session_id );
 
@@ -476,9 +478,13 @@ int osrf_app_session_connect(osrf_app_session* session){
 
        while( session->state != OSRF_SESSION_CONNECTED && remaining >= 0 ) {
                osrf_app_session_queue_wait( session, remaining );
+               debug_handler("In connect while with state: %x, %d [%s]", session, session->state, session->session_id );
                remaining -= (int) (time(NULL) - start);
        }
 
+       if(session->state == OSRF_SESSION_CONNECTED)
+               debug_handler(" * Connected Successfully");
+
        if(session->state != OSRF_SESSION_CONNECTED)
                return 0;
 
index c18f5bb..a5cab97 100644 (file)
@@ -22,8 +22,9 @@ int osrf_stack_transport_handler( transport_message* msg ) {
        osrf_app_session* session = osrf_app_session_find_session( msg->thread );
 
        if( session == NULL ) {  /* we must be a server, build a new session */
-               info_handler( "Server sessions not implemented yet ..." );
-               return 0;
+               info_handler( "Received message for nonexistant session. Dropping..." );
+               message_free( msg );
+               return 1;
        }
 
        debug_handler("Session [%s] found, building message", msg->thread );
@@ -79,7 +80,9 @@ osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) {
                switch( msg->status_code ) {
 
                        case OSRF_STATUS_OK:
+                               debug_handler("We connected successfully");
                                session->state = OSRF_SESSION_CONNECTED;
+                               debug_handler( "State: %x => %s => %d", session, session->session_id, session->state );
                                return NULL;
 
                        case OSRF_STATUS_COMPLETE:
index 49c606e..662e21b 100644 (file)
@@ -7,16 +7,19 @@ transport_client* osrf_system_get_transport_client() {
 }
 
 int osrf_system_bootstrap_client( char* config_file ) {
+
        if( config_file == NULL )
                fatal_handler("No Config File Specified\n" );
 
        config_reader_init( "opensrf.bootstrap", config_file ); 
+
        char* log_file          = config_value( "opensrf.bootstrap", "//logs/client" );
        char* log_level = config_value( "opensrf.bootstrap", "//bootstrap/debug" );
        char* domain            = config_value( "opensrf.bootstrap", "//bootstrap/domains/domain1" ); /* just the first for now */
        char* username          = config_value( "opensrf.bootstrap", "//bootstrap/username" );
        char* password          = config_value( "opensrf.bootstrap", "//bootstrap/passwd" );
        char* port                      = config_value( "opensrf.bootstrap", "//bootstrap/port" );
+
        int llevel = 0;
        int iport = atoi(port);