Update of /cvsroot/mutella/mutella/mutella In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20604 Modified Files: asyncfile.cpp common.cpp dir.cpp dir.h gnudownload.cpp gnushare.cpp gnuupload.cpp Log Message: some success in partial fragment support Index: asyncfile.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/asyncfile.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** asyncfile.cpp 23 Jun 2006 08:48:00 -0000 1.36 --- asyncfile.cpp 7 Jan 2007 15:06:31 -0000 1.37 *************** *** 306,310 **** if (state.hFile < 0 && (pRequest->mode & AFM_CREATEPATH)) { ! // my be we still can fix this little problem if (CheckAndCreatePath(state.sPath)) { --- 306,310 ---- if (state.hFile < 0 && (pRequest->mode & AFM_CREATEPATH)) { ! // may be we still can fix this little problem if (CheckAndCreatePath(state.sPath)) { *************** *** 706,709 **** --- 706,710 ---- ASSERT(szName); ASSERT(strlen(szName)<65536); + cout << "MAsyncFile::Open " << szName << endl; // MAFRequest* pReq = new MAFRequest; Index: common.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/common.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** common.cpp 29 Jul 2004 13:05:26 -0000 1.37 --- common.cpp 7 Jan 2007 15:06:31 -0000 1.38 *************** *** 947,950 **** --- 947,952 ---- { Name.make_lower(); + if (Name[0]!='\r'||Name[0]!='\n') + Name="\r\n"+Name; int keyPos = sLowHahdshake.find(Name); if (keyPos >= 0) Index: dir.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/dir.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dir.cpp 12 Jun 2002 20:51:20 -0000 1.8 --- dir.cpp 7 Jan 2007 15:06:31 -0000 1.9 *************** *** 98,102 **** } ! bool ScanDir( DirEntryVec& result, const CString &path, const CString &nameFilter, int typeFilter, int sortSpec ) { DIR *dir; --- 98,102 ---- } ! bool ScanDir( DirEntryVec& result, const CString &path, const CString &nameFilter, bool bMultyPattern, int typeFilter ) { DIR *dir; *************** *** 125,128 **** --- 125,129 ---- // de.Path = path + "/" + de.Name; // TODO: clean path + cout << "entry:" << de.Name << endl; struct stat st; if (0==stat(de.Path.c_str(), &st)) *************** *** 146,150 **** { // we should not match directories ! if ( (de.Type & DirEntry::dir) || MultiPatternMatch(de.Name, nameFilter, false)) res.push_back(de); } --- 147,153 ---- { // we should not match directories ! if ( (de.Type & DirEntry::dir) || ! ((!bMultyPattern || MultiPatternMatch(de.Name, nameFilter, false)) && ! (bMultyPattern || SinglePatternMatch(de.Name.c_str(), nameFilter.c_str(), false)))) res.push_back(de); } Index: dir.h =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/dir.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dir.h 30 Apr 2002 14:53:44 -0000 1.5 --- dir.h 7 Jan 2007 15:06:31 -0000 1.6 *************** *** 86,90 **** bool ScanDir( DirEntryVec& result, const CString &path, ! const CString &nameFilter, int typeFilter = DirEntry::regular, int sortSpec = SORT_NONE); #endif //_DIR_H_INCLUDED_ --- 86,90 ---- bool ScanDir( DirEntryVec& result, const CString &path, ! const CString &nameFilter, bool bMultyPattern = true, int typeFilter = DirEntry::regular); #endif //_DIR_H_INCLUDED_ Index: gnudownload.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/gnudownload.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** gnudownload.cpp 5 Jan 2007 17:48:46 -0000 1.79 --- gnudownload.cpp 7 Jan 2007 15:06:31 -0000 1.80 *************** *** 133,138 **** { DirEntryVec partials; ! CString sPattern = m_sName+".[[*"+DWrdtoStr(m_nSize)+"]]"; ! if (ScanDir(partials, m_sPath, sPattern, DirEntry::regular)) pRequest->file_state.nReturn = 0; else --- 133,139 ---- { DirEntryVec partials; ! CString sPattern = m_sName+".[["+DWrdtoStr(m_nSize)+"*]]"; ! cout << "scandir "<<m_sPath<<" with a pattern "<<sPattern<<endl; ! if (ScanDir(partials, m_sPath, sPattern, false)) pRequest->file_state.nReturn = 0; else *************** *** 141,144 **** --- 142,146 ---- m_vecNames.resize(partials.size()); m_vecSizes.resize(partials.size()); + cout << "scandir returned " << partials.size() << endl; for(int i=0; i<partials.size();++i) { *************** *** 258,262 **** bool RequestStartPoint(MDownloader* pDownloader); void OnDisconnect(MDownloader* pDownloader); ! bool NeedMoreSockets(){return m_pActiveDownloader==NULL;} // int GetSizeCompleted(){return m_nPartSize + m_nFragmentOffset;} --- 260,264 ---- bool RequestStartPoint(MDownloader* pDownloader); void OnDisconnect(MDownloader* pDownloader); ! bool NeedMoreSockets(){return m_nState==DMS_Opened && m_pActiveDownloader==NULL;} // int GetSizeCompleted(){return m_nPartSize + m_nFragmentOffset;} *************** *** 379,383 **** void MDownloadFile::OnSuccessDelayed(DWORD dwSeqReqID, int nReqType, const SAFileState& FileState) { ! //TRACE2("MDownloadFile::OnSuccess; request=", m_pRequest->type_compl); SRequestStatus rs; rs.bSuccess = true; --- 381,385 ---- void MDownloadFile::OnSuccessDelayed(DWORD dwSeqReqID, int nReqType, const SAFileState& FileState) { ! //TRACE2("MDownloadFile::OnSuccess; request=", nReqType); SRequestStatus rs; rs.bSuccess = true; *************** *** 395,399 **** void MDownloadFile::OnErrorDelayed(DWORD dwSeqReqID, int nReqType, const SAFileState& FileState) { ! //TRACE2("MDownloadFile::OnError; request=", m_pRequest->type_compl); SRequestStatus rs; rs.bSuccess = false; --- 397,401 ---- void MDownloadFile::OnErrorDelayed(DWORD dwSeqReqID, int nReqType, const SAFileState& FileState) { ! //TRACE2("MDownloadFile::OnError; request=", nReqType); SRequestStatus rs; rs.bSuccess = false; *************** *** 452,457 **** { case AFR_CUSTOM: ASSERT(m_pScanRequest!=NULL); - ASSERT(m_nState == DMS_Scanning); // TODO: here check whether there is only one fragment and decode the offset. don't forget to update the partial name m_nFragmentOffset = 0; --- 454,460 ---- { case AFR_CUSTOM: + if (m_nState != DMS_Scanning) + break; ASSERT(m_pScanRequest!=NULL); // TODO: here check whether there is only one fragment and decode the offset. don't forget to update the partial name m_nFragmentOffset = 0; *************** *** 464,475 **** TRACE("MDownFileMng::OnFileEvent() extracted '" << sBR << "' as size/pos parameter of " << m_pScanRequest->m_vecNames[0] << endl ); // see if there is a separator? ! int nSepPos=sBR.find('.'); if (nSepPos>0) { // got it! ! m_nFragmentOffset = atol(sBR.substr(0,nSepPos-1).c_str()); ! ASSERT(m_nFileSize==atol(sBR.substr(nSepPos+1).c_str())); ! m_sPartPath = m_pScanRequest->m_vecNames[0]; TRACE("MDownFileMng::OnFileEvent() extracted '" << m_nFragmentOffset << "' as offset parameter of " << m_pScanRequest->m_vecNames[0] << endl ); } } --- 467,479 ---- TRACE("MDownFileMng::OnFileEvent() extracted '" << sBR << "' as size/pos parameter of " << m_pScanRequest->m_vecNames[0] << endl ); // see if there is a separator? ! int nSepPos=sBR.find('+'); if (nSepPos>0) { // got it! ! m_nFragmentOffset = atol(sBR.substr(nSepPos+1).c_str()); TRACE("MDownFileMng::OnFileEvent() extracted '" << m_nFragmentOffset << "' as offset parameter of " << m_pScanRequest->m_vecNames[0] << endl ); + TRACE("m_nFileSize="<<m_nFileSize<<" from name:"<<sBR.substr(0,nSepPos)); + ASSERT(m_nFileSize==atol(sBR.substr(0,nSepPos).c_str())); + m_sPartPath = m_sPartDirPath + "/" + m_pScanRequest->m_vecNames[0]; } } *************** *** 480,486 **** // so file is open -- we are ready to operate m_nPartSize = rs.nFileSize; m_pDownload->OnFileManReady(); // check if we possibly completed the file ! if (rs.nFileSize==m_nFileSize) { // request file move and so on --- 484,492 ---- // so file is open -- we are ready to operate m_nPartSize = rs.nFileSize; + TRACE("OnFileOpen: m_nPartSize="<<m_nPartSize); + m_nState=DMS_Opened; m_pDownload->OnFileManReady(); // check if we possibly completed the file ! if (rs.nFileSize+m_nFragmentOffset==m_nFileSize) { // request file move and so on *************** *** 533,537 **** m_mapPos.erase(itm); // check if we possibly completed the file ! if (rs.nFileSize>=m_nFileSize) { if (rs.nFileSize>m_nFileSize) --- 539,543 ---- m_mapPos.erase(itm); // check if we possibly completed the file ! if (rs.nFileSize+m_nFragmentOffset>=m_nFileSize) { if (rs.nFileSize>m_nFileSize) *************** *** 555,559 **** while (m_listStartRequesters.size()) { ! m_pDownload->OnSetStartPoint(m_listStartRequesters.front(), m_nOverlapPos); m_listStartRequesters.pop_front(); } --- 561,565 ---- while (m_listStartRequesters.size()) { ! m_pDownload->OnSetStartPoint(m_listStartRequesters.front(), m_nOverlapPos+m_nFragmentOffset); m_listStartRequesters.pop_front(); } *************** *** 561,564 **** --- 567,571 ---- case AFR_CLOSE: m_pDownload->OnFileManClosed(); + m_nState = DMS_Closed; break; case AFR_NONE: *************** *** 641,644 **** --- 648,652 ---- // assert(IsOpen) // assert(!BufInSet) + //TRACE("MDownFileMng::StoreDataAt() nPos1=" <<nPos1 <<" m_nFragmentOffset="<<m_nFragmentOffset); int nPos0 = nPos1 - m_nFragmentOffset; ASSERT(nPos0>=0); *************** *** 733,736 **** --- 741,745 ---- bool MDownFileMng::RequestStartPoint(MDownloader* pDownloader) { + ASSERT(m_nState==DMS_Opened); // in the current incarnation just read the verify buffer // if its not read already *************** *** 738,742 **** { ASSERT(m_pOverlapBuff); ! m_pDownload->OnSetStartPoint(pDownloader, m_nOverlapPos); return true; } --- 747,751 ---- { ASSERT(m_pOverlapBuff); ! m_pDownload->OnSetStartPoint(pDownloader, m_nOverlapPos+m_nFragmentOffset); return true; } *************** *** 893,897 **** void MDownloader::ForceDisconnect(int nReason, int nStatus) { ! cout << "ForceDisconnect for " << Ip2Str(m_result.Host) << " m_nStatus=" << m_nStatus << " nReason=" << nReason << " nStatus=" << nStatus << endl ; #warning Update Error Counters here! (and remove it from the other places) // update error counters --- 902,906 ---- void MDownloader::ForceDisconnect(int nReason, int nStatus) { ! TRACE( "ForceDisconnect for " << Ip2Str(m_result.Host) << " m_nStatus=" << m_nStatus << " nReason=" << nReason << " nStatus=" << nStatus ); #warning Update Error Counters here! (and remove it from the other places) // update error counters *************** *** 989,992 **** --- 998,1002 ---- void MDownloader::Initiate() { + TRACE("MDownloader::Initiate"); // call Connect or request push // Attempt to connect *************** *** 1028,1031 **** --- 1038,1042 ---- void MDownloader::Enqueue() { + TRACE("MDownloader::Enqueue"); ASSERT(m_hSocket == INVALID_SOCKET || m_bKeepAlive); // not connected or keep-alive SetStatus(TRANSFER_QUEUED); *************** *** 1136,1139 **** --- 1147,1151 ---- void MDownloader::StoreStoreBuff() { + //TRACE("MDownloader::StoreStoreBuff()"); StoreResult sr = m_pDownload->StoreDataAt(this, m_nFilePos, m_pStoreBuff, m_pStoreBuff->contains()); if (SR_Success != sr) *************** *** 1756,1762 **** //if ((*itd)->GetStatusChangeTime()+m_pPrefs->m_nRetryWait>=nTimeStamp) // break; - case TRANSFER_NEW: //if (!m_pDirector->IsDownloadHostBusy((*itd)->GetHostIP(), (*itd)->GetResult().Name)) ! (*itd)->Enqueue(); } } --- 1768,1774 ---- //if ((*itd)->GetStatusChangeTime()+m_pPrefs->m_nRetryWait>=nTimeStamp) // break; //if (!m_pDirector->IsDownloadHostBusy((*itd)->GetHostIP(), (*itd)->GetResult().Name)) ! case TRANSFER_NEW: ! (*itd)->Enqueue(); } } Index: gnushare.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/gnushare.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** gnushare.cpp 27 May 2003 09:01:29 -0000 1.41 --- gnushare.cpp 7 Jan 2007 15:06:31 -0000 1.42 *************** *** 304,308 **** { DirEntryVec files; ! if (!ScanDir(files, FullPath, m_pShare->m_pDirector->GetPrefs()->m_szShareFilter, DirEntry::regular|DirEntry::dir)) { // TODO: messageID --- 304,308 ---- { DirEntryVec files; ! if (!ScanDir(files, FullPath, m_pShare->m_pDirector->GetPrefs()->m_szShareFilter, true, DirEntry::regular|DirEntry::dir)) { // TODO: messageID Index: gnuupload.cpp =================================================================== RCS file: /cvsroot/mutella/mutella/mutella/gnuupload.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** gnuupload.cpp 29 Jul 2004 13:05:26 -0000 1.45 --- gnuupload.cpp 7 Jan 2007 15:06:31 -0000 1.46 *************** *** 159,166 **** m_bBufferReady = false; ! if(m_pPrefs->m_dBandwidthTotal > 0) ! m_dMaxRate = 0; ! else ! m_dMaxRate = -1; m_nSecNum = 0; --- 159,164 ---- m_bBufferReady = false; ! if(m_pPrefs->m_dBandwidthTotal > 0 || m_pPrefs->m_dBandwidthTransfer>0) ! m_dMaxRate = max(m_pPrefs->m_dBandwidthTotal/2,m_pPrefs->m_dBandwidthTransfer); m_nSecNum = 0; *************** *** 618,622 **** --- 616,622 ---- // Range header m_nBytesCompleted = 0; + //cout<<"sHandshake="<<sHandshake<<endl; CString sRange = find_header("Range",sHandshake,sLowHandshake); + //cout<<"sRange="<<sRange<<endl; if(!sRange.empty()) { *************** *** 980,983 **** --- 980,984 ---- m_nBytesCompleted += nBytesSentNow; // limit bandwidth + //TRACE( << "m_dMaxRate=" << m_dMaxRate << " m_dwSecBytes="<<m_dwSecBytes); if (m_dMaxRate>0 && m_dwSecBytes>m_dMaxRate && m_bBelowRateLimit) { |