Browse Source

peer_on_no_reqs was called unsafely in peer_on_choke. It should only be

called after removing the last request.
master
Richard Nyberg 19 years ago
parent
commit
66d742a48e
2 changed files with 4 additions and 2 deletions
  1. +4
    -0
      btpd/download_subr.c
  2. +0
    -2
      btpd/peer.c

+ 4
- 0
btpd/download_subr.c View File

@@ -415,6 +415,9 @@ dl_unassign_requests(struct peer *p)
req = next; req = next;
} }


if (p->nreqs_out == 0)
peer_on_no_reqs(p);

if (was_full && !piece_full(pc)) if (was_full && !piece_full(pc))
dl_on_piece_unfull(pc); dl_on_piece_unfull(pc);
} }
@@ -497,6 +500,7 @@ dl_unassign_requests_eg(struct peer *p)
} }
} }
assert(BTPDQ_EMPTY(&p->my_reqs)); assert(BTPDQ_EMPTY(&p->my_reqs));
peer_on_no_reqs(p);


pc = BTPDQ_FIRST(&tmp); pc = BTPDQ_FIRST(&tmp);
while (pc != NULL) { while (pc != NULL) {


+ 0
- 2
btpd/peer.c View File

@@ -369,8 +369,6 @@ peer_on_choke(struct peer *p)
if ((p->flags & PF_P_CHOKE) != 0) if ((p->flags & PF_P_CHOKE) != 0)
return; return;
else { else {
if (p->nreqs_out > 0)
peer_on_no_reqs(p);
p->flags |= PF_P_CHOKE; p->flags |= PF_P_CHOKE;
dl_on_choke(p); dl_on_choke(p);
struct nb_link *nl = BTPDQ_FIRST(&p->outq); struct nb_link *nl = BTPDQ_FIRST(&p->outq);


Loading…
Cancel
Save