1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +00:00

(trunk libT) #4894 -- don't use evbuffer_add_printf() and evbuffer_pullup() together.

This commit is contained in:
Jordan Lee 2012-05-17 17:40:31 +00:00
parent a83630baf5
commit 6948852013
4 changed files with 23 additions and 17 deletions

View file

@ -50,7 +50,7 @@ get_event_string( const tr_announce_request * req )
return tr_announce_event_get_string( req->event );
}
static struct evbuffer *
static char*
announce_url_new( const tr_session * session, const tr_announce_request * req )
{
const char * str;
@ -116,7 +116,7 @@ announce_url_new( const tr_session * session, const tr_announce_request * req )
tr_http_escape( buf, ipv6_readable, -1, true );
}
return buf;
return evbuffer_free_to_str( buf );
}
static tr_pex*
@ -287,8 +287,7 @@ tr_tracker_http_announce( tr_session * session,
void * response_func_user_data )
{
struct announce_data * d;
struct evbuffer * buf = announce_url_new( session, request );
const char * url = (const char *) evbuffer_pullup( buf, -1 );
char * url = announce_url_new( session, request );
d = tr_new0( struct announce_data, 1 );
d->response.seeders = -1;
@ -302,7 +301,7 @@ tr_tracker_http_announce( tr_session * session,
dbgmsg( request->log_name, "Sending announce to libcurl: \"%s\"", url );
tr_webRun( session, url, NULL, NULL, on_announce_done, d );
evbuffer_free( buf );
tr_free( url );
}
/****
@ -429,7 +428,7 @@ on_scrape_done( tr_session * session,
tr_runInEventThread( session, on_scrape_done_eventthread, data );
}
static struct evbuffer *
static char *
scrape_url_new( const tr_scrape_request * req )
{
int i;
@ -446,7 +445,7 @@ scrape_url_new( const tr_scrape_request * req )
delimiter = '&';
}
return buf;
return evbuffer_free_to_str( buf );
}
void
@ -457,8 +456,7 @@ tr_tracker_http_scrape( tr_session * session,
{
int i;
struct scrape_data * d;
struct evbuffer * buf = scrape_url_new( request );
const char * url = (const char *) evbuffer_pullup( buf, -1 );
char * url = scrape_url_new( request );
d = tr_new0( struct scrape_data, 1 );
d->response.url = tr_strdup( request->url );
@ -477,5 +475,5 @@ tr_tracker_http_scrape( tr_session * session,
dbgmsg( request->log_name, "Sending scrape to libcurl: \"%s\"", url );
tr_webRun( session, url, NULL, NULL, on_scrape_done, d );
evbuffer_free( buf );
tr_free( url );
}

View file

@ -753,6 +753,7 @@ dbgmsg_tier_announce_queue( const tr_tier * tier )
{
int i;
char name[128];
char * message;
struct evbuffer * buf = evbuffer_new( );
tier_build_log_name( tier, name, sizeof( name ) );
@ -763,8 +764,9 @@ dbgmsg_tier_announce_queue( const tr_tier * tier )
evbuffer_add_printf( buf, "[%d:%s]", i, str );
}
tr_deepLog( __FILE__, __LINE__, name, "announce queue is %s", evbuffer_pullup( buf, -1 ) );
evbuffer_free( buf );
message = evbuffer_free_to_str( buf );
tr_deepLog( __FILE__, __LINE__, name, "announce queue is %s", message );
tr_free( message );
}
}

View file

@ -239,6 +239,7 @@ myDebug( const char * file, int line,
char timestr[64];
struct evbuffer * buf = evbuffer_new( );
char * base = tr_basename( file );
char * message;
evbuffer_add_printf( buf, "[%s] %s - %s [%s]: ",
tr_getLogTimeStr( timestr, sizeof( timestr ) ),
@ -249,10 +250,12 @@ myDebug( const char * file, int line,
evbuffer_add_vprintf( buf, fmt, args );
va_end( args );
evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
fputs( (const char*)evbuffer_pullup( buf, -1 ), fp );
message = evbuffer_free_to_str( buf );
fputs( message, fp );
tr_free( base );
evbuffer_free( buf );
tr_free( message );
}
}

View file

@ -231,6 +231,8 @@ tr_deepLog( const char * file,
char timestr[64];
struct evbuffer * buf = evbuffer_new( );
char * base = tr_basename( file );
char * message;
const char * str;
evbuffer_add_printf( buf, "[%s] ",
tr_getLogTimeStr( timestr, sizeof( timestr ) ) );
@ -241,12 +243,13 @@ tr_deepLog( const char * file,
va_end( args );
evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
/* FIXME(libevent2) ifdef this out for nonwindows platforms */
OutputDebugString( evbuffer_pullup( buf, -1 ) );
message = evbuffer_free_to_str( buf );
OutputDebugString( message );
if( fp )
fputs( (const char*)evbuffer_pullup( buf, -1 ), fp );
fputs( message, fp );
tr_free( message );
tr_free( base );
evbuffer_free( buf );
}
}