|
|
@@ -489,16 +489,13 @@ peer_on_request(struct peer *p, uint32_t index, uint32_t begin, |
|
|
|
btpd_log(BTPD_L_MSG, "received request(%u,%u,%u) from %p\n", |
|
|
|
index, begin, length, p); |
|
|
|
if ((p->flags & PF_NO_REQUESTS) == 0) { |
|
|
|
uint8_t *content; |
|
|
|
if (cm_get_bytes(p->n->tp, index, begin, length, &content) == 0) { |
|
|
|
peer_send(p, nb_create_piece(index, begin, length)); |
|
|
|
peer_send(p, nb_create_torrentdata(content, length)); |
|
|
|
p->npiece_msgs++; |
|
|
|
if (p->npiece_msgs >= MAXPIECEMSGS) { |
|
|
|
peer_send(p, nb_create_choke()); |
|
|
|
peer_send(p, nb_create_unchoke()); |
|
|
|
p->flags |= PF_NO_REQUESTS; |
|
|
|
} |
|
|
|
peer_send(p, nb_create_piece(index, begin, length)); |
|
|
|
peer_send(p, nb_create_torrentdata()); |
|
|
|
p->npiece_msgs++; |
|
|
|
if (p->npiece_msgs >= MAXPIECEMSGS) { |
|
|
|
peer_send(p, nb_create_choke()); |
|
|
|
peer_send(p, nb_create_unchoke()); |
|
|
|
p->flags |= PF_NO_REQUESTS; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|