bool PeerConnector::ConnectUDP(const PEER_ADDRESS& addr, const PeerConnectParam& param) { if (m_LiveInfo.TransferMethod == TRANSFER_TCP) { return ConnectTCP(addr, 0, param); // 用于测试纯tcp的情况 } if ( addr.UdpPort == 0 ) return false; if (CheckConnected(addr, param.IsVIP)) { VIEW_INFO("CPeerManager::ConnectToRemote CheckConnected " << addr << " failed"); return false; } const PEER_ADDRESS& localAddr = m_NetInfo->Address; if (addr.IP == localAddr.IP && addr.UdpPort == localAddr.UdpPort) { //LIVE_ASSERT(false); VIEW_ERROR("ConnectUDP ignore myself " << addr); return false; } return m_UDPConnector->Connect(addr, param); }
// Adjust pcs' window-size & insert them into RecvTimeMap. STL_FOR_EACH_CONST(PeerTunnelCollection, m_Tunnels, iter) { PeerTunnelPtr pt = *iter; PeerConnection* pc = &pt->GetConnection(); LIVE_ASSERT(pc != NULL); if (!m_downloader.CanDownload( pt )) { // 不能使用这个pc去下载,那么就跳过 continue; } #if 1//!_Savage // 清除每个Tunnel的预请求队列 VIEW_INFO(" TaskQueueLength Left "<<*pc<<" "<<pt->GetTaskQueueSize()<<" "<<pt->GetUsedTime()<<" "<<pt->GetWindowSize()); pt->ClearTaskQueue(); #endif if (pt->IsFreezing() || pc->GetMaxIndex() < m_downloader.GetStartIndex()) { // 该Peer没有资源去下载,那么也跳过 continue; } UINT minWindowSize = 2; if( pc->IsUDP() ) { // UDP 的连接 double tunnelRequestSuccedRate = pt->GetRequestSuccedRate(); UINT newWindowSize = (UINT)(80 * tunnelRequestSuccedRate / totalUDPRequestSuccedRate); if ( newWindowSize > minWindowSize ) minWindowSize = newWindowSize; } pt->AdjustWindowSize(minWindowSize); // 将tunnel插入到这个RecvTimeMap中 #if !_Savage m_RecvTimeMap.insert(std::make_pair(pt->GetSortValue(), pt.get())); #endif // !_Savage }
#include "tig/types.h" #include "tig/argv.h" #include "tig/io.h" #include "tig/keys.h" struct keybinding { enum request request; size_t keys; struct key key[1]; }; static struct keymap keymaps[] = { { "generic" }, { "search" }, #define VIEW_KEYMAP(id, name) { #name } VIEW_INFO(VIEW_KEYMAP) }; static struct keymap *generic_keymap = keymaps; #define is_generic_keymap(keymap) ((keymap) == generic_keymap) static struct keymap *search_keymap = keymaps + 1; #define is_search_keymap(keymap) ((keymap) == search_keymap) struct keymap * get_keymap(const char *name, size_t namelen) { int i; for (i = 0; i < ARRAY_SIZE(keymaps); i++) if (!strncasecmp(keymaps[i].name, name, namelen))
void Storage::ViewStreamBuffer() const { VIEW_INFO("Storage::ViewStreamBuffer - LocalBitmap " << GetMinIndex() << " " << GetMaxIndex() << " " << BuildBitmap().GetResourceString() << " End"); }