added LocalDestinationInfo I2PControl request - #2486
Conversation
| int GetNumRemoteLeaseSets () const { return m_RemoteLeaseSets.size (); }; | ||
| const decltype(m_RemoteLeaseSets)& GetLeaseSets () const { return m_RemoteLeaseSets; }; | ||
| // copy for other threads, unlike GetLeaseSets which hands out the container itself | ||
| std::vector<std::shared_ptr<i2p::data::LeaseSet> > GetLeaseSetsList () const |
There was a problem hiding this comment.
Новый метод, до этого не существующий
| const decltype(m_Streams)& GetStreams () const { return m_Streams; }; | ||
|
|
||
| // copy for other threads, unlike GetStreams which hands out the map itself | ||
| void GetStreamsList (std::vector<std::shared_ptr<const Stream> >& streams) |
There was a problem hiding this comment.
Новый метод до этого не существующий
| for (auto& it: m_StreamingDestination->GetStreams ()) | ||
| ret.push_back (it.second); | ||
| } | ||
| m_StreamingDestination->GetStreamsList (ret); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Новый vector создается, через новый метод и переменная ссылается на него. Добавлен мьютекс
There was a problem hiding this comment.
Безопасно ли выводить все свои лизсеты
данного метода нет в java. Оно локально вызывается или может быть вызвано извне?
There was a problem hiding this comment.
Безопасно ли выводить все свои лизсеты
данного метода нет в java. Оно локально вызывается или может быть вызвано извне?
There was a problem hiding this comment.
I2PControl всегда локальный
|
а так ок вродь |
| const decltype(m_Streams)& GetStreams () const { return m_Streams; }; | ||
|
|
||
| // copy for other threads, unlike GetStreams which hands out the map itself | ||
| void GetStreamsList (std::vector<std::shared_ptr<const Stream> >& streams) |
There was a problem hiding this comment.
Лучше этот вектор возвращать чем передавать на него ссылку.
8164d89 to
37acd98
Compare
Fix for #1820
LocalDestinationInfo returns the leasesets a local destination knows and the
streams it has open, so a service with several tunnels can see how loaded each
one is. The destination is given by its address, name to address mapping is
already there in ClientServicesInfo.
GetAllStreams now copies the map under the existing m_StreamsMutex, the list is
walked from another thread while streams are created and deleted. Checked with
thread sanitizer on a live router, 28808 requests while streams came and went:
without the lock it reports a race between the walk and the map, with the lock
there is none.
Both lists come back as JSON arrays and stay arrays when empty. Missing, empty
and malformed addresses answer with an error and no crash.