Bug 1074419: Close received socket file descriptors on errors, r=shawnjohnjr

This commit is contained in:
Thomas Zimmermann 2014-10-01 10:50:33 +02:00
parent 4d0afd2adf
commit 3a8da53d02
4 changed files with 18 additions and 2 deletions

View File

@ -363,6 +363,8 @@ public:
{
MOZ_ASSERT(NS_IsMainThread());
mozilla::ScopedClose fd(aFd); // Close received socket fd on error
if (mImpl->IsShutdownOnMainThread()) {
BT_LOGD("mConsumer is null, aborting receive!");
return;
@ -374,7 +376,8 @@ public:
}
mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new AcceptTask(mImpl, fd.forget()));
}
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE

View File

@ -9,6 +9,7 @@
#include <unistd.h>
#include <sys/socket.h>
#include "BluetoothHALHelpers.h"
#include "mozilla/FileUtils.h"
#include "nsClassHashtable.h"
#include "nsXULAppAPI.h"
@ -485,6 +486,10 @@ public:
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if ((aStatus != STATUS_SUCCESS) && (GetClientFd() != -1)) {
mozilla::ScopedClose(GetClientFd()); // Close received socket fd on error
}
DispatchBluetoothSocketHALResult(
GetResultHandler(), &BluetoothSocketResultHandler::Accept,
GetClientFd(), GetBdAddress(), GetConnectionStatus(), aStatus);

View File

@ -363,6 +363,8 @@ public:
{
MOZ_ASSERT(NS_IsMainThread());
mozilla::ScopedClose fd(aFd); // Close received socket fd on error
if (mImpl->IsShutdownOnMainThread()) {
BT_LOGD("mConsumer is null, aborting receive!");
return;
@ -374,7 +376,8 @@ public:
}
mImpl->mConsumer->SetAddress(aBdAddress);
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new AcceptTask(mImpl, fd.forget()));
}
void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE

View File

@ -9,6 +9,7 @@
#include <sys/socket.h>
#include <unistd.h>
#include "BluetoothHALHelpers.h"
#include "mozilla/FileUtils.h"
#include "nsClassHashtable.h"
#include "nsXULAppAPI.h"
@ -485,6 +486,10 @@ public:
void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE
{
if ((aStatus != STATUS_SUCCESS) && (GetClientFd() != -1)) {
mozilla::ScopedClose(GetClientFd()); // Close received socket fd on error
}
DispatchBluetoothSocketHALResult(
GetResultHandler(), &BluetoothSocketResultHandler::Accept,
GetClientFd(), GetBdAddress(), GetConnectionStatus(), aStatus);