diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-01-11 14:20:34 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-01-11 16:50:04 +0900 |
| commit | 8ba0d58ee1a9fc2249839339549293ddc183fe66 (patch) | |
| tree | 3fe0018527530e93fb01cf0ea76641193b75be5d /src/BtInterestedMessage.cc | |
| parent | 74e570de379752508d7f363dd0d1a0c4ae8b7319 (diff) | |
Vectorized write for SocketBuffer to avoid small packet
Diffstat (limited to 'src/BtInterestedMessage.cc')
| -rw-r--r-- | src/BtInterestedMessage.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/BtInterestedMessage.cc b/src/BtInterestedMessage.cc index e2391bc1..8fafb399 100644 --- a/src/BtInterestedMessage.cc +++ b/src/BtInterestedMessage.cc @@ -35,6 +35,7 @@ #include "BtInterestedMessage.h" #include "Peer.h" #include "PeerStorage.h" +#include "SocketBuffer.h" namespace aria2 { @@ -66,8 +67,23 @@ bool BtInterestedMessage::sendPredicate() const return !getPeer()->amInterested(); } -void BtInterestedMessage::onSendComplete() { - getPeer()->amInterested(true); +namespace { +struct ThisProgressUpdate : public ProgressUpdate { + ThisProgressUpdate(const SharedHandle<Peer>& peer) + : peer(peer) {} + virtual void update(size_t length, bool complete) + { + if(complete) { + peer->amInterested(true); + } + } + SharedHandle<Peer> peer; +}; +} // namespace + +ProgressUpdate* BtInterestedMessage::getProgressUpdate() +{ + return new ThisProgressUpdate(getPeer()); } void BtInterestedMessage::setPeerStorage |
