tweak the daemon & remote console messages a little

This commit is contained in:
Charles Kerr 2008-05-20 14:01:15 +00:00
parent 8ea0437bcf
commit 9815e48daf
2 changed files with 11 additions and 10 deletions

View File

@ -63,7 +63,7 @@ saveState( tr_handle * h )
}
tr_bencDictAddStr( &d, "encryption", str );
tr_ninf( MY_NAME, "saving \"%s\"\n", gl_configfile );
tr_ninf( MY_NAME, "saving \"%s\"", gl_configfile );
tr_bencSaveFile( gl_configfile, &d );
tr_bencFree( &d );
@ -206,14 +206,14 @@ daemon( int nochdir, int noclose )
case 0:
break;
case -1:
tr_nerr( MY_NAME, "Error daemonizing (fork)! %d - %s\n", errno, strerror(errno) );
tr_nerr( MY_NAME, "Error daemonizing (fork)! %d - %s", errno, strerror(errno) );
return -1;
default:
_exit(0);
}
if( setsid() < 0 ) {
tr_nerr( MY_NAME, "Error daemonizing (setsid)! %d - %s\n", errno, strerror(errno) );
tr_nerr( MY_NAME, "Error daemonizing (setsid)! %d - %s", errno, strerror(errno) );
return -1;
}
@ -221,14 +221,14 @@ daemon( int nochdir, int noclose )
case 0:
break;
case -1:
tr_nerr( MY_NAME, "Error daemonizing (fork2)! %d - %s\n", errno, strerror(errno) );
tr_nerr( MY_NAME, "Error daemonizing (fork2)! %d - %s", errno, strerror(errno) );
return -1;
default:
_exit(0);
}
if( !nochdir && 0 > chdir( "/" ) ) {
tr_nerr( MY_NAME, "Error daemonizing (chdir)! %d - %s\n", errno, strerror(errno) );
tr_nerr( MY_NAME, "Error daemonizing (chdir)! %d - %s", errno, strerror(errno) );
return -1;
}

View File

@ -258,12 +258,13 @@ torrentStatusToString( int i )
}
static void
processResponse( const void * response, size_t len )
processResponse( const char * host, int port,
const void * response, size_t len )
{
tr_benc top;
if( tr_jsonParse( response, len, &top, NULL ) )
tr_nerr( MY_NAME, "Unable to parse response\n" );
tr_nerr( MY_NAME, "Unable to parse response" );
else
{
tr_benc *args, *list;
@ -272,7 +273,7 @@ processResponse( const void * response, size_t len )
tr_bencDictFindInt( &top, "tag", &tag );
if( tr_bencDictFindStr( &top, "result", &str ) )
printf( "Server responded: \"%s\"\n", str );
printf( "%s:%d responded: \"%s\"\n", host, port, str );
if( ( tag == TAG_LIST ) &&
( tr_bencDictFindDict( &top, "arguments", &args ) ) &&
@ -328,9 +329,9 @@ processRequests( const char * host, int port,
CURLcode res;
curl_easy_setopt( curl, CURLOPT_POSTFIELDS, reqs[i] );
if(( res = curl_easy_perform( curl )))
tr_nerr( MY_NAME, "%s\n", curl_easy_strerror( res ) );
tr_nerr( MY_NAME, "(%s:%d) %s", host, port, curl_easy_strerror( res ) );
else
processResponse( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );
processResponse( host, port, EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );
evbuffer_drain( buf, EVBUFFER_LENGTH( buf ) );
}