From 1bd38aeaa14107ee4b8657214a51381e35753eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Ma=C5=82ecki?= Date: Wed, 3 Feb 2021 09:40:52 +0100 Subject: [PATCH 1/2] Prevented broken download from immediate exit --- apps/srt-file-transmit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/srt-file-transmit.cpp b/apps/srt-file-transmit.cpp index 521060cb5..71fd124f5 100644 --- a/apps/srt-file-transmit.cpp +++ b/apps/srt-file-transmit.cpp @@ -520,6 +520,8 @@ bool DoDownload(UriParser& us, string directory, string filename, status = srt_getsockstate(s); Verb() << "Event with status " << status << "\n"; + bool broken = false; + switch (status) { case SRTS_LISTENING: @@ -557,7 +559,12 @@ bool DoDownload(UriParser& us, string directory, string filename, } } break; + case SRTS_BROKEN: + cerr << "Connection closed, reading buffer remains\n"; + broken = true; + break; + case SRTS_NONEXIST: case SRTS_CLOSED: { From 01f4eb1d2d1642881e281e061338f6c446440931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Ma=C5=82ecki?= Date: Wed, 3 Feb 2021 09:58:38 +0100 Subject: [PATCH 2/2] Removed unused broken flag, added comment --- apps/srt-file-transmit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/srt-file-transmit.cpp b/apps/srt-file-transmit.cpp index 71fd124f5..5fb856c98 100644 --- a/apps/srt-file-transmit.cpp +++ b/apps/srt-file-transmit.cpp @@ -520,8 +520,6 @@ bool DoDownload(UriParser& us, string directory, string filename, status = srt_getsockstate(s); Verb() << "Event with status " << status << "\n"; - bool broken = false; - switch (status) { case SRTS_LISTENING: @@ -560,9 +558,11 @@ bool DoDownload(UriParser& us, string directory, string filename, } break; + // No need to do any special action in case of broken. + // The app will just try to read and in worst case it will + // get an error. case SRTS_BROKEN: cerr << "Connection closed, reading buffer remains\n"; - broken = true; break; case SRTS_NONEXIST: @@ -608,7 +608,7 @@ bool DoDownload(UriParser& us, string directory, string filename, if (n == 0) { result = true; - cerr << "Download COMPLETE."; + cerr << "Download COMPLETE.\n"; break; }