Skip to content

Commit 4d0e984

Browse files
Mikolaj Maleckicl-ment
authored andcommitted
[core] Fixed accidental blocking on sendmsg call
1 parent 0976f76 commit 4d0e984

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

srtcore/channel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ void srt::CChannel::setUDPSockOpt()
552552
// Set receiving time-out value
553553
if (-1 == ::setsockopt(m_iSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(timeval)))
554554
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
555+
// Set sending time-out, too; O_NONBLOCK sets it in both directions,
556+
// so both should be also set here for consistency.
557+
if (-1 == ::setsockopt(m_iSocket, SOL_SOCKET, SO_SNDTIMEO, (char*)&tv, sizeof(timeval)))
558+
throw CUDTException(MJ_SETUP, MN_NORES, NET_ERROR);
555559
#endif
556560

557561
#ifdef SRT_ENABLE_PKTINFO

srtcore/core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8358,6 +8358,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
83588358
{
83598359
ctrlpkt.pack(UMSG_ACK, &m_iAckSeqNo, data, ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_SMALL);
83608360
}
8361+
bufflock.unlock();
83618362

83628363
ctrlpkt.set_id(m_PeerID);
83638364
setPacketTS(ctrlpkt, steady_clock::now());

0 commit comments

Comments
 (0)