if( a && b ) {
- osrfLogActivity( "Running opensrf.math %s [ %s : %s ]",
+ osrfLogActivity( OSRF_LOG_MARK, "Running opensrf.math %s [ %s : %s ]",
ctx->method->name, a, b );
/* construct a new params object to send to dbmath */
free(json);
if( cachedmd5 ) {
- osrfLogDebug( "Found %s object in cache, returning....", cachedmd5 );
+ osrfLogDebug(OSRF_LOG_MARK, "Found %s object in cache, returning....", cachedmd5 );
jsonObject* resp = jsonNewObject(cachedmd5);
osrfAppRespondComplete( ctx, resp );
jsonObjectFree(resp);
osrfAppRespondComplete( ctx, resp );
jsonObjectFree(resp);
osrfAppSessionFree(ses);
- osrfLogDebug("Found version string %s, caching and returning...", resultmd5 );
+ osrfLogDebug(OSRF_LOG_MARK, "Found version string %s, caching and returning...", resultmd5 );
osrfCachePutString( paramsmd5, resultmd5, OSRF_VERSION_CACHE_TIME );
free(resultmd5);
free(paramsmd5);
char* cfg = ils_gateway_config_file;
if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT) ) {
- osrfLogError("Unable to bootstrap client in gateway...");
+ osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client in gateway...");
return;
}
fprintf(stderr, "Bootstrapping %d\n", getpid() );
/* verify we are connected */
if(!osrf_system_get_transport_client()) {
- osrfLogError("Bootstrap Failed, no transport client");
+ osrfLogError( OSRF_LOG_MARK, "Bootstrap Failed, no transport client");
return HTTP_INTERNAL_SERVER_ERROR;
}
ap_set_content_type(r, "text/plain");
- osrfLogDebug("Apache request method: %s", r->method );
+ osrfLogDebug( OSRF_LOG_MARK, "Apache request method: %s", r->method );
/* gather the post args and append them to the url query string */
if( !strcmp(r->method,"POST") ) {
ap_setup_client_block(r,REQUEST_CHUNKED_DECHUNK);
if(! ap_should_client_block(r)) {
- osrfLogWarning("No Post Body");
+ osrfLogWarning( OSRF_LOG_MARK, "No Post Body");
ap_rputs("null", r);
return OK;
}
}
if( buffer->n_used < 1 ) {
- osrfLogWarning("No Post Body");
+ osrfLogWarning( OSRF_LOG_MARK, "No Post Body");
ap_rputs("null", r);
return OK;
}
}
if( ! arg || strlen(arg) == 0 ) { /* we received no request */
- osrfLogWarning("No Args");
+ osrfLogWarning( OSRF_LOG_MARK, "No Args");
ap_rputs("null", r);
return OK;
}
- osrfLogDebug("URL: %s", arg );
+ osrfLogDebug( OSRF_LOG_MARK, "URL: %s", arg );
ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg );
r->allowed |= (AP_METHOD_BIT << M_GET);
fprintf(stderr, "DONE URL KEY: %s %d\n", key, api_level);
fflush(stderr);
- osrfLogInfo("\r\nPerforming(%d): service %s "
+ osrfLogInfo( OSRF_LOG_MARK, "\r\nPerforming(%d): service %s "
"| method %s |", getpid(), service, method );
int k;
for( k = 0; k!= sarray->size; k++ ) {
- osrfLogInfo( "param %s", string_array_get_string(sarray,k));
+ osrfLogInfo( OSRF_LOG_MARK, "param %s", string_array_get_string(sarray,k));
}
osrf_app_session* session = osrf_app_client_session_init(service);
- osrfLogDebug("session service: %s", session->remote_service );
+ osrfLogDebug( OSRF_LOG_MARK, "session service: %s", session->remote_service );
int req_id = osrf_app_session_make_req( session, NULL, method, api_level, sarray );
string_array_destroy(sarray);
char* s = omsg->status_name ? omsg->status_name : "Unknown Error";
char* t = omsg->status_text ? omsg->status_text : "No Error Message";
jsonObjectSetKey(response, "debug", jsonNewObject("\n\n%s:\n%s\n", s, t));
- osrfLogError( "Gateway received error: %s",
+ osrfLogError( OSRF_LOG_MARK, "Gateway received error: %s",
jsonObjectGetString(jsonObjectGetKey(response, "debug")));
break;
}
char* content = jsonObjectToJSON(response);
if(content) {
- osrfLogInfo( "Gateway responding with: %s", content );
+ osrfLogInfo( OSRF_LOG_MARK, "Gateway responding with: %s", content );
ap_rputs(content,r);
free(content);
}
jsonObjectFree(response);
osrf_app_session_request_finish( session, req_id );
- osrfLogDebug("gateway processed message successfully");
+ osrfLogDebug( OSRF_LOG_MARK, "gateway processed message successfully");
osrf_app_session_destroy(session);
return OK;
node->to, node->resource, node->username, node->domain, node->authkey, node->type );
}
- osrfLogDebug("DEBUG:\n%s", buf->buf );
+ osrfLogDebug( OSRF_LOG_MARK, "DEBUG:\n%s", buf->buf );
buffer_free(buf);
osrfListIteratorFree(itr);
}
if(!server) return -1;
while(1) {
if(socket_wait_all(server->mgr, -1) < 0)
- osrfLogWarning( "jserver_wait(): socket_wait_all() returned error");
+ osrfLogWarning( OSRF_LOG_MARK, "jserver_wait(): socket_wait_all() returned error");
}
return -1;
}
osrfChatNode* node = osrfListGetIndex( server->nodeList, sockid );
if(node)
- osrfLogDebug("Found node for sockid %d with state %d", sockid, node->state);
+ osrfLogDebug( OSRF_LOG_MARK, "Found node for sockid %d with state %d", sockid, node->state);
if(!node) {
- osrfLogDebug("Adding new connection for sockid %d", sockid );
+ osrfLogDebug( OSRF_LOG_MARK, "Adding new connection for sockid %d", sockid );
node = osrfChatAddNode( server, sockid );
}
if(node) {
if( (osrfChatPushData( server, node, data ) == -1) ) {
- osrfLogWarning("Node at socket %d received bad XML, disconnecting...", sockid );
+ osrfLogWarning( OSRF_LOG_MARK, "Node at socket %d received bad XML, disconnecting...", sockid );
osrfChatSendRaw( node, OSRF_CHAT_PARSE_ERROR );
osrfChatRemoveNode( server, node );
}
if( eq( dombuf, cs->domain ) ) { /* this is to a user we host */
- osrfLogInfo("Sending message on local connection\nfrom: %s\nto: %s", fromAddr, toAddr );
+ osrfLogInfo( OSRF_LOG_MARK, "Sending message on local connection\nfrom: %s\nto: %s", fromAddr, toAddr );
osrfChatNode* tonode = osrfHashGet(cs->nodeHash, toAddr);
if(tonode) {
osrfChatSendRaw( tonode, msgXML );
} else {
/* send an error message saying we don't have this connection */
- osrfLogInfo("We have no connection for %s", toAddr);
+ osrfLogInfo( OSRF_LOG_MARK, "We have no connection for %s", toAddr);
char* xml = va_list_to_string( OSRF_CHAT_NO_RECIPIENT, toAddr, fromAddr );
osrfChatSendRaw( node, xml );
free(xml);
osrfChatNode* tonode = osrfHashGet(cs->nodeHash, dombuf);
if(tonode) {
if( tonode->state == OSRF_CHAT_STATE_CONNECTED ) {
- osrfLogDebug("Routing message to server %s", dombuf);
+ osrfLogDebug( OSRF_LOG_MARK, "Routing message to server %s", dombuf);
osrfChatSendRaw( tonode, msgXML );
} else {
- osrfLogInfo("Received s2s message and we're still trying to connect...caching");
+ osrfLogInfo( OSRF_LOG_MARK, "Received s2s message and we're still trying to connect...caching");
osrfListPush( tonode->msgs, strdup(msgXML) );
}
} else {
if( osrfChatInitS2S( cs, dombuf, toAddr, msgXML ) != 0 ) {
- osrfLogWarning("We are unable to connect to remote server %s for recipient %s", dombuf, toAddr);
+ osrfLogWarning( OSRF_LOG_MARK, "We are unable to connect to remote server %s for recipient %s", dombuf, toAddr);
char* xml = va_list_to_string( OSRF_CHAT_NO_RECIPIENT, toAddr, fromAddr );
osrfChatSendRaw( node, xml );
free(xml);
osrfChatS2SMessage* msg = safe_malloc(sizeof(osrfChatS2SMessage));
msg->toAddr = strdup(toAddr);
msg->msgXML = strdup(msgXML);
- osrfLogInfo("Pushing client message onto s2s queue waiting for connect... ");
+ osrfLogInfo( OSRF_LOG_MARK, "Pushing client message onto s2s queue waiting for connect... ");
osrfListPush( snode->msgs, msgXML );
}
*/
int osrfChatInitS2S( osrfChatServer* cs, char* remote, char* toAddr, char* msgXML ) {
if(!(cs && remote && toAddr && msgXML)) return -1;
- osrfLogInfo("Initing server2server connection to domain %s", remote );
+ osrfLogInfo( OSRF_LOG_MARK, "Initing server2server connection to domain %s", remote );
osrfChatNode* snode = osrfNewChatS2SNode( cs->domain, remote );
snode->parent = cs;
/* try to connect to the remote site */
snode->sockid = socket_open_tcp_client(cs->mgr, cs->s2sport, remote);
if(snode->sockid < 1) {
- osrfLogWarning("Unable to connect to remote server at %s", remote );
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to connect to remote server at %s", remote );
return -1;
}
/* send the initial s2s request */
osrfChatSendRaw( snode, OSRF_CHAT_S2S_INIT );
- osrfLogDebug("Added new s2s node...");
+ osrfLogDebug( OSRF_LOG_MARK, "Added new s2s node...");
chatdbg(cs);
return 0;
chatdbg(server);
- osrfLogDebug("pushing data into xml parser for node %d with state %d:\n%s",
+ osrfLogDebug( OSRF_LOG_MARK, "pushing data into xml parser for node %d with state %d:\n%s",
node->sockid, node->state, data);
node->inparse = 1;
xmlParseChunk(node->parserCtx, data, strlen(data), 0);
void osrfChatStartStream( void* blob ) {
- osrfLogDebug("Starting new client stream...");
+ osrfLogDebug( OSRF_LOG_MARK, "Starting new client stream...");
}
int status = -1;
char* nm = (char*) name;
- osrfLogDebug("Starting element %s with namespace %s and node state %d",
+ osrfLogDebug( OSRF_LOG_MARK, "Starting element %s with namespace %s and node state %d",
nm, xmlSaxAttr(atts, "xmlns"), node->state );
switch( node->state ) {
case OSRF_CHAT_STATE_NONE:
status = osrfChatHandleNewConnection( node, nm, atts );
- osrfLogDebug("After NewConnection we have state %d", node->state);
+ osrfLogDebug( OSRF_LOG_MARK, "After NewConnection we have state %d", node->state);
break;
case OSRF_CHAT_STATE_CONNECTING:
osrfChatParseError( node, "We don't know how to handle the XML data received" );
}
-#define CHAT_CHECK_VARS(x,y,z) if(!(x && y)) return -1; if(z) osrfLogDebug(z);
+#define CHAT_CHECK_VARS(x,y,z) if(!(x && y)) return -1; if(z) osrfLogDebug( OSRF_LOG_MARK, z);
char* from = (char*) xmlGetProp(xmlDocGetRootElement(doc), BAD_CAST "from");
char* to = (char*) xmlGetProp(xmlDocGetRootElement(doc), BAD_CAST "to");
osrfChatSend( node->parent, node, to, from, xml );
- osrfLogDebug("Sending cached message from %s to %s", from, to);
+ osrfLogDebug( OSRF_LOG_MARK, "Sending cached message from %s to %s", from, to);
xmlFree(to); xmlFree(from);
xmlFreeDoc(doc);
}
}
if(status == 0) {
- osrfLogInfo("Successfully made S2S connection to %s", node->remote );
+ osrfLogInfo( OSRF_LOG_MARK, "Successfully made S2S connection to %s", node->remote );
node->state = OSRF_CHAT_STATE_CONNECTED;
node->xmlstate = 0;
}
if(!domain) return -1;
if(!eq(domain, node->domain)) {
- osrfLogWarning("Client attempting to connect to invalid domain");
+ osrfLogWarning( OSRF_LOG_MARK, "Client attempting to connect to invalid domain");
return -1;
}
char* buf = va_list_to_string( OSRF_CHAT_START_STREAM, domain, node->authkey );
node->state = OSRF_CHAT_STATE_CONNECTING;
- osrfLogDebug("Server node %d setting state to OSRF_CHAT_STATE_CONNECTING[%d]",
+ osrfLogDebug( OSRF_LOG_MARK, "Server node %d setting state to OSRF_CHAT_STATE_CONNECTING[%d]",
node->sockid, node->state );
- osrfLogDebug("Server responding to connect message with\n%s\n", buf );
+ osrfLogDebug( OSRF_LOG_MARK, "Server responding to connect message with\n%s\n", buf );
osrfChatSendRaw( node, buf );
free(buf);
return 0;
/* server to server init */
if(eq(ns, "jabber:server")) { /* client connection */
- osrfLogInfo("We received a new server 2 server connection, generating auth key...");
+ osrfLogInfo( OSRF_LOG_MARK, "We received a new server 2 server connection, generating auth key...");
char* xml = va_list_to_string( OSRF_CHAT_S2S_CHALLENGE, node->authkey );
osrfChatSendRaw( node, xml );
free(xml);
int osrfChatHandleConnecting( osrfChatNode* node, const char* name, const xmlChar** atts ) {
CHAT_CHECK_VARS(node, name, "osrfChatHandleConnecting()");
- osrfLogDebug("Handling connect node %s", name );
+ osrfLogDebug( OSRF_LOG_MARK, "Handling connect node %s", name );
if(eq(name, "iq")) node->xmlstate |= OSRF_CHAT_STATE_INIQ;
else if(eq(name,"username")) node->xmlstate |= OSRF_CHAT_STATE_INUSERNAME;
/* takes s2s secret, hashdomain, and the s2s auth token */
static char* osrfChatGenerateS2SKey( char* secret, char* hashdomain, char* authtoken ) {
if(!(secret && hashdomain && authtoken)) return NULL;
- osrfLogInfo("Generating s2s key with auth token: %s", authtoken );
+ osrfLogInfo( OSRF_LOG_MARK, "Generating s2s key with auth token: %s", authtoken );
char* a = shahash(secret);
- osrfLogDebug("S2S secret hash: %s", a);
+ osrfLogDebug( OSRF_LOG_MARK, "S2S secret hash: %s", a);
char* b = va_list_to_string("%s%s", a, hashdomain);
char* c = shahash(b);
- osrfLogDebug("S2S intermediate hash: %s", c);
+ osrfLogDebug( OSRF_LOG_MARK, "S2S intermediate hash: %s", c);
char* d = va_list_to_string("%s%s", c, authtoken);
char* e = strdup(shahash(d));
free(b); free(d);
/* we use our domain in the s2s challenge hash */
char* d = osrfChatGenerateS2SKey(node->parent->secret, node->domain, id );
char* e = va_list_to_string(OSRF_CHAT_S2S_RESPONSE, node->remote, node->domain, d );
- osrfLogInfo("Answering s2s challenge with key: %s", e );
+ osrfLogInfo( OSRF_LOG_MARK, "Answering s2s challenge with key: %s", e );
osrfChatSendRaw( node, e );
free(d); free(e);
node->state = OSRF_CHAT_STATE_S2S_VERIFY;
char* string = xmlDocToString(node->msgDoc, 0 );
char* from = (char*) xmlGetProp(msg, BAD_CAST "from");
- osrfLogDebug( "Routing message to %s\n%s\n", node->to, from, string );
+ osrfLogDebug( OSRF_LOG_MARK, "Routing message to %s\n%s\n", node->to, from, string );
osrfChatSend( node->parent, node, node->to, from, string );
xmlFree(from);
free(string);
node->remote = va_list_to_string(
"%s@%s/%s", node->username, node->domain, node->resource );
- osrfLogInfo("%s successfully logged in", node->remote );
+ osrfLogInfo( OSRF_LOG_MARK, "%s successfully logged in", node->remote );
- osrfLogDebug("Setting remote address to %s", node->remote );
+ osrfLogDebug( OSRF_LOG_MARK, "Setting remote address to %s", node->remote );
osrfChatSendRaw( node, OSRF_CHAT_LOGIN_OK );
if(osrfHashGet( node->parent->nodeHash, node->remote ) ) {
- osrfLogWarning("New node replaces existing node for remote id %s", node->remote);
+ osrfLogWarning( OSRF_LOG_MARK, "New node replaces existing node for remote id %s", node->remote);
osrfHashRemove(node->parent->nodeHash, node->remote);
}
osrfHashSet( node->parent->nodeHash, node, node->remote );
osrfChatNode* node = (osrfChatNode*) blob;
/*
- osrfLogDebug("Char Handler: state %d, xmlstate %d, chardata %s",
+ osrfLogDebug( OSRF_LOG_MARK, "Char Handler: state %d, xmlstate %d, chardata %s",
node->state, node->xmlstate, (char*) ch );
*/
(node->xmlstate & OSRF_CHAT_STATE_INS2SRESULT) ) {
char* key = strndup((char*) ch, len);
- osrfLogDebug("Got s2s key from %s : %s", node->remote, key );
+ osrfLogDebug( OSRF_LOG_MARK, "Got s2s key from %s : %s", node->remote, key );
char* e = osrfChatGenerateS2SKey(node->parent->secret, node->remote, node->authkey );
- osrfLogInfo("\nReceived s2s key from server: %s\nKey should be: %s", key, e );
+ osrfLogInfo( OSRF_LOG_MARK, "\nReceived s2s key from server: %s\nKey should be: %s", key, e );
if(eq(key, e)) {
char* msg = va_list_to_string(OSRF_CHAT_S2S_VERIFY_REQUEST,
node->xmlstate = 0;
} else {
- osrfLogWarning("Server2Server keys do not match!");
+ osrfLogWarning( OSRF_LOG_MARK, "Server2Server keys do not match!");
}
/* do the hash dance again */
osrfChatServer* server = osrfNewChatServer(domain, secret, s2port);
if( osrfChatServerConnect( server, port, s2port, listenaddr ) != 0 ) {
- osrfLogError("ChopChop unable to bind to port %d on %s", port, listenaddr);
+ osrfLogError( OSRF_LOG_MARK, "ChopChop unable to bind to port %d on %s", port, listenaddr);
return -1;
}
xmlDocPtr doc = xmlParseFile(configFile);
if(!doc) {
- osrfLogWarning( "Unable to parse XML config file %s", configFile);
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to parse XML config file %s", configFile);
return NULL;
}
xmlFreeDoc(doc);
if(!cfg->config) {
- osrfLogWarning("xmlDocToJSON failed for config %s", configFile);
+ osrfLogWarning( OSRF_LOG_MARK, "xmlDocToJSON failed for config %s", configFile);
return NULL;
}
if(!path) return NULL;
if(!cfg) cfg = __osrfConfigDefault;
- if(!cfg) { osrfLogWarning("No Confif object!"); return NULL; }
+ if(!cfg) { osrfLogWarning( OSRF_LOG_MARK, "No Confif object!"); return NULL; }
VA_LIST_TO_STRING(path);
if(!arr || !path) return 0;
if(!cfg) cfg = __osrfConfigDefault;
- if(!cfg) { osrfLogWarning("No Config object!"); return -1;}
+ if(!cfg) { osrfLogWarning( OSRF_LOG_MARK, "No Config object!"); return -1;}
VA_LIST_TO_STRING(path);
/** Pushes the given message onto the list of 'responses' to this request */
void _osrf_app_request_push_queue( osrf_app_request* req, osrf_message* result ){
if(req == NULL || result == NULL) return;
- osrfLogDebug( "App Session pushing request [%d] onto request queue", result->thread_trace );
+ osrfLogDebug( OSRF_LOG_MARK, "App Session pushing request [%d] onto request queue", result->thread_trace );
if(req->result == NULL)
req->result = result;
else {
void osrf_app_session_request_reset_timeout( osrf_app_session* session, int req_id ) {
if(session == NULL) return;
- osrfLogDebug("Resetting request timeout %d", req_id );
+ osrfLogDebug( OSRF_LOG_MARK, "Resetting request timeout %d", req_id );
osrf_app_request* req = osrfListGetIndex( session->request_queue, req_id );
if(req == NULL) return;
req->reset_timeout = 1;
while( remaining >= 0 ) {
/* tell the session to wait for stuff */
- osrfLogDebug( "In app_request receive with remaining time [%d]", (int) remaining );
+ osrfLogDebug( OSRF_LOG_MARK, "In app_request receive with remaining time [%d]", (int) remaining );
osrf_app_session_queue_wait( req->session, 0 );
if( req->result != NULL ) { /* if we received anything */
/* pop off the first message in the list */
- osrfLogDebug( "app_request_recv received a message, returning it");
+ osrfLogDebug( OSRF_LOG_MARK, "app_request_recv received a message, returning it");
osrf_message* ret_msg = req->result;
osrf_message* tmp_msg = ret_msg->next;
req->result = tmp_msg;
if( req->result != NULL ) { /* if we received anything */
/* pop off the first message in the list */
- osrfLogDebug( "app_request_recv received a message, returning it");
+ osrfLogDebug( OSRF_LOG_MARK, "app_request_recv received a message, returning it");
osrf_message* ret_msg = req->result;
osrf_message* tmp_msg = ret_msg->next;
req->result = tmp_msg;
if(req->reset_timeout) {
remaining = (time_t) timeout;
req->reset_timeout = 0;
- osrfLogDebug("Recevied a timeout reset");
+ osrfLogDebug( OSRF_LOG_MARK, "Recevied a timeout reset");
} else {
remaining -= (int) (time(NULL) - start);
}
}
- osrfLogDebug("Returning NULL from app_request_recv after timeout");
+ osrfLogDebug( OSRF_LOG_MARK, "Returning NULL from app_request_recv after timeout");
return NULL;
}
int _osrf_app_request_resend( osrf_app_request* req ) {
if(req == NULL) return 0;
if(!req->complete) {
- osrfLogDebug( "Resending request [%d]", req->request_id );
+ osrfLogDebug( OSRF_LOG_MARK, "Resending request [%d]", req->request_id );
return _osrf_app_session_send( req->session, req->payload );
}
return 1;
session->transport_handle = osrf_system_get_transport_client();
if( session->transport_handle == NULL ) {
- osrfLogWarning("No transport client for service 'client'");
+ osrfLogWarning( OSRF_LOG_MARK, "No transport client for service 'client'");
return NULL;
}
#ifdef ASSUME_STATELESS
session->stateless = 1;
- osrfLogDebug("%s session is stateless", remote_service );
+ osrfLogDebug( OSRF_LOG_MARK, "%s session is stateless", remote_service );
#else
session->stateless = 0;
- osrfLogDebug("%s session is NOT stateless", remote_service );
+ osrfLogDebug( OSRF_LOG_MARK, "%s session is NOT stateless", remote_service );
#endif
/* build a chunky, random session id */
sprintf(id, "%lf.%d%d", get_timestamp_millis(), (int)time(NULL), getpid());
session->session_id = strdup(id);
- osrfLogDebug( "Building a new client session with id [%s] [%s]",
+ osrfLogDebug( OSRF_LOG_MARK, "Building a new client session with id [%s] [%s]",
session->remote_service, session->session_id );
session->thread_trace = 0;
osrf_app_session* osrf_app_server_session_init(
char* session_id, char* our_app, char* remote_id ) {
- osrfLogInfo("Initing server session with session id %s, service %s,"
+ osrfLogInfo( OSRF_LOG_MARK, "Initing server session with session id %s, service %s,"
" and remote_id %s", session_id, our_app, remote_id );
osrf_app_session* session = osrf_app_session_find_session( session_id );
session->transport_handle = osrf_system_get_transport_client();
if( session->transport_handle == NULL ) {
- osrfLogWarning("No transport client for service '%s'", our_app );
+ osrfLogWarning( OSRF_LOG_MARK, "No transport client for service '%s'", our_app );
return NULL;
}
osrf_app_request* req = _osrf_app_request_init( session, req_msg );
if(_osrf_app_session_send( session, req_msg ) ) {
- osrfLogWarning( "Error sending request message [%d]", session->thread_trace );
+ osrfLogWarning( OSRF_LOG_MARK, "Error sending request message [%d]", session->thread_trace );
return -1;
}
- osrfLogDebug( "Pushing [%d] onto requeust queue for session [%s] [%s]",
+ osrfLogDebug( OSRF_LOG_MARK, "Pushing [%d] onto requeust queue for session [%s] [%s]",
req->request_id, session->remote_service, session->session_id );
osrfListSet( session->request_queue, req, req->request_id );
return req->request_id;
return;
free(session->remote_id);
- osrfLogDebug( "App Session [%s] [%s] resetting remote id to %s",
+ osrfLogDebug( OSRF_LOG_MARK, "App Session [%s] [%s] resetting remote id to %s",
session->remote_service, session->session_id, session->orig_remote_id );
session->remote_id = strdup(session->orig_remote_id);
int timeout = 5; /* XXX CONFIG VALUE */
- osrfLogDebug( "AppSession connecting to %s", session->remote_id );
+ osrfLogDebug( OSRF_LOG_MARK, "AppSession connecting to %s", session->remote_id );
/* defaulting to protocol 1 for now */
osrf_message* con_msg = osrf_message_init( CONNECT, session->thread_trace, 1 );
}
if(session->state == OSRF_SESSION_CONNECTED)
- osrfLogDebug(" * Connected Successfully to %s", session->remote_service );
+ osrfLogDebug( OSRF_LOG_MARK, " * Connected Successfully to %s", session->remote_service );
if(session->state != OSRF_SESSION_CONNECTED)
return 0;
return 1;
if(session->stateless && session->state != OSRF_SESSION_CONNECTED) {
- osrfLogDebug(
+ osrfLogDebug( OSRF_LOG_MARK,
"Exiting disconnect on stateless session %s",
session->session_id);
return 1;
}
- osrfLogDebug( "AppSession disconnecting from %s", session->remote_id );
+ osrfLogDebug(OSRF_LOG_MARK, "AppSession disconnecting from %s", session->remote_id );
osrf_message* dis_msg = osrf_message_init( DISCONNECT, session->thread_trace, 1 );
session->state = OSRF_SESSION_DISCONNECTED;
transport_message* t_msg = message_init(
string, "", session->session_id, session->remote_id, NULL );
- osrfLogDebug("Session [%s] [%s] sending to %s \nData: %s",
+ osrfLogDebug(OSRF_LOG_MARK, "Session [%s] [%s] sending to %s \nData: %s",
session->remote_service, session->session_id, t_msg->recipient, string );
retval = client_send_message( session->transport_handle, t_msg );
int osrf_app_session_queue_wait( osrf_app_session* session, int timeout ){
if(session == NULL) return 0;
int ret_val = 0;
- osrfLogDebug( "AppSession in queue_wait with timeout %d", timeout );
+ osrfLogDebug(OSRF_LOG_MARK, "AppSession in queue_wait with timeout %d", timeout );
ret_val = osrf_stack_entry_point(session->transport_handle, timeout);
return ret_val;
}
void osrf_app_session_destroy( osrf_app_session* session ){
if(session == NULL) return;
- osrfLogDebug( "AppSession [%s] [%s] destroying self and deleting requests",
+ osrfLogDebug(OSRF_LOG_MARK, "AppSession [%s] [%s] destroying self and deleting requests",
session->remote_service, session->session_id );
if(session->type == OSRF_SESSION_CLIENT
&& session->state != OSRF_SESSION_DISCONNECTED ) { /* disconnect if we're a client */
if(!__osrfAppHash) __osrfAppHash = osrfNewHash();
- osrfLogInfo("Registering application %s with file %s", appName, soFile );
+ osrfLogInfo( OSRF_LOG_MARK, "Registering application %s with file %s", appName, soFile );
osrfApplication* app = safe_malloc(sizeof(osrfApplication));
app->handle = dlopen (soFile, RTLD_NOW);
if(!app->handle) {
- osrfLogWarning("Failed to dlopen library file %s: %s", soFile, dlerror() );
+ osrfLogWarning( OSRF_LOG_MARK, "Failed to dlopen library file %s: %s", soFile, dlerror() );
dlerror(); /* clear the error */
free(app);
return -1;
*(void **) (&init) = dlsym(app->handle, "osrfAppInitialize");
if( (error = dlerror()) != NULL ) {
- osrfLogWarning("! Unable to locate method symbol [osrfAppInitialize] for app %s: %s", appName, error );
+ osrfLogWarning( OSRF_LOG_MARK, "! Unable to locate method symbol [osrfAppInitialize] for app %s: %s", appName, error );
} else {
/* run the method */
int ret;
if( (ret = (*init)()) ) {
- osrfLogWarning("Application %s returned non-zero value from "
+ osrfLogWarning( OSRF_LOG_MARK, "Application %s returned non-zero value from "
"'osrfAppInitialize', not registering...", appName );
//free(app->name); /* need a method to remove an application from the list */
//free(app);
__osrfAppRegisterSysMethods(appName);
- osrfLogInfo("Application %s registered successfully", appName );
+ osrfLogInfo( OSRF_LOG_MARK, "Application %s registered successfully", appName );
osrfLogSetAppname(appName);
osrfApplication* app = _osrfAppFindApplication(appName);
if(!app) {
- osrfLogWarning("Unable to locate application %s", appName );
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to locate application %s", appName );
return -1;
}
- osrfLogDebug("Registering method %s for app %s", methodName, appName );
+ osrfLogDebug( OSRF_LOG_MARK, "Registering method %s for app %s", methodName, appName );
osrfMethod* method = _osrfAppBuildMethod(
methodName, symbolName, notes, argc, options );
/* this is the method we're gonna run */
int (*meth) (osrfMethodContext*);
- osrfLogInfo("Running method [%s] for app [%s] with request id %d and "
+ osrfLogInfo( OSRF_LOG_MARK, "Running method [%s] for app [%s] with request id %d and "
"thread trace %s", methodName, appName, reqId, ses->session_id );
if( !(app = _osrfAppFindApplication(appName)) )
if(!(ctx && ctx->method)) return -1;
if( ctx->method->options & OSRF_METHOD_ATOMIC ) {
- osrfLogDebug(
+ osrfLogDebug( OSRF_LOG_MARK,
"Adding responses to stash for atomic method %s", ctx->method );
if( ctx->responses == NULL )
int __osrfAppPostProcess( osrfMethodContext* ctx, int retcode ) {
if(!(ctx && ctx->method)) return -1;
- osrfLogDebug( "Postprocessing method %s with retcode %d",
+ osrfLogDebug( OSRF_LOG_MARK, "Postprocessing method %s with retcode %d",
ctx->method->name, retcode );
if(ctx->responses) { /* we have cached responses to return (no responses have been sent) */
if(!ses) return -1;
if(!msg) msg = "";
VA_LIST_TO_STRING(msg);
- osrfLogWarning( "Returning method exception with message: %s", VA_BUF );
+ osrfLogWarning( OSRF_LOG_MARK, "Returning method exception with message: %s", VA_BUF );
osrfAppSessionStatus( ses, OSRF_STATUS_NOTFOUND, "osrfMethodException", request, VA_BUF );
return 0;
}
This macro verifies methods receive the correct parameters */
#define _OSRF_METHOD_VERIFY_CONTEXT(d) \
if(!d) return -1; \
- if(!d->session) { osrfLogError( "Session is NULL in app reqeust" ); return -1; }\
- if(!d->method) { osrfLogError( "Method is NULL in app reqeust" ); return -1; }\
- if(!d->params) { osrfLogError( "Params is NULL in app reqeust %s", d->method->name ); return -1; }\
+ if(!d->session) { osrfLogError( OSRF_LOG_MARK, "Session is NULL in app reqeust" ); return -1; }\
+ if(!d->method) { osrfLogError( OSRF_LOG_MARK, "Method is NULL in app reqeust" ); return -1; }\
+ if(!d->params) { osrfLogError( OSRF_LOG_MARK, "Params is NULL in app reqeust %s", d->method->name ); return -1; }\
if( d->params->type != JSON_ARRAY ) { \
- osrfLogError( "'params' is not a JSON array for method %s", d->method->name);\
+ osrfLogError( OSRF_LOG_MARK, "'params' is not a JSON array for method %s", d->method->name);\
return -1; }\
- if( !d->method->name ) { osrfLogError( "Method name is NULL"); return -1; }
+ if( !d->method->name ) { osrfLogError( OSRF_LOG_MARK, "Method name is NULL"); return -1; }
#ifdef OSRF_LOG_PARAMS
#define OSRF_METHOD_VERIFY_CONTEXT(d) \
_OSRF_METHOD_VERIFY_CONTEXT(d); \
char* __j = jsonObjectToJSON(d->params);\
if(__j) { \
- osrfLogInfo( "%s %s - %s", d->session->remote_service, d->method->name, __j);\
+ osrfLogInfo( OSRF_LOG_MARK, "%s %s - %s", d->session->remote_service, d->method->name, __j);\
free(__j); \
}
#else
#define OSRF_METHOD_VERIFY_DESCRIPTION(app, d) \
if(!app) return -1; \
if(!d) return -1;\
- if(!d->name) { osrfLogError( "No method name provided in description" ), return -1; } \
- if(!d->symbol) { osrfLogError( "No method symbol provided in description" ), return -1; } \
+ if(!d->name) { osrfLogError( OSRF_LOG_MARK, "No method name provided in description" ), return -1; } \
+ if(!d->symbol) { osrfLogError( OSRF_LOG_MARK, "No method symbol provided in description" ), return -1; } \
if(!d->notes) d->notes = ""; \
if(!d->paramNotes) d->paramNotes = "";\
if(!d->returnNotes) d->returnNotes = "";
int osrfCachePutObject( char* key, const jsonObject* obj, time_t seconds ) {
if( !(key && obj) ) return -1;
char* s = jsonObjectToJSON( obj );
- osrfLogInternal("osrfCachePut(): Putting object: %s", s);
+ osrfLogInternal( OSRF_LOG_MARK, "osrfCachePut(): Putting object: %s", s);
if( seconds < 0 ) seconds = __osrfCacheMaxSeconds;
mc_set(__osrfCache, key, strlen(key), s, strlen(s), seconds, 0);
int osrfCachePutString( char* key, const char* value, time_t seconds ) {
if( !(key && value) ) return -1;
if( seconds < 0 ) seconds = __osrfCacheMaxSeconds;
- osrfLogInternal("osrfCachePutString(): Putting string: %s", value);
+ osrfLogInternal( OSRF_LOG_MARK, "osrfCachePutString(): Putting string: %s", value);
mc_set(__osrfCache, key, strlen(key), value, strlen(value), seconds, 0);
return 0;
}
VA_LIST_TO_STRING(key);
char* data = (char*) mc_aget( __osrfCache, VA_BUF, strlen(VA_BUF) );
if( data ) {
- osrfLogInternal("osrfCacheGetObject(): Returning object: %s", data);
+ osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object: %s", data);
obj = jsonParseString( data );
return obj;
}
if( key ) {
VA_LIST_TO_STRING(key);
char* data = (char*) mc_aget(__osrfCache, VA_BUF, strlen(VA_BUF) );
- osrfLogInternal("osrfCacheGetObject(): Returning object: %s", data);
+ osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object: %s", data);
return data;
}
return NULL;
if(!msg || !o) return;
if(o->type != JSON_ARRAY) {
- osrfLogWarning("passing non-array to osrf_message_set_params(), fixing...");
+ osrfLogWarning( OSRF_LOG_MARK, "passing non-array to osrf_message_set_params(), fixing...");
jsonObject* clone = jsonObjectClone(o);
o = jsonNewObject(NULL);
jsonObjectPush(o, clone);
jsonObject* json = jsonParseString(string);
if(!json) {
- osrfLogWarning(
+ osrfLogWarning( OSRF_LOG_MARK,
"osrf_message_deserialize() unable to parse data: \n%s\n", string);
return 0;
}
int osrf_prefork_run(char* appname) {
if(!appname) {
- osrfLogError("osrf_prefork_run requires an appname to run!");
+ osrfLogError( OSRF_LOG_MARK, "osrf_prefork_run requires an appname to run!");
return -1;
}
int maxc = 10;
int minc = 3;
- osrfLogInfo("Loading config in osrf_forker for app %s", appname);
+ osrfLogInfo( OSRF_LOG_MARK, "Loading config in osrf_forker for app %s", appname);
jsonObject* max_req = osrf_settings_host_value_object("/apps/%s/unix_config/max_requests", appname);
jsonObject* min_children = osrf_settings_host_value_object("/apps/%s/unix_config/min_children", appname);
jsonObject* max_children = osrf_settings_host_value_object("/apps/%s/unix_config/max_children", appname);
- if(!max_req) osrfLogWarning("Max requests not defined, assuming 1000");
+ if(!max_req) osrfLogWarning( OSRF_LOG_MARK, "Max requests not defined, assuming 1000");
else maxr = (int) jsonObjectGetNumber(max_req);
- if(!min_children) osrfLogWarning("Min children not defined, assuming 3");
+ if(!min_children) osrfLogWarning( OSRF_LOG_MARK, "Min children not defined, assuming 3");
else minc = (int) jsonObjectGetNumber(min_children);
- if(!max_children) osrfLogWarning("Max children not defined, assuming 10");
+ if(!max_children) osrfLogWarning( OSRF_LOG_MARK, "Max children not defined, assuming 10");
else maxc = (int) jsonObjectGetNumber(max_children);
jsonObjectFree(max_req);
char* resc = va_list_to_string("%s_listener", appname);
if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc )) {
- osrfLogError("Unable to bootstrap client for osrf_prefork_run()");
+ osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()");
free(resc);
return -1;
}
forker->appname = strdup(appname);
if(forker == NULL) {
- osrfLogError("osrf_prefork_run() failed to create prefork_simple object");
+ osrfLogError( OSRF_LOG_MARK, "osrf_prefork_run() failed to create prefork_simple object");
return -1;
}
osrf_prefork_register_routers(appname);
- osrfLogInfo("Launching osrf_forker for app %s", appname);
+ osrfLogInfo( OSRF_LOG_MARK, "Launching osrf_forker for app %s", appname);
prefork_run(forker);
- osrfLogWarning("prefork_run() retuned - how??");
+ osrfLogWarning( OSRF_LOG_MARK, "prefork_run() retuned - how??");
prefork_free(forker);
return 0;
char* routerName = osrfConfigGetValue( NULL, "/router_name" );
transport_client* client = osrfSystemGetTransportClient();
- osrfLogInfo("router name is %s and we have %d routers to connect to", routerName, c );
+ osrfLogInfo( OSRF_LOG_MARK, "router name is %s and we have %d routers to connect to", routerName, c );
while( c ) {
char* domain = osrfStringArrayGetString(arr, --c);
if(domain) {
char* jid = va_list_to_string( "%s@%s/router", routerName, domain );
- osrfLogInfo("Registering with router %s", jid );
+ osrfLogInfo( OSRF_LOG_MARK, "Registering with router %s", jid );
transport_message* msg = message_init("registering", NULL, NULL, jid, NULL );
message_set_router_info( msg, NULL, NULL, appname, "register", 0 );
void prefork_child_init_hook(prefork_child* child) {
if(!child) return;
- osrfLogDebug("Child init hook for child %d", child->pid);
+ osrfLogDebug( OSRF_LOG_MARK, "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)) {
- osrfLogError("Unable to bootstrap client for osrf_prefork_run()");
+ osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()");
free(resc);
return;
}
/* keepalive loop for stateful sessions */
- osrfLogDebug("Entering keepalive loop for session %s", session->session_id );
+ osrfLogDebug( OSRF_LOG_MARK, "Entering keepalive loop for session %s", session->session_id );
}
int max_requests, int min_children, int max_children ) {
if( min_children > max_children ) {
- osrfLogError( "min_children (%d) is greater "
+ osrfLogError( OSRF_LOG_MARK, "min_children (%d) is greater "
"than max_children (%d)", min_children, max_children );
return NULL;
}
if( max_children > ABS_MAX_CHILDREN ) {
- osrfLogError( "max_children (%d) is greater than ABS_MAX_CHILDREN (%d)",
+ osrfLogError( OSRF_LOG_MARK, "max_children (%d) is greater than ABS_MAX_CHILDREN (%d)",
max_children, ABS_MAX_CHILDREN );
return NULL;
}
/* Set up the data pipes and add the child struct to the parent */
if( pipe(data_fd) < 0 ) { /* build the data pipe*/
- osrfLogError( "Pipe making error" );
+ osrfLogError( OSRF_LOG_MARK, "Pipe making error" );
return NULL;
}
if( pipe(status_fd) < 0 ) {/* build the status pipe */
- osrfLogError( "Pipe making error" );
+ osrfLogError( OSRF_LOG_MARK, "Pipe making error" );
return NULL;
}
- osrfLogInternal( "Pipes: %d %d %d %d", data_fd[0], data_fd[1], status_fd[0], status_fd[1] );
+ osrfLogInternal( OSRF_LOG_MARK, "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] );
add_prefork_child( forker, child );
if( (pid=fork()) < 0 ) {
- osrfLogError( "Forking Error" );
+ osrfLogError( OSRF_LOG_MARK, "Forking Error" );
return NULL;
}
(forker->current_num_children)++;
child->pid = pid;
- osrfLogDebug( "Parent launched %d", pid );
+ osrfLogDebug( OSRF_LOG_MARK, "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 */
- osrfLogInternal("I am new child with read_data_fd = %d and write_status_fd = %d",
+ osrfLogInternal( OSRF_LOG_MARK, "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();
while(1) {
if( forker->first_child == NULL ) {/* no more children */
- osrfLogWarning("No more children..." );
+ osrfLogWarning( OSRF_LOG_MARK, "No more children..." );
return;
}
- osrfLogDebug("Forker going into wait for data...");
+ osrfLogDebug( OSRF_LOG_MARK, "Forker going into wait for data...");
cur_msg = client_recv( forker->connection, -1 );
//fprintf(stderr, "Got Data %f\n", get_timestamp_millis() );
check_children( forker );
- osrfLogDebug( "Server received inbound data" );
+ osrfLogDebug( OSRF_LOG_MARK, "Server received inbound data" );
int k;
prefork_child* cur_child = forker->first_child;
/* Look for an available child */
for( k = 0; k < 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);
+ osrfLogInternal( OSRF_LOG_MARK, "Searching for available child. cur_child->pid = %d", cur_child->pid );
+ osrfLogInternal( OSRF_LOG_MARK, "Current num children %d and loop %d", forker->current_num_children, k);
if( cur_child->available ) {
- osrfLogDebug( "forker sending data to %d", cur_child->pid );
+ osrfLogDebug( OSRF_LOG_MARK, "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;
- osrfLogInternal( "Writing to child fd %d", cur_child->write_data_fd );
+ osrfLogInternal( OSRF_LOG_MARK, "Writing to child fd %d", cur_child->write_data_fd );
int written = 0;
//fprintf(stderr, "Writing Data %f\n", get_timestamp_millis() );
if( (written = write( cur_child->write_data_fd, data, strlen(data) + 1 )) < 0 ) {
- osrfLogWarning("Write returned error %d", errno);
+ osrfLogWarning( OSRF_LOG_MARK, "Write returned error %d", errno);
cur_child = cur_child->next;
continue;
}
/* if none available, add a new child if we can */
if( ! honored ) {
- osrfLogDebug("Not enough children, attempting to add...");
+ osrfLogDebug( OSRF_LOG_MARK, "Not enough children, attempting to add...");
if( forker->current_num_children < forker->max_children ) {
- osrfLogDebug( "Launching new child with current_num = %d",
+ osrfLogDebug( OSRF_LOG_MARK, "Launching new child with current_num = %d",
forker->current_num_children );
prefork_child* new_child = launch_child( forker );
char* data = cur_msg->msg_xml;
if( ! data || strlen(data) < 1 ) break;
new_child->available = 0;
- osrfLogDebug( "Writing to new child fd %d : pid %d",
+ osrfLogDebug( OSRF_LOG_MARK, "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;
}
if( !honored ) {
- osrfLogWarning( "No children available, sleeping and looping..." );
+ osrfLogWarning( OSRF_LOG_MARK, "No children available, sleeping and looping..." );
usleep( 50000 ); /* 50 milliseconds */
}
FD_CLR(0,&read_set);/* just to be sure */
if( (select_ret=select( max_fd + 1 , &read_set, NULL, NULL, &tv)) == -1 ) {
- osrfLogWarning( "Select returned error %d on check_children", errno );
+ osrfLogWarning( OSRF_LOG_MARK, "Select returned error %d on check_children", errno );
}
if( select_ret == 0 )
if( FD_ISSET( cur_child->read_status_fd, &read_set ) ) {
//printf( "Server received status from a child %d\n", cur_child->pid );
- osrfLogDebug( "Server received status from a child %d", cur_child->pid );
+ osrfLogDebug( OSRF_LOG_MARK, "Server received status from a child %d", cur_child->pid );
num_handled++;
char buf[64];
memset( buf, 0, 64);
if( (n=read(cur_child->read_status_fd, buf, 63)) < 0 ) {
- osrfLogWarning("Read error afer select in child status read with errno %d", errno);
+ osrfLogWarning( OSRF_LOG_MARK, "Read error afer select in child status read with errno %d", errno);
}
- osrfLogDebug( "Read %d bytes from status buffer: %s", n, buf );
+ osrfLogDebug( OSRF_LOG_MARK, "Read %d bytes from status buffer: %s", n, buf );
cur_child->available = 1;
}
cur_child = cur_child->next;
}
if( n < 0 ) {
- osrfLogWarning( "Child read returned error with errno %d", errno );
+ osrfLogWarning( OSRF_LOG_MARK, "Child read returned error with errno %d", errno );
break;
}
buffer_free(gbuf);
- osrfLogDebug("Child exiting...[%d]", getpid() );
+ osrfLogDebug( OSRF_LOG_MARK, "Child exiting...[%d]", getpid() );
exit(0);
}
if( forker->first_child == NULL ) { return; }
(forker->current_num_children)--;
- osrfLogDebug("Deleting Child: %d", pid );
+ osrfLogDebug( OSRF_LOG_MARK, "Deleting Child: %d", pid );
prefork_child* start_child = forker->first_child; /* starting point */
prefork_child* cur_child = start_child; /* current pointer */
int prefork_free( prefork_simple* prefork ) {
while( prefork->first_child != NULL ) {
- osrfLogInfo( "Killing children and sleeping 1 to reap..." );
+ osrfLogInfo( OSRF_LOG_MARK, "Killing children and sleeping 1 to reap..." );
kill( 0, SIGKILL );
sleep(1);
}
osrf_app_session_destroy( session );
if(!config) {
- osrfLogError("Unable to load config for host %s", hostname);
+ osrfLogError( OSRF_LOG_MARK, "Unable to load config for host %s", hostname);
return -1;
}
}
transport_message* msg = NULL;
while( (msg = client_recv( client, timeout )) ) {
- osrfLogDebug( "Received message from transport code from %s", msg->sender );
+ osrfLogDebug( OSRF_LOG_MARK, "Received message from transport code from %s", msg->sender );
osrf_stack_transport_handler( msg, NULL );
timeout = 0;
}
if(!msg) return NULL;
- osrfLogDebug( "Transport handler received new message \nfrom %s "
+ osrfLogDebug( OSRF_LOG_MARK, "Transport handler received new message \nfrom %s "
"to %s with body \n\n%s\n", msg->sender, msg->recipient, msg->body );
if( msg->is_error && ! msg->thread ) {
- osrfLogWarning("!! Received jabber layer error for %s ... exiting\n", msg->sender );
+ osrfLogWarning( OSRF_LOG_MARK, "!! Received jabber layer error for %s ... exiting\n", msg->sender );
message_free( msg );
return NULL;
}
if(! msg->thread && ! msg->is_error ) {
- osrfLogWarning("Received a non-error message with no thread trace... dropping");
+ osrfLogWarning( OSRF_LOG_MARK, "Received a non-error message with no thread trace... dropping");
message_free( msg );
return NULL;
}
if( !session ) return NULL;
if(!msg->is_error)
- osrfLogDebug("Session [%s] found or built", session->session_id );
+ osrfLogDebug( OSRF_LOG_MARK, "Session [%s] found or built", session->session_id );
osrf_app_session_set_remote( session, msg->sender );
osrf_message* arr[OSRF_MAX_MSGS_PER_PACKET];
memset(arr, 0, OSRF_MAX_MSGS_PER_PACKET );
int num_msgs = osrf_message_deserialize(msg->body, arr, OSRF_MAX_MSGS_PER_PACKET);
- osrfLogDebug( "We received %d messages from %s", num_msgs, msg->sender );
+ osrfLogDebug( OSRF_LOG_MARK, "We received %d messages from %s", num_msgs, msg->sender );
int i;
for( i = 0; i != num_msgs; i++ ) {
someone who no longer exists) and we're not talking to the original
remote id for this server, consider it a redirect and pass it up */
if(msg->is_error) {
- osrfLogWarning( " !!! Received Jabber layer error message" );
+ osrfLogWarning( OSRF_LOG_MARK, " !!! Received Jabber layer error message" );
if(strcmp(session->remote_id,session->orig_remote_id)) {
- osrfLogWarning( "Treating jabber error as redirect for tt [%d] "
+ osrfLogWarning( OSRF_LOG_MARK, "Treating jabber error as redirect for tt [%d] "
"and session [%s]", arr[i]->thread_trace, session->session_id );
arr[i]->m_type = STATUS;
arr[i]->status_code = OSRF_STATUS_REDIRECTED;
} else {
- osrfLogWarning(" * Jabber Error is for top level remote id [%s], no one "
+ osrfLogWarning( OSRF_LOG_MARK, " * Jabber Error is for top level remote id [%s], no one "
"to send my message too!!!", session->remote_id );
}
}
}
message_free( msg );
- osrfLogDebug("after msg delete");
+ osrfLogDebug( OSRF_LOG_MARK, "after msg delete");
return session;
}
ret_msg= _do_server( session, msg );
if(ret_msg) {
- osrfLogDebug("passing message %d / session %s to app handler",
+ osrfLogDebug( OSRF_LOG_MARK, "passing message %d / session %s to app handler",
msg->thread_trace, session->session_id );
osrf_stack_application_handler( session, ret_msg );
} else
switch( msg->status_code ) {
case OSRF_STATUS_OK:
- osrfLogDebug("We connected successfully");
+ osrfLogDebug( OSRF_LOG_MARK, "We connected successfully");
session->state = OSRF_SESSION_CONNECTED;
- osrfLogDebug( "State: %x => %s => %d", session, session->session_id, session->state );
+ osrfLogDebug( OSRF_LOG_MARK, "State: %x => %s => %d", session, session->session_id, session->state );
return NULL;
case OSRF_STATUS_COMPLETE:
new_msg = osrf_message_init( RESULT, msg->thread_trace, msg->protocol );
osrf_message_set_status_info( new_msg,
msg->status_name, msg->status_text, msg->status_code );
- osrfLogWarning("The stack doesn't know what to do with "
+ osrfLogWarning( OSRF_LOG_MARK, "The stack doesn't know what to do with "
"the provided message code: %d, name %s. Passing UP.",
msg->status_code, msg->status_name );
new_msg->is_exception = 1;
if(session == NULL || msg == NULL) return NULL;
- osrfLogDebug("Server received message of type %d", msg->m_type );
+ osrfLogDebug( OSRF_LOG_MARK, "Server received message of type %d", msg->m_type );
switch( msg->m_type ) {
case REQUEST:
- osrfLogDebug("server passing message %d to application handler "
+ osrfLogDebug( OSRF_LOG_MARK, "server passing message %d to application handler "
"for session %s", msg->thread_trace, session->session_id );
return msg;
default:
- osrfLogWarning("Server cannot handle message of type %d", msg->m_type );
+ osrfLogWarning( OSRF_LOG_MARK, "Server cannot handle message of type %d", msg->m_type );
return NULL;
}
char* servers[cacheServers->size];
for( i = 0; i != cacheServers->size; i++ ) {
servers[i] = jsonObjectGetString( jsonObjectGetIndex(cacheServers, i) );
- osrfLogInfo("Adding cache server %s", servers[i]);
+ osrfLogInfo( OSRF_LOG_MARK, "Adding cache server %s", servers[i]);
}
osrfCacheInit( servers, cacheServers->size, atoi(maxCache) );
} else {
char* servers[] = { jsonObjectGetString(cacheServers) };
- osrfLogInfo("Adding cache server %s", servers[0]);
+ osrfLogInfo( OSRF_LOG_MARK, "Adding cache server %s", servers[0]);
osrfCacheInit( servers, 1, atoi(maxCache) );
}
} else {
- osrfLogError( "Missing config value for /cache/global/servers/server _or_ "
+ osrfLogError( OSRF_LOG_MARK, "Missing config value for /cache/global/servers/server _or_ "
"/cache/global/max_cache_time");
}
/* first we grab the settings */
if(!osrfSystemBootstrapClientResc(configfile, contextNode, "settings_grabber" )) {
- osrfLogError("Unable to bootstrap");
+ osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap");
return -1;
}
char* libfile = osrf_settings_host_value("/apps/%s/implementation", appname);
if(! (appname && libfile) ) {
- osrfLogWarning("Missing appname / libfile in settings config");
+ osrfLogWarning( OSRF_LOG_MARK, "Missing appname / libfile in settings config");
continue;
}
- osrfLogInfo("Launching application %s with implementation %s", appname, libfile);
+ osrfLogInfo( OSRF_LOG_MARK, "Launching application %s with implementation %s", appname, libfile);
int pid;
if( (pid = fork()) ) {
// storage pid in local table for re-launching dead children...
- osrfLogInfo("Launched application child %d", pid);
+ osrfLogInfo( OSRF_LOG_MARK, "Launched application child %d", pid);
} else {
if( osrfAppRegisterApplication( appname, libfile ) == 0 )
osrf_prefork_run(appname);
- osrfLogDebug("Server exiting for app %s and library %s", appname, libfile );
+ osrfLogDebug( OSRF_LOG_MARK, "Server exiting for app %s and library %s", appname, libfile );
exit(0);
}
} // language == c
int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) {
if( !( config_file && contextnode ) && ! osrfConfigHasDefaultConfig() ) {
- osrfLogError("No Config File Specified\n" );
+ osrfLogError( OSRF_LOG_MARK, "No Config File Specified\n" );
return -1;
}
osrfLogSetFile( log_file );
}
- osrfLogInfo("Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath );
+ osrfLogInfo( OSRF_LOG_MARK, "Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath );
transport_client* client = client_init( domain, iport, unixpath, 0 );
int status;
while( (pid = waitpid(-1, &status, WNOHANG)) > 0) {
- osrfLogWarning("We lost child %d", pid);
+ osrfLogWarning( OSRF_LOG_MARK, "We lost child %d", pid);
}
/** relaunch the server **/
for( i = 0; i != count; i++ ) {
if(!(nodes[i] && nodes[i]->domain) ) return NULL;
osrfHashSet( grp->nodes, nodes[i], nodes[i]->domain );
- osrfLogDebug("Adding domain %s to TransportGroup", nodes[i]->domain);
+ osrfLogDebug( OSRF_LOG_MARK, "Adding domain %s to TransportGroup", nodes[i]->domain);
}
return grp;
osrfHashIteratorReset(grp->itr);
while( (node = osrfHashIteratorNext(grp->itr)) ) {
- osrfLogInfo("TransportGroup attempting to connect to domain %s",
+ osrfLogInfo( OSRF_LOG_MARK, "TransportGroup attempting to connect to domain %s",
node->connection->session->server);
if(client_connect( node->connection, node->username,
node->password, node->resource, 10, AUTH_DIGEST )) {
node->active = 1;
active++;
- osrfLogInfo("TransportGroup successfully connected to domain %s",
+ osrfLogInfo( OSRF_LOG_MARK, "TransportGroup successfully connected to domain %s",
node->connection->session->server);
} else {
- osrfLogWarning("TransportGroup unable to connect to domain %s",
+ osrfLogWarning( OSRF_LOG_MARK, "TransportGroup unable to connect to domain %s",
node->connection->session->server);
}
}
osrfHashIteratorReset(grp->itr);
while( (node = osrfHashIteratorNext(grp->itr)) ) {
- osrfLogInfo("TransportGroup disconnecting from domain %s",
+ osrfLogInfo( OSRF_LOG_MARK, "TransportGroup disconnecting from domain %s",
node->connection->session->server);
client_disconnect(node->connection);
node->active = 0;
return 0;
}
- osrfLogWarning("Error sending message to domain %s", domain );
+ osrfLogWarning( OSRF_LOG_MARK, "Error sending message to domain %s", domain );
return -1;
}
} else {
if(!strcmp(firstdomain, node->domain)) { /* we've made a full loop */
- osrfLogWarning("We've tried to send to all domains.. giving up");
+ osrfLogWarning( OSRF_LOG_MARK, "We've tried to send to all domains.. giving up");
return -1;
}
}
int main( int argc, char** argv ) {
if( argc < 5 ) {
- osrfLogError( "Usage: %s <username> <host> <resource> <recipient> \n", argv[0] );
+ osrfLogError( OSRF_LOG_MARK, "Usage: %s <username> <host> <resource> <recipient> \n", argv[0] );
return 99;
}
// try to connect, allow 15 second connect timeout
if( client_connect( client, argv[1], "jkjkasdf", argv[3], 15, AUTH_DIGEST ) )
- osrfLogInfo("Connected...\n");
+ osrfLogInfo(OSRF_LOG_MARK, "Connected...\n");
else {
- osrfLogError( "NOT Connected...\n" );
+ osrfLogError( OSRF_LOG_MARK, "NOT Connected...\n" );
return -1;
}
if( argc < 5 ) {
- osrfLogError( "Usage: %s <server> <port> <name> <secret>", argv[0] );
+ osrfLogError(OSRF_LOG_MARK, "Usage: %s <server> <port> <name> <secret>", argv[0] );
return -1;
}
// try to connect, allow 15 second connect timeout
if( client_connect( client, argv[3], argv[4], "", 15, 1 ) )
- osrfLogInfo("Connected...\n");
+ osrfLogInfo(OSRF_LOG_MARK, "Connected...\n");
else {
- osrfLogError( "NOT Connected...\n" );
+ osrfLogError(OSRF_LOG_MARK, "NOT Connected...\n" );
return -1;
}
if(client->session == NULL) {
- osrfLogError( "client_init(): Out of Memory");
+ osrfLogError(OSRF_LOG_MARK, "client_init(): Out of Memory");
return NULL;
}
client->session->message_callback = client_message_handler;
// if( ! session_wait( client->session, -1 ) ) {
int x;
if( (x = session_wait( client->session, -1 )) ) {
- osrfLogWarning("session_wait returned failure code %d\n", x);
+ osrfLogWarning(OSRF_LOG_MARK, "session_wait returned failure code %d\n", x);
return NULL;
}
}
msg->subject == NULL || msg->recipient == NULL ||
msg->sender == NULL ) {
- osrfLogError( "message_init(): Out of Memory" );
+ osrfLogError(OSRF_LOG_MARK, "message_init(): Out of Memory" );
return NULL;
}
encoded_body = strdup( (char*) xmlbuf );
if( encoded_body == NULL )
- osrfLogError("message_to_xml(): Out of Memory");
+ osrfLogError(OSRF_LOG_MARK, "message_to_xml(): Out of Memory");
xmlFree(xmlbuf);
xmlFreeDoc(msg_doc);
if( msg->router_from == NULL || msg->router_to == NULL ||
msg->router_class == NULL || msg->router_command == NULL )
- osrfLogError( "message_set_router_info(): Out of Memory" );
+ osrfLogError(OSRF_LOG_MARK, "message_set_router_info(): Out of Memory" );
return;
}
xmlKeepBlanksDefault(0);
if( ! msg ) {
- osrfLogWarning( "Passing NULL message to message_to_xml()");
+ osrfLogWarning(OSRF_LOG_MARK, "Passing NULL message to message_to_xml()");
return 0;
}
encoded_body = strdup( (char*) xmlbuf );
if( encoded_body == NULL ) {
- osrfLogError("message_to_xml(): Out of Memory");
+ osrfLogError(OSRF_LOG_MARK, "message_to_xml(): Out of Memory");
return NULL;
}
session->router_class_buffer == NULL || session->router_command_buffer == NULL ||
session->session_id == NULL ) {
- osrfLogError( "init_transport(): buffer_init returned NULL" );
+ osrfLogError(OSRF_LOG_MARK, "init_transport(): buffer_init returned NULL" );
return 0;
}
if( ! session ) { return -1; }
if( ! session->state_machine->connected ) {
- osrfLogWarning("State machine is not connected in send_msg()");
+ osrfLogWarning(OSRF_LOG_MARK, "State machine is not connected in send_msg()");
return -1;
}
int size2 = 0;
if( ! session ) {
- osrfLogWarning( "session is null in connect" );
+ osrfLogWarning(OSRF_LOG_MARK, "session is null in connect" );
return 0;
}
// if( ! tcp_send( session->sock_obj, stanza1 ) ) {
if( socket_send( session->sock_id, stanza1 ) ) {
- osrfLogWarning("error sending");
+ osrfLogWarning(OSRF_LOG_MARK, "error sending");
return 0;
}
//if( ! tcp_send( session->sock_obj, stanza2 ) ) {
if( socket_send( session->sock_id, stanza2 ) ) {
- osrfLogWarning("error sending");
+ osrfLogWarning(OSRF_LOG_MARK, "error sending");
return 0;
}
}
session->state_machine->connecting = CONNECTING_1;
//if( ! tcp_send( session->sock_obj, stanza1 ) ) {
if( socket_send( session->sock_id, stanza1 ) ) {
- osrfLogWarning("error sending");
+ osrfLogWarning(OSRF_LOG_MARK, "error sending");
return 0;
}
if( session->state_machine->connecting == CONNECTING_2 ) {
//if( ! tcp_send( session->sock_obj, stanza2 ) ) {
if( socket_send( session->sock_id, stanza2 ) ) {
- osrfLogWarning("error sending");
+ osrfLogWarning(OSRF_LOG_MARK, "error sending");
return 0;
}
}
if( session->state_machine->connecting == CONNECTING_2 ) {
//if( ! tcp_send( session->sock_obj, stanza2 ) ) {
if( socket_send( session->sock_id, stanza2 ) ) {
- osrfLogWarning("error sending");
+ osrfLogWarning(OSRF_LOG_MARK, "error sending");
return 0;
}
}
if( strcmp( name, "stream:error" ) == 0 ) {
ses->state_machine->in_error = 1;
- osrfLogWarning( "Received <stream:error> message from Jabber server" );
+ osrfLogWarning( OSRF_LOG_MARK, "Received <stream:error> message from Jabber server" );
return;
}
ses->state_machine->in_message_error = 1;
buffer_add( ses->message_error_type, get_xml_attr( atts, "type" ) );
ses->message_error_code = atoi( get_xml_attr( atts, "code" ) );
- osrfLogInfo( "Received <error> message with type %s and code %s",
+ osrfLogInfo( OSRF_LOG_MARK, "Received <error> message with type %s and code %s",
get_xml_attr( atts, "type"), get_xml_attr( atts, "code") );
return;
}
}
if( strcmp( get_xml_attr(atts, "type"), "error") == 0 ) {
- osrfLogWarning( "Error connecting to jabber" );
+ osrfLogWarning( OSRF_LOG_MARK, "Error connecting to jabber" );
return;
}
}
if( strcmp( name, "iq" ) == 0 ) {
ses->state_machine->in_iq = 0;
if( ses->message_error_code > 0 ) {
- osrfLogWarning( "Error in IQ packet: code %d", ses->message_error_code );
- osrfLogWarning( "Error 401 means not authorized" );
+ osrfLogWarning( OSRF_LOG_MARK, "Error in IQ packet: code %d", ses->message_error_code );
+ osrfLogWarning( OSRF_LOG_MARK, "Error 401 means not authorized" );
}
reset_session_buffers( session );
return;
if( ses->state_machine->in_error ) {
/* for now... */
- osrfLogWarning( "ERROR Xml fragment: %s\n", ch );
+ osrfLogWarning( OSRF_LOG_MARK, "ERROR Xml fragment: %s\n", ch );
}
}
int numhandled = 0;
if( (selectret = select(maxfd + 1, &set, NULL, NULL, NULL)) < 0 ) {
- osrfLogWarning("Top level select call failed with errno %d", errno);
+ osrfLogWarning( OSRF_LOG_MARK, "Top level select call failed with errno %d", errno);
continue;
}
/* see if there is a top level router message */
if( FD_ISSET(routerfd, &set) ) {
- osrfLogDebug("Top router socket is active: %d", routerfd );
+ osrfLogDebug( OSRF_LOG_MARK, "Top router socket is active: %d", routerfd );
numhandled++;
osrfRouterHandleIncoming( router );
}
if( classname && (class = osrfRouterFindClass( router, classname )) ) {
- osrfLogDebug("Checking %s for activity...", classname );
+ osrfLogDebug( OSRF_LOG_MARK, "Checking %s for activity...", classname );
int sockfd = class->ROUTER_SOCKFD;
if(FD_ISSET( sockfd, &set )) {
- osrfLogDebug("Socket is active: %d", sockfd );
+ osrfLogDebug( OSRF_LOG_MARK, "Socket is active: %d", sockfd );
numhandled++;
osrfRouterClassHandleIncoming( router, classname, class );
}
if(osrfStringArrayContains( router->trustedServers, domain))
osrfRouterHandleMessage( router, msg );
else
- osrfLogWarning("Received message from un-trusted server domain %s", msg->sender);
+ osrfLogWarning( OSRF_LOG_MARK, "Received message from un-trusted server domain %s", msg->sender);
}
message_free(msg);
if(!(router && class)) return -1;
transport_message* msg;
- osrfLogDebug("osrfRouterClassHandleIncoming()");
+ osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleIncoming()");
if( (msg = client_recv( class->connection, 0 )) ) {
osrfRouterClassHandleMessage( router, class, msg );
} else {
- osrfLogWarning("Received client message from untrusted client domain %s", domain );
+ osrfLogWarning( OSRF_LOG_MARK, "Received client message from untrusted client domain %s", domain );
}
}
if(!strcmp(msg->router_command, ROUTER_REGISTER)) {
class = osrfRouterFindClass( router, msg->router_class );
- osrfLogInfo("Registering class %s", msg->router_class );
+ osrfLogInfo( OSRF_LOG_MARK, "Registering class %s", msg->router_class );
if(!class) class = osrfRouterAddClass( router, msg->router_class );
} else if( !strcmp( msg->router_command, ROUTER_UNREGISTER ) ) {
if( msg->router_class && strcmp( msg->router_class, "") ) {
- osrfLogInfo("Unregistering router class %s", msg->router_class );
+ osrfLogInfo( OSRF_LOG_MARK, "Unregistering router class %s", msg->router_class );
osrfRouterClassRemoveNode( router, msg->router_class, msg->sender );
}
}
int osrfRouterClassAddNode( osrfRouterClass* rclass, char* remoteId ) {
if(!(rclass && rclass->nodes && remoteId)) return -1;
- osrfLogInfo("Adding router node for remote id %s", remoteId );
+ osrfLogInfo( OSRF_LOG_MARK, "Adding router node for remote id %s", remoteId );
osrfRouterNode* node = safe_malloc(sizeof(osrfRouterNode));
node->count = 0;
transport_message* osrfRouterClassHandleBounce(
osrfRouter* router, char* classname, osrfRouterClass* rclass, transport_message* msg ) {
- osrfLogDebug("osrfRouterClassHandleBounce()");
+ osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleBounce()");
- osrfLogInfo("Received network layer error message from %s", msg->sender );
+ osrfLogInfo( OSRF_LOG_MARK, "Received network layer error message from %s", msg->sender );
osrfRouterNode* node = osrfRouterClassFindNode( rclass, msg->sender );
transport_message* lastSent = NULL;
if( node && osrfHashGetCount(rclass->nodes) == 1 ) { /* the last node is dead */
if( node->lastMessage ) {
- osrfLogWarning("We lost the last node in the class, responding with error and removing...");
+ osrfLogWarning( OSRF_LOG_MARK, "We lost the last node in the class, responding with error and removing...");
transport_message* error = message_init(
node->lastMessage->body, node->lastMessage->subject,
} else {
if( node->lastMessage ) {
- osrfLogDebug("Cloning lastMessage so next node can send it");
+ osrfLogDebug( OSRF_LOG_MARK, "Cloning lastMessage so next node can send it");
lastSent = message_init( node->lastMessage->body,
node->lastMessage->subject, node->lastMessage->thread, "", node->lastMessage->router_from );
message_set_router_info( lastSent, node->lastMessage->router_from, NULL, NULL, NULL, 0 );
osrfRouter* router, osrfRouterClass* rclass, transport_message* msg ) {
if(!(router && rclass && msg)) return -1;
- osrfLogDebug("osrfRouterClassHandleMessage()");
+ osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleMessage()");
osrfRouterNode* node = osrfHashIteratorNext( rclass->itr );
if(!node) {
msg->subject, msg->thread, node->remoteId, msg->sender );
message_set_router_info( new_msg, msg->sender, NULL, NULL, NULL, 0 );
- osrfLogInfo( "Routing message:\nfrom: [%s]\nto: [%s]",
+ osrfLogInfo( OSRF_LOG_MARK, "Routing message:\nfrom: [%s]\nto: [%s]",
new_msg->router_from, new_msg->recipient );
message_free( node->lastMessage );
else {
message_prepare_xml(new_msg);
- osrfLogWarning("Error sending message from %s to %s\n%s",
+ osrfLogWarning( OSRF_LOG_MARK, "Error sending message from %s to %s\n%s",
new_msg->sender, new_msg->recipient, new_msg->msg_xml );
}
int osrfRouterRemoveClass( osrfRouter* router, char* classname ) {
if(!(router && router->classes && classname)) return -1;
- osrfLogInfo("Removing router class %s", classname );
+ osrfLogInfo( OSRF_LOG_MARK, "Removing router class %s", classname );
osrfHashRemove( router->classes, classname );
return 0;
}
if(!(router && router->classes && classname && remoteId)) return 0;
- osrfLogInfo("Removing router node %s", remoteId );
+ osrfLogInfo( OSRF_LOG_MARK, "Removing router node %s", remoteId );
osrfRouterClass* class = osrfRouterFindClass( router, classname );
osrfMessage* success = osrf_message_init( STATUS, omsg->thread_trace, omsg->protocol );
- osrfLogDebug("router recevied a CONNECT message from %s", msg->sender );
+ osrfLogDebug( OSRF_LOG_MARK, "router recevied a CONNECT message from %s", msg->sender );
osrf_message_set_status_info(
success, "osrfConnectStatus", "Connection Successful", OSRF_STATUS_OK );
if(!(router && msg && omsg && omsg->method_name)) return -1;
- osrfLogInfo("Router received app request: %s", omsg->method_name );
+ osrfLogInfo( OSRF_LOG_MARK, "Router received app request: %s", omsg->method_name );
jsonObject* jresponse = NULL;
if(!strcmp( omsg->method_name, ROUTER_REQUEST_CLASS_LIST )) {
osrf_message_set_result_content( oresponse, json);
char* data = osrf_message_serialize(oresponse);
- osrfLogDebug( "Responding to client app request with data: \n%s\n", data );
+ osrfLogDebug( OSRF_LOG_MARK, "Responding to client app request with data: \n%s\n", data );
transport_message* tresponse = message_init(
data, "", msg->thread, msg->sender, msg->recipient );
osrfRouter* __osrfRouter = NULL;
void routerSignalHandler( int signal ) {
- osrfLogWarning("Received signal [%d], cleaning up...", signal );
+ osrfLogWarning( OSRF_LOG_MARK, "Received signal [%d], cleaning up...", signal );
osrfConfigCleanup();
osrfRouterFree(__osrfRouter);
}
int main( int argc, char* argv[] ) {
if( argc < 3 ) {
- osrfLogError( "Usage: %s <path_to_config_file> <config_context>", argv[0] );
+ osrfLogError( OSRF_LOG_MARK, "Usage: %s <path_to_config_file> <config_context>", argv[0] );
exit(0);
}
free(level);
free(log_file);
- osrfLogInfo( "Router connecting as: server: %s port: %s "
+ osrfLogInfo( OSRF_LOG_MARK, "Router connecting as: server: %s port: %s "
"user: %s resource: %s", server, port, username, resource );
int iport = 0;
int i;
for( i = 0; i != tservers->size; i++ )
- osrfLogInfo( "Router adding trusted server: %s", osrfStringArrayGetString( tservers, i ) );
+ osrfLogInfo( OSRF_LOG_MARK, "Router adding trusted server: %s", osrfStringArrayGetString( tservers, i ) );
for( i = 0; i != tclients->size; i++ )
- osrfLogInfo( "Router adding trusted client: %s", osrfStringArrayGetString( tclients, i ) );
+ osrfLogInfo( OSRF_LOG_MARK, "Router adding trusted client: %s", osrfStringArrayGetString( tclients, i ) );
if( tclients->size == 0 || tservers->size == 0 ) {
- osrfLogError("We need trusted servers and trusted client to run the router...");
+ osrfLogError( OSRF_LOG_MARK, "We need trusted servers and trusted client to run the router...");
return -1;
}
memset(fbuf, 0, l);
sprintf(fbuf,"%s/.srfsh.xml",home);
- //osrfLogInit( OSRF_LOG_TYPE_SYSLOG, "srfsh",
-
if(!access(fbuf, R_OK)) {
if( ! osrf_system_bootstrap_client(fbuf, "srfsh") ) {
fprintf(stderr,"Unable to bootstrap client for requests\n");
- osrfLogError( "Unable to bootstrap client for requests");
+ osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for requests");
return -1;
}
/* for now.. the first arg is used as a script file for processing */
int f;
if( (f = open(argv[1], O_RDONLY)) == -1 ) {
- osrfLogError("Unable to open file %s for reading, exiting...", argv[1]);
+ osrfLogError( OSRF_LOG_MARK, "Unable to open file %s for reading, exiting...", argv[1]);
return -1;
}
if(dup2(f, STDIN_FILENO) == -1) {
- osrfLogError("Unable to duplicate STDIN, exiting...");
+ osrfLogError( OSRF_LOG_MARK, "Unable to duplicate STDIN, exiting...");
return -1;
}
osrf_app_session* session = osrf_app_client_session_init(server);
if(!osrf_app_session_connect(session)) {
- osrfLogWarning( "Unable to connect to remote service %s\n", server );
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to connect to remote service %s\n", server );
return 1;
}
__osrfLogLevel = loglevel;
}
-void osrfLogError( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_ERROR); }
-void osrfLogWarning( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_WARNING); }
-void osrfLogInfo( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_INFO); }
-void osrfLogDebug( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_DEBUG); }
-void osrfLogInternal( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_INTERNAL); }
-void osrfLogActivity( const char* msg, ... ) {
- OSRF_LOG_GO(msg, OSRF_LOG_ACTIVITY);
- /* activity log entries are also logged as info intries */
- osrfLogDetail( OSRF_LOG_INFO, NULL, -1, NULL, VA_BUF );
+void osrfLogError( const char* file, int line, const char* msg, ... )
+ { OSRF_LOG_GO(file, line, msg, OSRF_LOG_ERROR); }
+void osrfLogWarning( const char* file, int line, const char* msg, ... )
+ { OSRF_LOG_GO(file, line, msg, OSRF_LOG_WARNING); }
+void osrfLogInfo( const char* file, int line, const char* msg, ... )
+ { OSRF_LOG_GO(file, line, msg, OSRF_LOG_INFO); }
+void osrfLogDebug( const char* file, int line, const char* msg, ... )
+ { OSRF_LOG_GO(file, line, msg, OSRF_LOG_DEBUG); }
+void osrfLogInternal( const char* file, int line, const char* msg, ... )
+ { OSRF_LOG_GO(file, line, msg, OSRF_LOG_INTERNAL); }
+void osrfLogActivity( const char* file, int line, const char* msg, ... ) {
+ OSRF_LOG_GO(file, line, msg, OSRF_LOG_ACTIVITY);
+ _osrfLogDetail( OSRF_LOG_INFO, file, line, VA_BUF ); /* also log at info level */
}
-void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... ) {
- if(!msg) return;
- VA_LIST_TO_STRING(msg);
- _osrfLogDetail( level, filename, line, func, VA_BUF );
-}
-
-void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg ) {
+void _osrfLogDetail( int level, const char* filename, int line, char* msg ) {
if( level == OSRF_LOG_ACTIVITY && ! __osrfLogActivityEnabled ) return;
if( level > __osrfLogLevel ) return;
if(!msg) return;
if(!filename) filename = "";
- if(!func) func = "";
-
- char lb[12];
- bzero(lb,12);
- if(line >= 0) snprintf(lb,12,"%d", line);
char* l = "INFO"; /* level name */
int lvl = LOG_INFO; /* syslog level */
}
if(__osrfLogType == OSRF_LOG_TYPE_SYSLOG )
- syslog( fac | lvl, "[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg );
+ syslog( fac | lvl, "[%s:%d:%s:%d] %s", l, getpid(), filename, line, msg );
else if( __osrfLogType == OSRF_LOG_TYPE_FILE )
- _osrfLogToFile("[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg );
+ _osrfLogToFile("[%s:%d:%s:%d] %s", l, getpid(), filename, line, msg );
}
bzero(datebuf,36);
time_t t = time(NULL);
struct tm* tms = localtime(&t);
- strftime(datebuf, 36, "%Y-%m-%d %h:%m:%s", tms);
+ strftime(datebuf, 36, "%Y-%m-%d %H:%M:%S", tms);
FILE* file = fopen(__osrfLogFile, "a");
if(!file) {
fprintf(file, "%s %s %s\n", __osrfLogAppname, datebuf, VA_BUF );
if( fclose(file) != 0 )
- osrfLogWarning("Error closing log file: %s", strerror(errno));
+ osrfLogWarning(OSRF_LOG_MARK, "Error closing log file: %s", strerror(errno));
}
#define OSRF_LOG_TYPE_FILE 1
#define OSRF_LOG_TYPE_SYSLOG 2
+#define OSRF_LOG_MARK __FILE__, __LINE__
-#define OSRF_LOG_GO(m,l) \
+
+#define OSRF_LOG_GO(f,li,m,l) \
if(!m) return; \
VA_LIST_TO_STRING(m); \
- _osrfLogDetail( l, NULL, -1, NULL, VA_BUF );
+ _osrfLogDetail( l, f, li, VA_BUF );
* than "level" will not be logged */
void osrfLogSetLevel( int loglevel );
/* Log an error message */
-void osrfLogError( const char* msg, ... );
+void osrfLogError( const char* file, int line, const char* msg, ... );
/* Log a warning message */
-void osrfLogWarning( const char* msg, ... );
+void osrfLogWarning( const char* file, int line, const char* msg, ... );
/* log an info message */
-void osrfLogInfo( const char* msg, ... );
+void osrfLogInfo( const char* file, int line, const char* msg, ... );
/* Log a debug message */
-void osrfLogDebug( const char* msg, ... );
+void osrfLogDebug( const char* file, int line, const char* msg, ... );
/* Log an internal debug message */
-void osrfLogInternal( const char* msg, ... );
+void osrfLogInternal( const char* file, int line, const char* msg, ... );
/* Log an activity message */
-void osrfLogActivity( const char* msg, ... );
+void osrfLogActivity( const char* file, int line, const char* msg, ... );
+/* sets the activity flag */
void osrfLogSetActivityEnabled( int enabled );
-/* Use this for logging detailed message containing the filename, line number
- * and function name in addition to the usual level and message */
-void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... );
-
/** Actually does the logging */
-void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg );
+void _osrfLogDetail( int level, const char* filename, int line, char* msg );
void _osrfLogToFile( char* msg, ... );
/* -------------------------------------------------------------------- */
-/*
-int osrfLogDebug(char* msg, ...) {
- va_list args;
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
- fprintf( stderr, "\n" );
- return -1;
-}
-
-int osrfLogWarning(char* msg, ...) {
- va_list args;
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
- fprintf( stderr, "\n" );
- return -1;
-}
-*/
-
socket_node* _socket_add_node(socket_manager* mgr,
int endpoint, int addr_type, int sock_fd, int parent_id ) {
if(mgr == NULL) return NULL;
- osrfLogInternal("Adding socket node with fd %d", sock_fd);
+ osrfLogInternal( OSRF_LOG_MARK, "Adding socket node with fd %d", sock_fd);
socket_node* new_node = safe_malloc(sizeof(socket_node));
new_node->endpoint = endpoint;
int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) {
if( mgr == NULL ) {
- osrfLogWarning("socket_open_tcp_server(): NULL mgr");
+ osrfLogWarning( OSRF_LOG_MARK, "socket_open_tcp_server(): NULL mgr");
return -1;
}
sock_fd = socket(AF_INET, SOCK_STREAM, 0);
if(sock_fd < 0) {
- osrfLogWarning("tcp_server_connect(): Unable to create socket");
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): Unable to create socket");
return -1;
}
server_addr.sin_port = htons(port);
if(bind( sock_fd, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0) {
- osrfLogWarning("tcp_server_connect(): cannot bind to port %d", port );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): cannot bind to port %d", port );
return -1;
}
if(listen(sock_fd, 20) == -1) {
- osrfLogWarning("tcp_server_connect(): listen() returned error");
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): listen() returned error");
return -1;
}
int socket_open_unix_server(socket_manager* mgr, char* path) {
if(mgr == NULL || path == NULL) return -1;
- osrfLogDebug("opening unix socket at %s", path);
+ osrfLogDebug( OSRF_LOG_MARK, "opening unix socket at %s", path);
int sock_fd;
struct sockaddr_un server_addr;
sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(sock_fd < 0){
- osrfLogWarning("socket_open_unix_server(): socket() failed");
+ osrfLogWarning( OSRF_LOG_MARK, "socket_open_unix_server(): socket() failed");
return -1;
}
if( bind(sock_fd, (struct sockaddr*) &server_addr,
sizeof(struct sockaddr_un)) < 0) {
- osrfLogWarning(
+ osrfLogWarning( OSRF_LOG_MARK,
"socket_open_unix_server(): cannot bind to unix port %s", path );
return -1;
}
if(listen(sock_fd, 20) == -1) {
- osrfLogWarning("socket_open_unix_server(): listen() returned error");
+ osrfLogWarning( OSRF_LOG_MARK, "socket_open_unix_server(): listen() returned error");
return -1;
}
- osrfLogDebug("unix socket successfully opened");
+ osrfLogDebug( OSRF_LOG_MARK, "unix socket successfully opened");
int i = 1;
/* causing problems with router for some reason ... */
- //osrfLogDebug("Setting SO_REUSEADDR");
+ //osrfLogDebug( OSRF_LOG_MARK, "Setting SO_REUSEADDR");
//setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
- //osrfLogDebug("Setting TCP_NODELAY");
+ //osrfLogDebug( OSRF_LOG_MARK, "Setting TCP_NODELAY");
setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i));
_socket_add_node(mgr, SERVER_SOCKET, UNIX, sock_fd, 0);
struct sockaddr_in server_addr;
if( (sockfd = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
- osrfLogWarning("Unable to create UDP socket");
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to create UDP socket");
return -1;
}
else server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if( (bind (sockfd, (struct sockaddr *) &server_addr,sizeof(server_addr))) ) {
- osrfLogWarning("Unable to bind to UDP port %d", port);
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to bind to UDP port %d", port);
return -1;
}
// Create the socket
// ------------------------------------------------------------------
if( (sock_fd = socket( AF_INET, SOCK_STREAM, 0 )) < 0 ) {
- osrfLogWarning( "tcp_connect(): Cannot create socket" );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot create socket" );
return -1;
}
int i = 1;
- //osrfLogDebug("Setting TCP_NODELAY");
+ //osrfLogDebug( OSRF_LOG_MARK, "Setting TCP_NODELAY");
setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i));
// Get the hostname
// ------------------------------------------------------------------
if( (hptr = gethostbyname( dest_addr ) ) == NULL ) {
- osrfLogWarning( "tcp_connect(): Unknown Host => %s", dest_addr );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Unknown Host => %s", dest_addr );
return -1;
}
// Bind to a local port
// ------------------------------------------------------------------
if( bind( sock_fd, (struct sockaddr *) &localAddr, sizeof( localAddr ) ) < 0 ) {
- osrfLogWarning( "tcp_connect(): Cannot bind to local port" );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot bind to local port" );
return -1;
}
// Connect to server
// ------------------------------------------------------------------
if( connect( sock_fd, (struct sockaddr*) &remoteAddr, sizeof( struct sockaddr_in ) ) < 0 ) {
- osrfLogWarning( "tcp_connect(): Cannot connect to server %s", dest_addr );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot connect to server %s", dest_addr );
return -1;
}
struct hostent* host;
if( (host = gethostbyname(dest_addr)) == NULL) {
- osrfLogWarning("Unable to resolve host: %s", dest_addr);
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to resolve host: %s", dest_addr);
return -1;
}
server_addr.sin_port = htons(port);
if( (sockfd = socket(AF_INET,SOCK_DGRAM,0)) < 0 ) {
- osrfLogWarning("Unable to create UDP socket");
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to create UDP socket");
return -1;
}
client_addr.sin_port = htons(0);
if( (bind(sockfd, (struct sockaddr *) &client_addr, sizeof(client_addr))) < 0 ) {
- osrfLogWarning("Unable to bind UDP socket");
+ osrfLogWarning( OSRF_LOG_MARK, "Unable to bind UDP socket");
return -1;
}
struct sockaddr_un usock;
if( (sock_fd = socket( AF_UNIX, SOCK_STREAM, 0 )) < 0 ) {
- osrfLogWarning( "Cannot create socket" );
+ osrfLogWarning( OSRF_LOG_MARK, "Cannot create socket" );
return -1;
}
len = sizeof( usock.sun_family ) + strlen( usock.sun_path );
if( connect( sock_fd, (struct sockaddr *) &usock, len ) < 0 ) {
- osrfLogWarning( "Error connecting to unix socket" );
+ osrfLogWarning( OSRF_LOG_MARK, "Error connecting to unix socket" );
return -1;
}
if(mgr == NULL) return;
- osrfLogDebug("removing socket %d", sock_fd);
+ osrfLogDebug( OSRF_LOG_MARK, "removing socket %d", sock_fd);
socket_node* head = mgr->socket;
socket_node* tail = head;
void _socket_print_list(socket_manager* mgr) {
if(mgr == NULL) return;
socket_node* node = mgr->socket;
- osrfLogDebug("socket_node list: [");
+ osrfLogDebug( OSRF_LOG_MARK, "socket_node list: [");
while(node) {
- osrfLogDebug("sock_fd: %d | parent_id: %d",
+ osrfLogDebug( OSRF_LOG_MARK, "sock_fd: %d | parent_id: %d",
node->sock_fd, node->parent_id);
node = node->next;
}
- osrfLogDebug("]");
+ osrfLogDebug( OSRF_LOG_MARK, "]");
}
/* sends the given data to the given socket */
int socket_send(int sock_fd, const char* data) {
- osrfLogInternal( "socket_bundle sending to %d data %s",
+ osrfLogInternal( OSRF_LOG_MARK, "socket_bundle sending to %d data %s",
sock_fd, data);
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" );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_server_send(): Error sending data" );
return -1;
}
it from the socket set */
void socket_disconnect(socket_manager* mgr, int sock_fd) {
- osrfLogDebug("Closing socket %d", sock_fd);
+ osrfLogDebug( OSRF_LOG_MARK, "Closing socket %d", sock_fd);
if( close( sock_fd ) == -1 )
- osrfLogWarning( "socket_disconnect(): Error closing socket, removing anyway" );
+ osrfLogWarning( OSRF_LOG_MARK, "socket_disconnect(): Error closing socket, removing anyway" );
if(mgr != NULL)
socket_remove_node(mgr, sock_fd);
// If timeout is -1, we block indefinitely
if( (retval = select( sock_fd + 1, &read_set, NULL, NULL, NULL)) == -1 ) {
- osrfLogWarning("Sys Error: %s", strerror(errno));
- osrfLogWarning("Call to select interrupted");
+ osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno));
+ osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted");
return -1;
}
} else if( timeout > 0 ) { /* timeout of 0 means don't block */
if( (retval = select( sock_fd + 1, &read_set, NULL, NULL, &tv)) == -1 ) {
- osrfLogWarning("Sys Error: %s", strerror(errno));
- osrfLogWarning( "Call to select interrupted" );
+ osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno));
+ osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted" );
return -1;
}
}
- osrfLogInternal("%d active sockets after select()", retval);
+ osrfLogInternal( OSRF_LOG_MARK, "%d active sockets after select()", retval);
return _socket_route_data_id(mgr, sock_fd);
}
int socket_wait_all(socket_manager* mgr, int timeout) {
if(mgr == NULL) {
- osrfLogWarning( "tcp_wait(): null mgr" );
+ osrfLogWarning( OSRF_LOG_MARK, "tcp_wait(): null mgr" );
return -1;
}
socket_node* node = mgr->socket;
int max_fd = 0;
while(node) {
- osrfLogInternal("Adding socket fd %d to select set",node->sock_fd);
+ osrfLogInternal( OSRF_LOG_MARK, "Adding socket fd %d to select set",node->sock_fd);
FD_SET( node->sock_fd, &read_set );
if(node->sock_fd > max_fd) max_fd = node->sock_fd;
node = node->next;
// If timeout is -1, there is no timeout passed to the call to select
if( (retval = select( max_fd, &read_set, NULL, NULL, NULL)) == -1 ) {
- osrfLogWarning("Call to select interrupted (returned -1)");
- osrfLogWarning("Sys Error: %s", strerror(errno));
+ osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted (returned -1)");
+ osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno));
return -1;
}
} else if( timeout != 0 ) { /* timeout of 0 means don't block */
if( (retval = select( max_fd, &read_set, NULL, NULL, &tv)) == -1 ) {
- osrfLogWarning( "Call to select interrupted (returned -1)" );
- osrfLogWarning("Sys Error: %s", strerror(errno));
+ osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted (returned -1)" );
+ osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno));
return -1;
}
}
- osrfLogDebug("%d active sockets after select()", retval);
+ osrfLogDebug( OSRF_LOG_MARK, "%d active sockets after select()", retval);
return _socket_route_data(mgr, retval, &read_set);
}
if(last_failed_id != -1) {
/* in case it was not removed by our overlords */
- osrfLogInternal("Attempting to remove last_failed_id of %d", last_failed_id);
+ osrfLogInternal( OSRF_LOG_MARK, "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 ) ) {
- osrfLogInternal("Socket %d active", sock_fd);
+ osrfLogInternal( OSRF_LOG_MARK, "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;
- osrfLogInternal("Backtracking back to start of loop because "
+ osrfLogInternal( OSRF_LOG_MARK, "Backtracking back to start of loop because "
"of -1 return code from _socket_handle_client_data()");
}
}
int new_sock_fd;
new_sock_fd = accept(node->sock_fd, NULL, NULL);
if(new_sock_fd < 0) {
- osrfLogWarning("_socket_route_data(): accept() failed");
+ osrfLogWarning( OSRF_LOG_MARK, "_socket_route_data(): accept() failed");
return -1;
}
if(node->addr_type == INET) {
_socket_add_node(mgr, CLIENT_SOCKET, INET, new_sock_fd, node->sock_fd);
- osrfLogDebug("Adding new INET client for %d", node->sock_fd);
+ osrfLogDebug( OSRF_LOG_MARK, "Adding new INET client for %d", node->sock_fd);
} else if(node->addr_type == UNIX) {
_socket_add_node(mgr, CLIENT_SOCKET, UNIX, new_sock_fd, node->sock_fd);
- osrfLogDebug("Adding new UNIX client for %d", node->sock_fd);
+ osrfLogDebug( OSRF_LOG_MARK, "Adding new UNIX client for %d", node->sock_fd);
}
return 0;
memset(buf, 0, RBUFSIZE);
set_fl(sock_fd, O_NONBLOCK);
- osrfLogInternal("%d : Received data at %lf\n", getpid(), get_timestamp_millis());
+ osrfLogInternal( OSRF_LOG_MARK, "%d : Received data at %lf\n", getpid(), get_timestamp_millis());
while( (read_bytes = recv(sock_fd, buf, RBUFSIZE-1, 0) ) > 0 ) {
- osrfLogInternal("Socket %d Read %d bytes and data: %s", sock_fd, read_bytes, buf);
+ osrfLogInternal( OSRF_LOG_MARK, "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);
clr_fl(sock_fd, O_NONBLOCK);
if(read_bytes < 0) {
if( errno != EAGAIN )
- osrfLogWarning( " * Error reading socket with errno %d", errno );
+ osrfLogWarning( OSRF_LOG_MARK, " * Error reading socket with errno %d", errno );
}
} else { return -1; } /* inform the caller that this node has been tampered with */
string_array* init_string_array(int size) {
if(size > STRING_ARRAY_MAX_SIZE)
- osrfLogError("init_string_array size is too large");
+ osrfLogError( OSRF_LOG_MARK, "init_string_array size is too large");
string_array* arr =
(string_array*) safe_malloc(sizeof(string_array));
arr->size++;
if( arr->size > STRING_ARRAY_MAX_SIZE )
- osrfLogError("string_array_add size is too large");
+ osrfLogError( OSRF_LOG_MARK, "string_array_add size is too large");
/* if necessary, double capacity */
if(arr->size >= arr->arr_size) {