[Pkg-voip-commits] [janus] 80/282: Better management of POLLERR errors in NoSIP plugin

Jonas Smedegaard dr at jones.dk
Wed Dec 20 21:53:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.6-1
in repository janus.

commit 636790a9e7381397ab8cbb0ed0275c8feb8bc7b8
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Tue Jun 27 12:55:56 2017 +0200

    Better management of POLLERR errors in NoSIP plugin
---
 plugins/janus_nosip.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/plugins/janus_nosip.c b/plugins/janus_nosip.c
index e00957f..02dc123 100644
--- a/plugins/janus_nosip.c
+++ b/plugins/janus_nosip.c
@@ -733,8 +733,8 @@ void janus_nosip_incoming_rtp(janus_plugin_session *handle, int video, char *buf
 				video ? "video" : "audio",
 				video ? session->media.video_ssrc : session->media.audio_ssrc);
 		}
-		if((video && session->media.has_video && session->media.video_rtp_fd) ||
-				(!video && session->media.has_audio && session->media.audio_rtp_fd)) {
+		if((video && session->media.has_video && session->media.video_rtp_fd != -1) ||
+				(!video && session->media.has_audio && session->media.audio_rtp_fd != -1)) {
 			/* Save the frame if we're recording */
 			janus_recorder_save_frame(video ? session->vrc : session->arc, buf, len);
 			/* Is SRTP involved? */
@@ -773,8 +773,8 @@ void janus_nosip_incoming_rtcp(janus_plugin_session *handle, int video, char *bu
 			return;
 		}
 		/* Forward to our NoSIP peer */
-		if((video && session->media.has_video && session->media.video_rtcp_fd) ||
-				(!video && session->media.has_audio && session->media.audio_rtcp_fd)) {
+		if((video && session->media.has_video && session->media.video_rtcp_fd != -1) ||
+				(!video && session->media.has_audio && session->media.audio_rtcp_fd != -1)) {
 			/* Fix SSRCs as the gateway does */
 			JANUS_LOG(LOG_HUGE, "[NoSIP-%p] Fixing %s SSRCs (local %u, peer %u)\n",
 				session, video ? "video" : "audio",
@@ -1781,15 +1781,35 @@ static void *janus_nosip_relay_thread(void *data) {
 		int i = 0;
 		for(i=0; i<num; i++) {
 			if(fds[i].revents & (POLLERR | POLLHUP)) {
+				/* If we just updated the session, let's wait until things have calmed down */
 				if(session->media.updated)
 					break;
-				/* Socket error? */
-				JANUS_LOG((errno == 0 ? LOG_WARN : LOG_ERR), "[NoSIP-%p] Error polling: %s... errno=%d (%s)\n",
-					session, fds[i].revents & POLLERR ? "POLLERR" : "POLLHUP", errno, strerror(errno));
-				if(errno == 0) {
-					/* Maybe not a breaking error? */
+				/* Check the socket error */
+				int error = 0;
+				socklen_t errlen = sizeof(error);
+				getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen);
+				if(error == 0) {
+					/* Maybe not a breaking error after all? */
+					continue;
+				} else if(error == 111) {
+					/* ICMP error? If it's related to RTCP, let's just close the RTCP socket and move on */
+					if(fds[i].fd == session->media.audio_rtcp_fd) {
+						JANUS_LOG(LOG_WARN, "[NoSIP-%p] Got a '%s' on the audio RTCP socket, closing it\n",
+							session, strerror(error));
+						close(session->media.audio_rtcp_fd);
+						session->media.audio_rtcp_fd = -1;
+					} else if(fds[i].fd == session->media.video_rtcp_fd) {
+						JANUS_LOG(LOG_WARN, "[NoSIP-%p] Got a '%s' on the video RTCP socket, closing it\n",
+							session, strerror(error));
+						close(session->media.video_rtcp_fd);
+						session->media.video_rtcp_fd = -1;
+					}
+					/* FIXME Should we do the same with the RTP sockets as well? We may risk overreacting, there... */
 					continue;
 				}
+				JANUS_LOG(LOG_ERR, "[NoSIP-%p] Error polling %d (socket #%d): %s...\n", session,
+					fds[i].fd, i, fds[i].revents & POLLERR ? "POLLERR" : "POLLHUP");
+				JANUS_LOG(LOG_ERR, "[NoSIP-%p]   -- %d (%s)\n", session, error, strerror(error));
 				/* Can we assume it's pretty much over, after a POLLERR? */
 				goon = FALSE;
 				/* FIXME Close the PeerConnection */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list