mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1046109: Add |SocketIOShutdownTask|, r=kyle
|SocketIOShutdownTask| invokes the shutdown procedure for Socket I/O objects on the I/O thread.
This commit is contained in:
parent
e57e07d8d1
commit
ae46aec1d3
@ -488,6 +488,36 @@ private:
|
||||
UnixSocketRawData* mData;
|
||||
};
|
||||
|
||||
/* |SocketIOShutdownTask| signals shutdown to the Socket I/O object on
|
||||
* the I/O thread and sends it to the main thread for destruction.
|
||||
*/
|
||||
template <typename T>
|
||||
class SocketIOShutdownTask MOZ_FINAL : public SocketIOTask<T>
|
||||
{
|
||||
public:
|
||||
SocketIOShutdownTask(T* aIO)
|
||||
: SocketIOTask<T>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
T* io = SocketIOTask<T>::GetIO();
|
||||
|
||||
// At this point, there should be no new events on the I/O thread
|
||||
// after this one with the possible exception of an accept task,
|
||||
// which ShutdownOnIOThread will cancel for us. We are now fully
|
||||
// shut down, so we can send a message to the main thread to delete
|
||||
// |io| safely knowing that it's not reference any longer.
|
||||
io->ShutdownOnIOThread();
|
||||
|
||||
nsRefPtr<nsRunnable> r = new SocketIODeleteInstanceRunnable<T>(io);
|
||||
nsresult rv = NS_DispatchToMainThread(r);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,34 +227,6 @@ 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()
|
||||
{
|
||||
@ -551,8 +523,8 @@ UnixSocketConsumer::CloseSocket()
|
||||
// will create a new implementation.
|
||||
mImpl->ShutdownOnMainThread();
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
||||
new ShutdownSocketTask(mImpl));
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE, new SocketIOShutdownTask<UnixSocketImpl>(mImpl));
|
||||
|
||||
mImpl = nullptr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user