MCPcopy Create free account
hub / github.com/amule-project/amule / SendListToServer

Method SendListToServer

src/SharedFileList.cpp:1001–1096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

999}
1000
1001void CSharedFileList::SendListToServer(){
1002 std::vector<CKnownFile*> SortedList;
1003
1004 {
1005 wxMutexLocker lock(list_mut);
1006
1007 if (m_Files_map.empty() || !theApp->IsConnectedED2K() ) {
1008 return;
1009 }
1010
1011 // Getting a sorted list of the non-published files.
1012 SortedList.reserve( m_Files_map.size() );
1013
1014 CKnownFileMap::iterator it = m_Files_map.begin();
1015 for ( ; it != m_Files_map.end(); ++it ) {
1016 if (!it->second->GetPublishedED2K()) {
1017 SortedList.push_back( it->second );
1018 }
1019 }
1020 }
1021
1022 std::sort( SortedList.begin(), SortedList.end(), SortFunc );
1023
1024 // Limits for the server.
1025
1026 CServer* server = theApp->serverconnect->GetCurrentServer();
1027 if (!server) {
1028 return;
1029 }
1030
1031 uint32 limit = server->GetSoftFiles();
1032 if( limit == 0 || limit > 200 ) {
1033 limit = 200;
1034 }
1035
1036 if( (uint32)SortedList.size() < limit ) {
1037 limit = SortedList.size();
1038 if (limit == 0) {
1039 m_lastPublishED2KFlag = false;
1040 return;
1041 }
1042 }
1043
1044 CMemFile files;
1045
1046 // Files-sent count is patched in after the loop. We can't write the
1047 // final number up-front because the loop body filters out >4GB files
1048 // when the server doesn't advertise SRV_TCPFLG_LARGEFILES, and we
1049 // only know how many actually made it into the packet once the loop
1050 // has run. Pre-fix the header was hard-coded to `limit`, so the
1051 // packet header claimed N files but the body could carry N-K of them
1052 // for any K >4GB files in the prefix; legacy non-LF servers see a
1053 // short read against the count and may reject or partially process
1054 // the publish (#347).
1055 files.WriteUInt32(0);
1056
1057 uint32 count = 0;
1058 // Add to packet

Callers

nothing calls this directly

Calls 15

GetPublishedED2KMethod · 0.80
GetSoftFilesMethod · 0.80
WriteUInt32Method · 0.80
IsLargeFileMethod · 0.80
SupportsLargeFilesTCPMethod · 0.80
SetPublishedED2KMethod · 0.80
SeekMethod · 0.80
GetTCPFlagsMethod · 0.80
PackPacketMethod · 0.80
GetPacketSizeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected