summaryrefslogtreecommitdiff
path: root/indra/llmessage/llxfer_vfile.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2018-05-08 15:55:01 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2018-05-08 15:55:01 +0300
commitff521c67ff5580e1df2e01ec7ff511cad311f5f1 (patch)
tree9093c10c41c098239a5fd70664c33665d2196693 /indra/llmessage/llxfer_vfile.cpp
parent9eabb2797ea6a485c2b82efb0c31da55755cbca2 (diff)
MAINT-7626 Update logging and comments, sync remaining transfer changes
Diffstat (limited to 'indra/llmessage/llxfer_vfile.cpp')
-rw-r--r--indra/llmessage/llxfer_vfile.cpp65
1 files changed, 52 insertions, 13 deletions
diff --git a/indra/llmessage/llxfer_vfile.cpp b/indra/llmessage/llxfer_vfile.cpp
index 5d41180192..e0281f1348 100644
--- a/indra/llmessage/llxfer_vfile.cpp
+++ b/indra/llmessage/llxfer_vfile.cpp
@@ -79,8 +79,20 @@ void LLXfer_VFile::init (LLVFS *vfs, const LLUUID &local_id, LLAssetType::EType
void LLXfer_VFile::cleanup ()
{
- LLVFile file(mVFS, mTempID, mType, LLVFile::WRITE);
- file.remove();
+ if (mTempID.notNull() &&
+ mDeleteTempFile)
+ {
+ if (mVFS->getExists(mTempID, mType))
+ {
+ LLVFile file(mVFS, mTempID, mType, LLVFile::WRITE);
+ file.remove();
+ }
+ else
+ {
+ LL_WARNS("Xfer") << "LLXfer_VFile::cleanup() can't open to delete VFS file " << mTempID << "." << LLAssetType::lookup(mType)
+ << ", mRemoteID is " << mRemoteID << LL_ENDL;
+ }
+ }
delete mVFile;
mVFile = NULL;
@@ -118,7 +130,7 @@ S32 LLXfer_VFile::initializeRequest(U64 xfer_id,
mName = llformat("VFile %s:%s", id_string.c_str(), LLAssetType::lookup(mType));
- LL_INFOS() << "Requesting " << mName << LL_ENDL;
+ LL_INFOS("Xfer") << "Requesting " << mName << LL_ENDL;
if (mBuffer)
{
@@ -131,6 +143,7 @@ S32 LLXfer_VFile::initializeRequest(U64 xfer_id,
mBufferLength = 0;
mPacketNum = 0;
mTempID.generate();
+ mDeleteTempFile = TRUE;
mStatus = e_LL_XFER_PENDING;
return retval;
}
@@ -140,7 +153,8 @@ S32 LLXfer_VFile::initializeRequest(U64 xfer_id,
S32 LLXfer_VFile::startDownload()
{
S32 retval = 0; // presume success
- LLVFile file(mVFS, mTempID, mType, LLVFile::APPEND);
+
+ // Don't need to create the file here, it will happen when data arrives
gMessageSystem->newMessageFast(_PREHASH_RequestXfer);
gMessageSystem->nextBlockFast(_PREHASH_XferID);
@@ -184,6 +198,8 @@ S32 LLXfer_VFile::startSend (U64 xfer_id, const LLHost &remote_host)
if (mVFile->getSize() <= 0)
{
+ LL_WARNS("Xfer") << "LLXfer_VFile::startSend() VFS file " << mLocalID << "." << LLAssetType::lookup(mType)
+ << " has unexpected file size of " << mVFile->getSize() << LL_ENDL;
delete mVFile;
mVFile = NULL;
@@ -198,6 +214,7 @@ S32 LLXfer_VFile::startSend (U64 xfer_id, const LLHost &remote_host)
}
else
{
+ LL_WARNS("Xfer") << "LLXfer_VFile::startSend() can't read VFS file " << mLocalID << "." << LLAssetType::lookup(mType) << LL_ENDL;
retval = LL_ERR_FILE_NOT_FOUND;
}
@@ -223,8 +240,11 @@ S32 LLXfer_VFile::reopenFileHandle()
if (mVFile == NULL)
{
- mVFile =new LLVFile(mVFS, mLocalID, mType, LLVFile::READ);
- if (mVFile == NULL)
+ if (mVFS->getExists(mLocalID, mType))
+ {
+ mVFile = new LLVFile(mVFS, mLocalID, mType, LLVFile::READ);
+ }
+ else
{
LL_WARNS("Xfer") << "LLXfer_VFile::reopenFileHandle() can't read VFS file " << mLocalID << "." << LLAssetType::lookup(mType) << LL_ENDL;
retval = LL_ERR_FILE_NOT_FOUND;
@@ -268,8 +288,8 @@ S32 LLXfer_VFile::suck(S32 start_position)
// grab a buffer from the right place in the file
if (! mVFile->seek(start_position, 0))
{
- LL_WARNS() << "VFile Xfer Can't seek to position " << start_position << ", file length " << mVFile->getSize() << LL_ENDL;
- LL_WARNS() << "While sending file " << mLocalID << LL_ENDL;
+ LL_WARNS("Xfer") << "VFile Xfer Can't seek to position " << start_position << ", file length " << mVFile->getSize() << LL_ENDL;
+ LL_WARNS("Xfer") << "While sending file " << mLocalID << LL_ENDL;
return -1;
}
@@ -320,12 +340,31 @@ S32 LLXfer_VFile::processEOF()
if (!mCallbackResult)
{
- LLVFile file(mVFS, mTempID, mType, LLVFile::WRITE);
- if (! file.rename(mLocalID, mType))
+ if (mVFS->getExists(mTempID, mType))
{
- LL_INFOS() << "copy from temp file failed: unable to rename to " << mLocalID << LL_ENDL;
+ LLVFile file(mVFS, mTempID, mType, LLVFile::WRITE);
+ if (!file.rename(mLocalID, mType))
+ {
+ LL_WARNS("Xfer") << "VFS rename of temp file failed: unable to rename " << mTempID << " to " << mLocalID << LL_ENDL;
+ }
+ else
+ {
+ #ifdef VFS_SPAM
+ // Debugging spam
+ LL_INFOS("Xfer") << "VFS rename of temp file done: renamed " << mTempID << " to " << mLocalID
+ << " LLVFile size is " << file.getSize()
+ << LL_ENDL;
+ #endif
+
+ // Rename worked: the original file is gone. Clear mDeleteTempFile
+ // so we don't attempt to delete the file in cleanup()
+ mDeleteTempFile = FALSE;
+ }
+ }
+ else
+ {
+ LL_WARNS("Xfer") << "LLXfer_VFile::processEOF() can't open for renaming VFS file " << mTempID << "." << LLAssetType::lookup(mType) << LL_ENDL;
}
-
}
if (mVFile)
@@ -367,4 +406,4 @@ std::string LLXfer_VFile::getFileName()
U32 LLXfer_VFile::getXferTypeTag()
{
return LLXfer::XFER_VFILE;
-}
+} \ No newline at end of file