ソースを参照

Make changes in the choke/interest state of a peer visible to the

policy on a lower level.
master
Richard Nyberg 19年前
コミット
ba425dc31a
3個のファイルの変更52行の追加17行の削除
  1. +20
    -16
      btpd/peer.c
  2. +28
    -0
      btpd/policy.c
  3. +4
    -1
      btpd/policy.h

+ 20
- 16
btpd/peer.c ファイルの表示

@@ -205,41 +205,45 @@ peer_create_out_compact(struct torrent *tp, const char *compact)
void
peer_on_choke(struct peer *p)
{
if ((p->flags & (PF_P_CHOKE|PF_I_WANT)) == PF_I_WANT) {
p->flags |= PF_P_CHOKE;
cm_on_undownload(p);
} else
if ((p->flags & PF_P_CHOKE) != 0)
return;
else {
p->flags |= PF_P_CHOKE;
cm_on_choke(p);
}
}

void
peer_on_unchoke(struct peer *p)
{
if ((p->flags & (PF_P_CHOKE|PF_I_WANT)) == (PF_P_CHOKE|PF_I_WANT)) {
p->flags &= ~PF_P_CHOKE;
cm_on_download(p);
} else
if ((p->flags & PF_P_CHOKE) == 0)
return;
else {
p->flags &= ~PF_P_CHOKE;
cm_on_unchoke(p);
}
}

void
peer_on_interest(struct peer *p)
{
if ((p->flags & (PF_P_WANT|PF_I_CHOKE)) == 0) {
p->flags |= PF_P_WANT;
cm_on_upload(p);
} else
if ((p->flags & PF_P_WANT) != 0)
return;
else {
p->flags |= PF_P_WANT;
cm_on_interest(p);
}
}

void
peer_on_uninterest(struct peer *p)
{
if ((p->flags & (PF_P_WANT|PF_I_CHOKE)) == PF_P_WANT) {
p->flags &= ~PF_P_WANT;
cm_on_unupload(p);
} else
if ((p->flags & PF_P_WANT) == 0)
return;
else {
p->flags &= ~PF_P_WANT;
cm_on_uninterest(p);
}
}

void


+ 28
- 0
btpd/policy.c ファイルの表示

@@ -215,6 +215,20 @@ cm_on_unupload(struct peer *peer)
choke_alg(peer->tp);
}

void
cm_on_interest(struct peer *peer)
{
if ((peer->flags & PF_I_CHOKE) == 0)
cm_on_upload(peer);
}

void
cm_on_uninterest(struct peer *peer)
{
if ((peer->flags & PF_I_CHOKE) == 0)
cm_on_unupload(peer);
}

void
cm_by_second(struct torrent *tp)
{
@@ -246,6 +260,20 @@ cm_on_undownload(struct peer *peer)
cm_unassign_requests_eg(peer);
}

void
cm_on_unchoke(struct peer *peer)
{
if ((peer->flags & PF_I_WANT) != 0)
cm_on_download(peer);
}

void
cm_on_choke(struct peer *peer)
{
if ((peer->flags & PF_I_WANT) != 0)
cm_on_undownload(peer);
}

void
cm_on_piece_ann(struct peer *peer, uint32_t piece)
{


+ 4
- 1
btpd/policy.h ファイルの表示

@@ -6,9 +6,12 @@ void cm_by_second(struct torrent *tp);
void cm_on_new_peer(struct peer *peer);
void cm_on_lost_peer(struct peer *peer);

void cm_on_choke(struct peer *peer);
void cm_on_unchoke(struct peer *peer);
void cm_on_upload(struct peer *peer);
void cm_on_unupload(struct peer *peer);

void cm_on_interest(struct peer *peer);
void cm_on_uninterest(struct peer *peer);
void cm_on_download(struct peer *peer);
void cm_on_undownload(struct peer *peer);
void cm_on_piece_ann(struct peer *peer, uint32_t piece);


読み込み中…
キャンセル
保存