From 6ab640c50bfa42a86bee680524b77e2e48d721dd Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Tue, 30 Jan 2007 20:06:42 +0000 Subject: [PATCH] Fixes a race condition --- libtransmission/peermessages.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libtransmission/peermessages.h b/libtransmission/peermessages.h index 4663dc68c..12325c21c 100644 --- a/libtransmission/peermessages.h +++ b/libtransmission/peermessages.h @@ -95,6 +95,12 @@ static uint8_t * blockPending( tr_torrent_t * tor, tr_peer_t * peer, tr_ioRead( tor->io, r->index, r->begin, r->length, &p[13] ); + if( peer->outRequestCount < 1 ) + { + /* We were choked during the read */ + return NULL; + } + peer_dbg( "SEND piece %d/%d (%d bytes)", r->index, r->begin, r->length );