Backed out changeset b20b097fde99 (bug 1046109)

This commit is contained in:
Carsten "Tomcat" Book
2014-07-31 10:14:21 +02:00
parent dc3769a467
commit 8814937a50
2 changed files with 30 additions and 32 deletions

View File

@@ -227,6 +227,34 @@ public:
}
};
class ShutdownSocketTask : public SocketIOTask<UnixSocketImpl>
{
public:
ShutdownSocketTask(UnixSocketImpl* aImpl)
: SocketIOTask<UnixSocketImpl>(aImpl)
{ }
void Run() MOZ_OVERRIDE
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsCanceled());
UnixSocketImpl* impl = GetIO();
// At this point, there should be no new events on the IO thread after this
// one with the possible exception of a SocketListenTask that
// ShutdownOnIOThread will cancel for us. We are now fully shut down, so we
// can send a message to the main thread that will delete impl safely knowing
// that no more tasks reference it.
impl->ShutdownOnIOThread();
nsRefPtr<nsIRunnable> r =
new SocketIODeleteInstanceRunnable<UnixSocketImpl>(impl);
nsresult rv = NS_DispatchToMainThread(r);
NS_ENSURE_SUCCESS_VOID(rv);
}
};
void
UnixSocketImpl::FireSocketError()
{
@@ -523,8 +551,8 @@ UnixSocketConsumer::CloseSocket()
// will create a new implementation.
mImpl->ShutdownOnMainThread();
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE, new SocketIOShutdownTask<UnixSocketImpl>(mImpl));
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
new ShutdownSocketTask(mImpl));
mImpl = nullptr;