Bug 914514 - Close socket right after the user stops the transmission, r=gyeh, r=btian

Instead of setting a flag, this patch would shutdown current connection
right after the user stopped the transmission.
This commit is contained in:
Eric Chou 2013-10-01 10:53:08 +08:00
parent c897785f6d
commit 1e7ea56b53
2 changed files with 7 additions and 20 deletions

View File

@ -389,7 +389,13 @@ BluetoothOppManager::SendFile(const nsAString& aDeviceAddress,
bool
BluetoothOppManager::StopSendingFile()
{
mAbortFlag = true;
MOZ_ASSERT(NS_IsMainThread());
if (mIsServer) {
mAbortFlag = true;
} else {
Disconnect(nullptr);
}
return true;
}
@ -929,11 +935,6 @@ BluetoothOppManager::ClientDataHandler(UnixSocketRawData* aMessage)
return;
}
if (mAbortFlag) {
SendAbortRequest();
return;
}
if (kUpdateProgressBase * mUpdateProgressCounter < mSentFileLength) {
UpdateProgress();
mUpdateProgressCounter = mSentFileLength / kUpdateProgressBase + 1;
@ -1083,19 +1084,6 @@ BluetoothOppManager::SendDisconnectRequest()
SendObexData(req, ObexRequestCode::Disconnect, index);
}
void
BluetoothOppManager::SendAbortRequest()
{
if (!mConnected) return;
// Section 3.3.5 "Abort", IrOBEX 1.2
// [opcode:1][length:2][Headers:var]
uint8_t req[255];
int index = 3;
SendObexData(req, ObexRequestCode::Abort, index);
}
void
BluetoothOppManager::CheckPutFinal(uint32_t aNumRead)
{

View File

@ -56,7 +56,6 @@ public:
void SendPutRequest(uint8_t* aFileBody, int aFileBodyLength);
void SendPutFinalRequest();
void SendDisconnectRequest();
void SendAbortRequest();
void ExtractPacketHeaders(const ObexHeaderSet& aHeader);
bool ExtractBlobHeaders();