Bug 807109: Turn off SO_LINGER for SCTP sockets in DataChannels r=ekr

This commit is contained in:
Randell Jesup 2012-10-31 20:31:39 -04:00
parent 9e0a39679d
commit 7e835b7ab1

View File

@ -145,6 +145,7 @@ DataChannelConnection::~DataChannelConnection()
// if we really want it to do true clean shutdowns it can
// create a dependant Internal object that would remain around
// until the network shut down the association or timed out.
LOG(("Destroying DataChannelConnection"));
CloseAll();
if (mSocket && mSocket != mMasterSocket)
usrsctp_close(mSocket);
@ -211,6 +212,16 @@ DataChannelConnection::Init(unsigned short aPort, uint16_t aNumStreams, bool aUs
return false;
}
// Make sure when we close the socket, make sure it doesn't call us back again!
// This would cause it try to use an invalid DataChannelConnection pointer
struct linger l;
l.l_onoff = 1;
l.l_linger = 0;
if (usrsctp_setsockopt(mMasterSocket, SOL_SOCKET, SO_LINGER,
(const void *)&l, (socklen_t)sizeof(struct linger)) < 0) {
LOG(("Couldn't set SO_LINGER on SCTP socket"));
}
if (!aUsingDtls) {
memset(&encaps, 0, sizeof(encaps));
encaps.sue_address.ss_family = AF_INET;
@ -475,6 +486,14 @@ DataChannelConnection::Listen(unsigned short port)
}
mState = OPEN;
struct linger l;
l.l_onoff = 1;
l.l_linger = 0;
if (usrsctp_setsockopt(mSocket, SOL_SOCKET, SO_LINGER,
(const void *)&l, (socklen_t)sizeof(struct linger)) < 0) {
LOG(("Couldn't set SO_LINGER on SCTP socket"));
}
// Notify Connection open
// XXX We need to make sure connection sticks around until the message is delivered
LOG(("%s: sending ON_CONNECTION for %p", __FUNCTION__, this));