@@ -760,7 +760,10 @@ class CConnman
760
760
bool m_i2p_accept_incoming;
761
761
};
762
762
763
- void Init (const Options& connOptions) {
763
+ void Init (const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
764
+ {
765
+ AssertLockNotHeld (m_total_bytes_sent_mutex);
766
+
764
767
nLocalServices = connOptions.nLocalServices ;
765
768
nMaxConnections = connOptions.nMaxConnections ;
766
769
m_max_outbound_full_relay = std::min (connOptions.m_max_outbound_full_relay , connOptions.nMaxConnections );
@@ -789,7 +792,7 @@ class CConnman
789
792
790
793
CConnman (uint64_t seed0, uint64_t seed1, AddrMan& addrman, bool network_active = true );
791
794
~CConnman ();
792
- bool Start (CScheduler& scheduler, const Options& options);
795
+ bool Start (CScheduler& scheduler, const Options& options) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
793
796
794
797
void StopThreads ();
795
798
void StopNodes ();
@@ -808,7 +811,7 @@ class CConnman
808
811
809
812
bool ForNode (NodeId id, std::function<bool (CNode* pnode)> func);
810
813
811
- void PushMessage (CNode* pnode, CSerializedNetMsg&& msg);
814
+ void PushMessage (CNode* pnode, CSerializedNetMsg&& msg) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
812
815
813
816
using NodeFn = std::function<void (CNode*)>;
814
817
void ForEachNode (const NodeFn& func)
@@ -899,24 +902,22 @@ class CConnman
899
902
// ! that peer during `net_processing.cpp:PushNodeVersion()`.
900
903
ServiceFlags GetLocalServices () const ;
901
904
902
- uint64_t GetMaxOutboundTarget () const ;
905
+ uint64_t GetMaxOutboundTarget () const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
903
906
std::chrono::seconds GetMaxOutboundTimeframe () const ;
904
907
905
908
// ! check if the outbound target is reached
906
909
// ! if param historicalBlockServingLimit is set true, the function will
907
910
// ! response true if the limit for serving historical blocks has been reached
908
- bool OutboundTargetReached (bool historicalBlockServingLimit) const ;
911
+ bool OutboundTargetReached (bool historicalBlockServingLimit) const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
909
912
910
913
// ! response the bytes left in the current max outbound cycle
911
914
// ! in case of no limit, it will always response 0
912
- uint64_t GetOutboundTargetBytesLeft () const ;
915
+ uint64_t GetOutboundTargetBytesLeft () const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
913
916
914
- // ! returns the time left in the current max outbound cycle
915
- // ! in case of no limit, it will always return 0
916
- std::chrono::seconds GetMaxOutboundTimeLeftInCycle () const ;
917
+ std::chrono::seconds GetMaxOutboundTimeLeftInCycle () const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
917
918
918
919
uint64_t GetTotalBytesRecv () const ;
919
- uint64_t GetTotalBytesSent () const ;
920
+ uint64_t GetTotalBytesSent () const EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
920
921
921
922
/* * Get a unique deterministic randomizer. */
922
923
CSipHasher GetDeterministicRandomizer (uint64_t id) const ;
@@ -942,6 +943,10 @@ class CConnman
942
943
NetPermissionFlags m_permissions;
943
944
};
944
945
946
+ // ! returns the time left in the current max outbound cycle
947
+ // ! in case of no limit, it will always return 0
948
+ std::chrono::seconds GetMaxOutboundTimeLeftInCycle_ () const EXCLUSIVE_LOCKS_REQUIRED(m_total_bytes_sent_mutex);
949
+
945
950
bool BindListenPort (const CService& bindAddr, bilingual_str& strError, NetPermissionFlags permissions);
946
951
bool Bind (const CService& addr, unsigned int flags, NetPermissionFlags permissions);
947
952
bool InitBinds (const Options& options);
@@ -1001,7 +1006,7 @@ class CConnman
1001
1006
/* *
1002
1007
* Check connected and listening sockets for IO readiness and process them accordingly.
1003
1008
*/
1004
- void SocketHandler ();
1009
+ void SocketHandler () EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
1005
1010
1006
1011
/* *
1007
1012
* Do the read/write for connected sockets that are ready for IO.
@@ -1014,15 +1019,16 @@ class CConnman
1014
1019
void SocketHandlerConnected (const std::vector<CNode*>& nodes,
1015
1020
const std::set<SOCKET>& recv_set,
1016
1021
const std::set<SOCKET>& send_set,
1017
- const std::set<SOCKET>& error_set);
1022
+ const std::set<SOCKET>& error_set)
1023
+ EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1018
1024
1019
1025
/* *
1020
1026
* Accept incoming connections, one from each read-ready listening socket.
1021
1027
* @param[in] recv_set Sockets that are ready for read.
1022
1028
*/
1023
1029
void SocketHandlerListening (const std::set<SOCKET>& recv_set);
1024
1030
1025
- void ThreadSocketHandler ();
1031
+ void ThreadSocketHandler () EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
1026
1032
void ThreadDNSAddressSeed ();
1027
1033
1028
1034
uint64_t CalculateKeyedNetGroup (const CAddress& ad) const ;
@@ -1051,7 +1057,7 @@ class CConnman
1051
1057
1052
1058
// Network stats
1053
1059
void RecordBytesRecv (uint64_t bytes);
1054
- void RecordBytesSent (uint64_t bytes);
1060
+ void RecordBytesSent (uint64_t bytes) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex) ;
1055
1061
1056
1062
/* *
1057
1063
* Return vector of current BLOCK_RELAY peers.
0 commit comments