Bugfixes and extra debugging for file transfer.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@791 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-11-04 23:12:53 +00:00
parent 6343de176e
commit 80f4686100
12 changed files with 333 additions and 230 deletions

View file

@ -34,6 +34,7 @@
* #define CS_DEBUG 1
***/
#define CS_DEBUG 1
bool operator<(const CacheId &a, const CacheId &b)
{
@ -209,7 +210,7 @@ CacheStore::CacheStore(uint16_t t, bool m,
void CacheStore::lockData() const
{
#ifdef CS_DEBUG
std::cerr << "CacheStore::lockData()" << std::endl;
// std::cerr << "CacheStore::lockData()" << std::endl;
#endif
cMutex.lock();
}
@ -217,7 +218,7 @@ void CacheStore::lockData() const
void CacheStore::unlockData() const
{
#ifdef CS_DEBUG
std::cerr << "CacheStore::unlockData()" << std::endl;
// std::cerr << "CacheStore::unlockData()" << std::endl;
#endif
cMutex.unlock();
}
@ -1050,15 +1051,29 @@ bool CacheTransfer::CompletedCache(std::string hash)
std::map<std::string, CacheData>::iterator dit;
std::map<std::string, CacheStore *>::iterator sit;
#ifdef CS_DEBUG
std::cerr << "CacheTransfer::CompletedCache(" << hash << ")";
std::cerr << std::endl;
#endif
/* find in store.... */
sit = cbStores.find(hash);
dit = cbData.find(hash);
if ((sit == cbStores.end()) || (dit == cbData.end()))
{
#ifdef CS_DEBUG
std::cerr << "CacheTransfer::CompletedCache() Failed to find it";
std::cerr << std::endl;
#endif
return false;
}
#ifdef CS_DEBUG
std::cerr << "CacheTransfer::CompletedCache() callback to store";
std::cerr << std::endl;
#endif
/* callback */
(sit -> second) -> downloadedCache(dit->second);

View file

@ -963,6 +963,10 @@ int DirEntry::saveEntry(std::ostringstream &oss)
int FileIndex::searchHash(std::string hash, std::list<FileEntry *> &results) const
{
#ifdef FI_DEBUG
std::cerr << "FileIndex::searchHash(" << hash << ")";
std::cerr << std::endl;
#endif
DirEntry *ndir = NULL;
std::list<DirEntry *> dirlist;
dirlist.push_back(root);
@ -985,6 +989,11 @@ int FileIndex::searchHash(std::string hash, std::list<FileEntry *> &results) con
if (hash == (fit->second)->hash)
{
results.push_back(fit->second);
#ifdef FI_DEBUG
std::cerr << "FileIndex::searchHash(" << hash << ")";
std::cerr << " found: " << fit->second->name;
std::cerr << std::endl;
#endif
}
}
}

View file

@ -44,6 +44,8 @@ FileIndexStore::~FileIndexStore()
* #define FIS_DEBUG 1
**/
#define FIS_DEBUG 1
/* actual load, once data available */
int FileIndexStore::loadCache(const CacheData &data)
{
@ -353,6 +355,10 @@ int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results)
#endif
for(pit = indices.begin(); pit != indices.end(); pit++)
{
#ifdef FIS_DEBUG
std::cerr << "FileIndexStore::SearchHash() Searching: Peer ";
std::cerr << pit->first << std::endl;
#endif
firesults.clear();
(pit->second)->searchHash(hash, firesults);
@ -373,6 +379,12 @@ int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results)
}
#ifdef FIS_DEBUG
std::cerr << "FileIndexStore::SearchHash() Found " << results.size();
std::cerr << " Results from " << indices.size() << " Peers" << std::endl;
#endif
unlockData();
return results.size();
}