Browse Source

Added missing try-catch block in SctpTransport::handleUpcall()

Paul-Louis Ageneau 3 years ago
parent
commit
db776f050b
1 changed files with 16 additions and 11 deletions
  1. 16 11
      src/impl/sctptransport.cpp

+ 16 - 11
src/impl/sctptransport.cpp

@@ -701,21 +701,26 @@ void SctpTransport::sendReset(uint16_t streamId) {
 }
 
 void SctpTransport::handleUpcall() {
-	if (!mSock)
-		return;
+	try {
+		if (!mSock)
+			return;
 
-	PLOG_VERBOSE << "Handle upcall";
+		PLOG_VERBOSE << "Handle upcall";
 
-	int events = usrsctp_get_events(mSock);
+		int events = usrsctp_get_events(mSock);
 
-	if (events & SCTP_EVENT_READ && mPendingRecvCount == 0) {
-		++mPendingRecvCount;
-		mProcessor.enqueue(&SctpTransport::doRecv, shared_from_this());
-	}
+		if (events & SCTP_EVENT_READ && mPendingRecvCount == 0) {
+			++mPendingRecvCount;
+			mProcessor.enqueue(&SctpTransport::doRecv, shared_from_this());
+		}
+
+		if (events & SCTP_EVENT_WRITE && mPendingFlushCount == 0) {
+			++mPendingFlushCount;
+			mProcessor.enqueue(&SctpTransport::doFlush, shared_from_this());
+		}
 
-	if (events & SCTP_EVENT_WRITE && mPendingFlushCount == 0) {
-		++mPendingFlushCount;
-		mProcessor.enqueue(&SctpTransport::doFlush, shared_from_this());
+	} catch (const std::exception &e) {
+		PLOG_ERROR << "SCTP upcall: " << e.what();
 	}
 }