Added new C event code for handling the auth login events
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 6 Dec 2005 21:38:05 +0000 (21:38 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 6 Dec 2005 21:38:05 +0000 (21:38 +0000)
(just remembered that i need to read the events file from the settings server)

updated auth to use the new events code

added some events to the constants file

update srfsh to accept the new event

cleaned up some logging in the prefork and socket_bundle code

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

src/libstack/osrf_prefork.c
src/srfsh/srfsh.c
src/utils/socket_bundle.c

index 528c337..c467ae9 100644 (file)
@@ -109,7 +109,7 @@ void osrf_prefork_register_routers( char* appname ) {
 void prefork_child_init_hook(prefork_child* child) {
 
        if(!child) return;
-       osrfLogInfo("Child init hook for child %d", child->pid);
+       osrfLogDebug("Child init hook for child %d", child->pid);
        char* resc = va_list_to_string("%s_drone",child->appname);
 
        if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc)) {
@@ -186,7 +186,7 @@ prefork_child*  launch_child( prefork_simple* forker ) {
                return NULL;
        }
 
-       osrfLogDebug( "Pipes: %d %d %d %d", data_fd[0], data_fd[1], status_fd[0], status_fd[1] );
+       osrfLogInternal( "Pipes: %d %d %d %d", data_fd[0], data_fd[1], status_fd[0], status_fd[1] );
        prefork_child* child = prefork_child_init( forker->max_requests, data_fd[0], 
                        data_fd[1], status_fd[0], status_fd[1] );
 
@@ -206,7 +206,7 @@ prefork_child*  launch_child( prefork_simple* forker ) {
                (forker->current_num_children)++;
                child->pid = pid;
 
-               osrfLogInfo( "Parent launched %d", pid );
+               osrfLogDebug( "Parent launched %d", pid );
                /* *no* child pipe FD's can be closed or the parent will re-use fd's that
                        the children are currently using */
                return child;
@@ -214,7 +214,7 @@ prefork_child*  launch_child( prefork_simple* forker ) {
 
        else { /* child */
 
-               osrfLogDebug("I am  new child with read_data_fd = %d and write_status_fd = %d",
+               osrfLogInternal("I am  new child with read_data_fd = %d and write_status_fd = %d",
                        child->read_data_fd, child->write_status_fd );
 
                child->pid = getpid();
@@ -295,18 +295,18 @@ void prefork_run(prefork_simple* forker) {
                        /* Look for an available child */
                        for( k = 0; k < forker->current_num_children; k++ ) {
 
-                               osrfLogDebug("Searching for available child. cur_child->pid = %d", cur_child->pid );
-                               osrfLogDebug("Current num children %d and loop %d", forker->current_num_children, k);
+                               osrfLogInternal("Searching for available child. cur_child->pid = %d", cur_child->pid );
+                               osrfLogInternal("Current num children %d and loop %d", forker->current_num_children, k);
                        
                                if( cur_child->available ) {
-                                       osrfLogDebug( "sending data to %d", cur_child->pid );
+                                       osrfLogDebug( "forker sending data to %d", cur_child->pid );
 
                                        message_prepare_xml( cur_msg );
                                        char* data = cur_msg->msg_xml;
                                        if( ! data || strlen(data) < 1 ) break;
 
                                        cur_child->available = 0;
-                                       osrfLogDebug( "Writing to child fd %d", cur_child->write_data_fd );
+                                       osrfLogInternal( "Writing to child fd %d", cur_child->write_data_fd );
 
                                        int written = 0;
                                        //fprintf(stderr, "Writing Data %f\n", get_timestamp_millis() );
@@ -337,8 +337,8 @@ void prefork_run(prefork_simple* forker) {
                                        char* data = cur_msg->msg_xml;
                                        if( ! data || strlen(data) < 1 ) break;
                                        new_child->available = 0;
-                                       osrfLogDebug( "sending data to %d", new_child->pid );
-                                       osrfLogDebug( "Writing to new child fd %d", new_child->write_data_fd );
+                                       osrfLogDebug( "Writing to new child fd %d : pid %d", 
+                                                       new_child->write_data_fd, new_child->pid );
                                        write( new_child->write_data_fd, data, strlen(data) + 1 );
                                        forker->first_child = new_child->next;
                                        honored = 1;
index 294c5d5..8909887 100644 (file)
@@ -279,7 +279,7 @@ int handle_login( char* words[]) {
 
                jsonObject* x = last_result->_result_content;
                if(x) {
-                       char* authtoken = jsonObjectGetString(jsonObjectGetKey(x, "authtoken"));
+                       char* authtoken = jsonObjectGetString(jsonObjectGetKey(x,"payload"));
                        if(authtoken) login_session = strdup(authtoken);
                        else login_session = NULL;
                }
index 70d94ba..4849fa2 100644 (file)
@@ -63,7 +63,7 @@ socket_node* _socket_add_node(socket_manager* mgr,
                int endpoint, int addr_type, int sock_fd, int parent_id ) {
 
        if(mgr == NULL) return NULL;
-       osrfLogDebug("Adding socket node with fd %d", sock_fd);
+       osrfLogInternal("Adding socket node with fd %d", sock_fd);
        socket_node* new_node = safe_malloc(sizeof(socket_node));
 
        new_node->endpoint      = endpoint;
@@ -159,7 +159,7 @@ int socket_open_unix_server(socket_manager* mgr, char* path) {
        //osrfLogDebug("Setting SO_REUSEADDR");
        //setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
        
-       osrfLogDebug("Setting TCP_NODELAY");
+       //osrfLogDebug("Setting TCP_NODELAY");
        setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i));
 
        _socket_add_node(mgr, SERVER_SOCKET, UNIX, sock_fd, 0);
@@ -209,7 +209,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) {
    }
 
        int i = 1;
-       osrfLogDebug("Setting TCP_NODELAY");
+       //osrfLogDebug("Setting TCP_NODELAY");
        setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i));
 
 
@@ -351,7 +351,6 @@ void socket_remove_node(socket_manager* mgr, int sock_fd) {
        if(head->sock_fd == sock_fd) {
                mgr->socket = head->next;
                free(head);
-               osrfLogDebug("removing first socket in list");
                return;
        }
 
@@ -385,10 +384,9 @@ void _socket_print_list(socket_manager* mgr) {
 
 /* sends the given data to the given socket */
 int socket_send(int sock_fd, const char* data) {
-       osrfLogDebug( "socket_bundle sending to %d data %s",
+       osrfLogInternal( "socket_bundle sending to %d data %s",
                sock_fd, data);
 
-       osrfLogDebug("%d : Sending data at %lf\n", getpid(), get_timestamp_millis());
        signal(SIGPIPE, SIG_IGN); /* in case a unix socket was closed */
        if( send( sock_fd, data, strlen(data), 0 ) < 0 ) {
                osrfLogWarning( "tcp_server_send(): Error sending data" );
@@ -455,7 +453,7 @@ int socket_wait(socket_manager* mgr, int timeout, int sock_fd) {
                }
        }
 
-       osrfLogDebug("%d active sockets after select()", retval);
+       osrfLogInternal("%d active sockets after select()", retval);
        return _socket_route_data_id(mgr, sock_fd);
 }
 
@@ -530,7 +528,7 @@ int _socket_route_data(
                        
                        if(last_failed_id != -1) {
                                /* in case it was not removed by our overlords */
-                               osrfLogDebug("Attempting to remove last_failed_id of %d", last_failed_id);
+                               osrfLogInternal("Attempting to remove last_failed_id of %d", last_failed_id);
                                socket_remove_node( mgr, last_failed_id );
                                last_failed_id = -1;
                                status = -1;
@@ -540,7 +538,7 @@ int _socket_route_data(
                        /* does this socket have data? */
                        if( FD_ISSET( sock_fd, read_set ) ) {
        
-                               osrfLogDebug("Socket %d active", sock_fd);
+                               osrfLogInternal("Socket %d active", sock_fd);
                                handled++;
                                FD_CLR(sock_fd, read_set);
        
@@ -554,7 +552,7 @@ int _socket_route_data(
                                        us...start over with the first socket */
                                if(status == -1)  {
                                        last_failed_id = sock_fd;
-                                       osrfLogDebug("Backtracking back to start of loop because "
+                                       osrfLogInternal("Backtracking back to start of loop because "
                                                        "of -1 return code from _socket_handle_client_data()");
                                }
                        }
@@ -623,12 +621,11 @@ int _socket_handle_client_data(socket_manager* mgr, socket_node* node) {
 
        memset(buf, 0, RBUFSIZE);
        set_fl(sock_fd, O_NONBLOCK);
-       osrfLogDebug("Gathering client data for %d", node->sock_fd);
 
-       osrfLogDebug("%d : Received data at %lf\n", getpid(), get_timestamp_millis());
+       osrfLogInternal("%d : Received data at %lf\n", getpid(), get_timestamp_millis());
 
        while( (read_bytes = recv(sock_fd, buf, RBUFSIZE-1, 0) ) > 0 ) {
-               osrfLogDebug("Socket %d Read %d bytes and data: %s", sock_fd, read_bytes, buf);
+               osrfLogInternal("Socket %d Read %d bytes and data: %s", sock_fd, read_bytes, buf);
                if(mgr->data_received)
                        mgr->data_received(mgr->blob, mgr, sock_fd, buf, node->parent_id);