diff --git a/ChangeLog b/ChangeLog index 62971d8d..1e307592 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-06-13 Tatsuhiro Tsujikawa + + Made DHTMessageEntry struct + * src/DHTMessageDispatcherImpl.cc + * src/DHTMessageDispatcherImpl.h + * src/DHTMessageEntry.cc + * src/DHTMessageEntry.h + 2010-06-13 Tatsuhiro Tsujikawa Made DHTNodeLookupEntry struct diff --git a/src/DHTMessageDispatcherImpl.cc b/src/DHTMessageDispatcherImpl.cc index bb507c52..2ea04c16 100644 --- a/src/DHTMessageDispatcherImpl.cc +++ b/src/DHTMessageDispatcherImpl.cc @@ -55,44 +55,48 @@ DHTMessageDispatcherImpl::DHTMessageDispatcherImpl DHTMessageDispatcherImpl::~DHTMessageDispatcherImpl() {} void -DHTMessageDispatcherImpl::addMessageToQueue(const SharedHandle& message, - time_t timeout, - const SharedHandle& callback) +DHTMessageDispatcherImpl::addMessageToQueue +(const SharedHandle& message, + time_t timeout, + const SharedHandle& callback) { - SharedHandle e(new DHTMessageEntry(message, timeout, callback)); + SharedHandle e + (new DHTMessageEntry(message, timeout, callback)); _messageQueue.push_back(e); } void -DHTMessageDispatcherImpl::addMessageToQueue(const SharedHandle& message, - const SharedHandle& callback) +DHTMessageDispatcherImpl::addMessageToQueue +(const SharedHandle& message, + const SharedHandle& callback) { addMessageToQueue(message, _timeout, callback); } bool -DHTMessageDispatcherImpl::sendMessage(const SharedHandle& entry) +DHTMessageDispatcherImpl::sendMessage +(const SharedHandle& entry) { try { - if(entry->_message->send()) { - if(!entry->_message->isReply()) { - _tracker->addMessage(entry->_message, entry->_timeout, entry->_callback); + if(entry->message->send()) { + if(!entry->message->isReply()) { + _tracker->addMessage(entry->message, entry->timeout, entry->callback); } if(_logger->info()) { - _logger->info("Message sent: %s", entry->_message->toString().c_str()); + _logger->info("Message sent: %s", entry->message->toString().c_str()); } } else { return false; } } catch(RecoverableException& e) { _logger->info("Failed to send message: %s", - e, entry->_message->toString().c_str()); + e, entry->message->toString().c_str()); // Add message to DHTMessageTracker with timeout 0 to treat it as // time out. Without this, we have untracked message and some of // DHTTask(such as DHTAbstractNodeLookupTask) don't finish // forever. - if(!entry->_message->isReply()) { - _tracker->addMessage(entry->_message, 0, entry->_callback); + if(!entry->message->isReply()) { + _tracker->addMessage(entry->message, 0, entry->callback); } } return true; diff --git a/src/DHTMessageDispatcherImpl.h b/src/DHTMessageDispatcherImpl.h index ea48904b..650030d7 100644 --- a/src/DHTMessageDispatcherImpl.h +++ b/src/DHTMessageDispatcherImpl.h @@ -41,7 +41,7 @@ namespace aria2 { class DHTMessageTracker; -class DHTMessageEntry; +struct DHTMessageEntry; class Logger; class DHTMessageDispatcherImpl:public DHTMessageDispatcher { diff --git a/src/DHTMessageEntry.cc b/src/DHTMessageEntry.cc index 29342d83..6eaafe5d 100644 --- a/src/DHTMessageEntry.cc +++ b/src/DHTMessageEntry.cc @@ -39,12 +39,13 @@ namespace aria2 { -DHTMessageEntry::DHTMessageEntry(const SharedHandle& message, - time_t timeout, - const SharedHandle& callback): - _message(message), - _timeout(timeout), - _callback(callback) {} +DHTMessageEntry::DHTMessageEntry +(const SharedHandle& message, + time_t timeout, + const SharedHandle& callback): + message(message), + timeout(timeout), + callback(callback) {} DHTMessageEntry::~DHTMessageEntry() {} diff --git a/src/DHTMessageEntry.h b/src/DHTMessageEntry.h index fb325e11..84e87d91 100644 --- a/src/DHTMessageEntry.h +++ b/src/DHTMessageEntry.h @@ -44,11 +44,10 @@ namespace aria2 { class DHTMessage; class DHTMessageCallback; -class DHTMessageEntry { -public: - SharedHandle _message; - time_t _timeout; - SharedHandle _callback; +struct DHTMessageEntry { + SharedHandle message; + time_t timeout; + SharedHandle callback; DHTMessageEntry(const SharedHandle& message, time_t timeout,