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)) {
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] );
(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;
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();
/* 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() );
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;
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;
//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);
}
int i = 1;
- osrfLogDebug("Setting TCP_NODELAY");
+ //osrfLogDebug("Setting TCP_NODELAY");
setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i));
if(head->sock_fd == sock_fd) {
mgr->socket = head->next;
free(head);
- osrfLogDebug("removing first socket in list");
return;
}
/* 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" );
}
}
- osrfLogDebug("%d active sockets after select()", retval);
+ osrfLogInternal("%d active sockets after select()", retval);
return _socket_route_data_id(mgr, sock_fd);
}
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;
/* 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);
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()");
}
}
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);