mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1158818: Only store Bluetooth result runnable after command has been sent successfully, r=shuang
With the current code, the Bluetooth result runnable is saved for receiving before a command has been sent successfully. If sending fails afterwards, the saved result runnable will still sit in the result queue, and interfere with later, successful commands. With this patch, the result runnable is saved only if the sending was successful.
This commit is contained in:
parent
65d3ca050c
commit
79b0cc601a
@ -1507,6 +1507,7 @@ BluetoothDaemonProtocol::Send(BluetoothDaemonPDU* aPDU, void* aUserData)
|
|||||||
MOZ_ASSERT(mConnection);
|
MOZ_ASSERT(mConnection);
|
||||||
MOZ_ASSERT(aPDU);
|
MOZ_ASSERT(aPDU);
|
||||||
|
|
||||||
|
aPDU->SetConsumer(this);
|
||||||
aPDU->SetUserData(aUserData);
|
aPDU->SetUserData(aUserData);
|
||||||
aPDU->UpdateHeader();
|
aPDU->UpdateHeader();
|
||||||
return mConnection->Send(aPDU); // Forward PDU to command channel
|
return mConnection->Send(aPDU); // Forward PDU to command channel
|
||||||
|
@ -42,8 +42,9 @@ static const char sBluetoothdSocketName[] = "bluez_hal_socket";
|
|||||||
|
|
||||||
BluetoothDaemonPDU::BluetoothDaemonPDU(uint8_t aService, uint8_t aOpcode,
|
BluetoothDaemonPDU::BluetoothDaemonPDU(uint8_t aService, uint8_t aOpcode,
|
||||||
uint16_t aPayloadSize)
|
uint16_t aPayloadSize)
|
||||||
: UnixSocketIOBuffer(HEADER_SIZE + aPayloadSize)
|
: UnixSocketIOBuffer(HEADER_SIZE + aPayloadSize)
|
||||||
, mUserData(nullptr)
|
, mConsumer(nullptr)
|
||||||
|
, mUserData(nullptr)
|
||||||
{
|
{
|
||||||
uint8_t* data = Append(HEADER_SIZE);
|
uint8_t* data = Append(HEADER_SIZE);
|
||||||
MOZ_ASSERT(data);
|
MOZ_ASSERT(data);
|
||||||
@ -55,8 +56,9 @@ BluetoothDaemonPDU::BluetoothDaemonPDU(uint8_t aService, uint8_t aOpcode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BluetoothDaemonPDU::BluetoothDaemonPDU(size_t aPayloadSize)
|
BluetoothDaemonPDU::BluetoothDaemonPDU(size_t aPayloadSize)
|
||||||
: UnixSocketIOBuffer(HEADER_SIZE + aPayloadSize)
|
: UnixSocketIOBuffer(HEADER_SIZE + aPayloadSize)
|
||||||
, mUserData(nullptr)
|
, mConsumer(nullptr)
|
||||||
|
, mUserData(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -92,6 +94,12 @@ BluetoothDaemonPDU::Send(int aFd)
|
|||||||
|
|
||||||
Consume(res);
|
Consume(res);
|
||||||
|
|
||||||
|
if (mConsumer) {
|
||||||
|
// We successfully sent a PDU, now store the
|
||||||
|
// result runnable in the consumer.
|
||||||
|
mConsumer->StoreUserData(*this);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +384,6 @@ BluetoothDaemonConnectionIO::Send(BluetoothDaemonPDU* aPDU)
|
|||||||
MOZ_ASSERT(mConsumer);
|
MOZ_ASSERT(mConsumer);
|
||||||
MOZ_ASSERT(aPDU);
|
MOZ_ASSERT(aPDU);
|
||||||
|
|
||||||
mConsumer->StoreUserData(*aPDU); // Store user data for reply
|
|
||||||
EnqueueData(aPDU);
|
EnqueueData(aPDU);
|
||||||
AddWatchers(WRITE_WATCHER, false);
|
AddWatchers(WRITE_WATCHER, false);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace mozilla {
|
|||||||
namespace ipc {
|
namespace ipc {
|
||||||
|
|
||||||
class BluetoothDaemonConnectionIO;
|
class BluetoothDaemonConnectionIO;
|
||||||
|
class BluetoothDaemonPDUConsumer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* |BlutoothDaemonPDU| represents a single PDU that is transfered from or to
|
* |BlutoothDaemonPDU| represents a single PDU that is transfered from or to
|
||||||
@ -55,6 +56,11 @@ public:
|
|||||||
uint16_t aPayloadSize);
|
uint16_t aPayloadSize);
|
||||||
BluetoothDaemonPDU(size_t aPayloadSize);
|
BluetoothDaemonPDU(size_t aPayloadSize);
|
||||||
|
|
||||||
|
void SetConsumer(BluetoothDaemonPDUConsumer* aConsumer)
|
||||||
|
{
|
||||||
|
mConsumer = aConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
void SetUserData(void* aUserData)
|
void SetUserData(void* aUserData)
|
||||||
{
|
{
|
||||||
mUserData = aUserData;
|
mUserData = aUserData;
|
||||||
@ -79,6 +85,7 @@ private:
|
|||||||
size_t GetPayloadSize() const;
|
size_t GetPayloadSize() const;
|
||||||
void OnError(const char* aFunction, int aErrno);
|
void OnError(const char* aFunction, int aErrno);
|
||||||
|
|
||||||
|
BluetoothDaemonPDUConsumer* mConsumer;
|
||||||
void* mUserData;
|
void* mUserData;
|
||||||
ScopedClose mReceivedFd;
|
ScopedClose mReceivedFd;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user