From 85bc8ebc87a3db75c2fcf4274c594a78e68c121d Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Fri, 25 May 2007 21:22:02 +0000 Subject: [PATCH] Handle the server failing to send info or stat response gracefully. --- daemon/remote.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/daemon/remote.c b/daemon/remote.c index d7120de52..0e0785d70 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -76,6 +76,8 @@ struct opts struct torinfo { int id; + int infogood; + int statgood; char * name; int64_t size; char * state; @@ -625,6 +627,7 @@ infomsg( const struct cl_info * cinfo ) RB_INSERT( torlist, &gl_torinfo, tinfo ); } + tinfo->infogood = 1; free( tinfo->name ); tinfo->name = strdup_noctrl( cinfo->name ); tinfo->size = cinfo->size; @@ -669,6 +672,7 @@ statmsg( const struct cl_stat * st ) RB_INSERT( torlist, &gl_torinfo, info ); } + info->statgood = 1; free( info->state ); info->state = strdup_noctrl( st->state ); info->eta = st->eta; @@ -903,6 +907,11 @@ printlisting( void ) RB_REMOVE( tornames, &names, ii ); RB_REMOVE( torlist, &gl_torinfo, ii ); + if( !ii->infogood || !ii->statgood ) + { + goto free; + } + /* massage some numbers into a better format for printing */ size = fmtsize( ii->size, &units ); upspeed = fmtsize( ii->rateup, &upunits ); @@ -986,6 +995,7 @@ printlisting( void ) putchar( '\n' ); /* free the stuff for this torrent */ + free: free( ii->name ); free( ii->state ); free( ii->errorcode );