mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 806169: proxy all SendPackets to the STS thread r=ekr
This commit is contained in:
parent
087ca217a9
commit
74619f08cf
@ -190,6 +190,12 @@ DataChannelConnection::Init(unsigned short aPort, uint16_t aNumStreams, bool aUs
|
||||
gDataChannelShutdown->Init();
|
||||
}
|
||||
}
|
||||
// XXX FIX! make this a global we get once
|
||||
// Find the STS thread
|
||||
|
||||
nsresult res;
|
||||
mSTS = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(res));
|
||||
|
||||
// Open sctp association across tunnel
|
||||
if ((mMasterSocket = usrsctp_socket(
|
||||
@ -394,7 +400,6 @@ DataChannelConnection::PacketReceived(TransportFlow *flow,
|
||||
usrsctp_conninput(static_cast<void *>(this), data, len, 0);
|
||||
}
|
||||
|
||||
// XXX Merge with SctpDtlsOutput?
|
||||
int
|
||||
DataChannelConnection::SendPacket(const unsigned char *data, size_t len)
|
||||
{
|
||||
@ -408,8 +413,21 @@ DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length,
|
||||
uint8_t tos, uint8_t set_df)
|
||||
{
|
||||
DataChannelConnection *peer = static_cast<DataChannelConnection *>(addr);
|
||||
int res;
|
||||
|
||||
return peer->SendPacket(static_cast<unsigned char *>(buffer), length);
|
||||
if (peer->IsSTSThread()) {
|
||||
res = peer->SendPacket(static_cast<unsigned char *>(buffer), length);
|
||||
} else {
|
||||
res = -1;
|
||||
// XXX It might be worthwhile to add an assertion against the thread
|
||||
// somehow getting into the DataChannel/SCTP code again, as
|
||||
// DISPATCH_SYNC is not fully blocking. This may be tricky, as it
|
||||
// needs to be a per-thread check, not a global.
|
||||
peer->mSTS->Dispatch(WrapRunnableRet(
|
||||
peer, &DataChannelConnection::SendPacket, static_cast<unsigned char *>(buffer), length, &res
|
||||
), NS_DISPATCH_SYNC);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -216,6 +216,16 @@ private:
|
||||
void HandleStreamChangeEvent(const struct sctp_stream_change_event *strchg);
|
||||
void HandleNotification(const union sctp_notification *notif, size_t n);
|
||||
|
||||
#ifdef SCTP_DTLS_SUPPORTED
|
||||
bool IsSTSThread() {
|
||||
bool on = false;
|
||||
if (mSTS) {
|
||||
mSTS->IsOnCurrentThread(&on);
|
||||
}
|
||||
return on;
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: while these arrays will auto-expand, increases in the number of
|
||||
// channels available from the stack must be negotiated!
|
||||
nsAutoTArray<DataChannel*,16> mStreamsOut;
|
||||
@ -231,6 +241,7 @@ private:
|
||||
|
||||
#ifdef SCTP_DTLS_SUPPORTED
|
||||
nsRefPtr<TransportFlow> mTransportFlow;
|
||||
nsCOMPtr<nsIEventTarget> mSTS;
|
||||
#endif
|
||||
uint16_t mLocalPort;
|
||||
uint16_t mRemotePort;
|
||||
|
Loading…
Reference in New Issue
Block a user