Преглед на файлове

Make net->piece_count properly aligned.

The misalignment caused btpd to not work properly on machines like
the NSLU2. Reported by John Caldwell.
master
Richard Nyberg преди 16 години
родител
ревизия
432be0a103
променени са 1 файла, в които са добавени 6 реда и са изтрити 8 реда
  1. +6
    -8
      btpd/net.c

+ 6
- 8
btpd/net.c Целия файл

@@ -41,23 +41,21 @@ net_torrent_has_peer(struct net *n, const uint8_t *id)
void
net_create(struct torrent *tp)
{
size_t field_size = ceil(tp->npieces / 8.0);
size_t mem = sizeof(*(tp->net)) + field_size +
tp->npieces * sizeof(*(tp->net->piece_count));

struct net *n = btpd_calloc(1, mem);
struct net *n = btpd_calloc(1, sizeof(*n));
n->tp = tp;
tp->net = n;

BTPDQ_INIT(&n->getlst);
n->busy_field = (uint8_t *)(n + 1);
n->piece_count = (unsigned *)(n->busy_field + field_size);
n->busy_field = btpd_calloc(ceil(tp->npieces / 8.0), 1);
n->piece_count = btpd_calloc(tp->npieces, sizeof(*n->piece_count));
}

void
net_kill(struct torrent *tp)
{
free(tp->net->piece_count);
free(tp->net->busy_field);
free(tp->net);
tp->net = NULL;
}


Loading…
Отказ
Запис