From 6e45224b000231e6b9a70b6cca7e67462e552506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Date: Sat, 29 Sep 2007 11:17:57 +0000 Subject: [PATCH] Clean up of semi-opened socket and error handling of failed open -call. --- protocolhttp.c | 11 ++++++++--- streamer.c | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/protocolhttp.c b/protocolhttp.c index 1a499f0..705d29f 100644 --- a/protocolhttp.c +++ b/protocolhttp.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocolhttp.c,v 1.7 2007/09/29 10:55:14 ajhseppa Exp $ + * $Id: protocolhttp.c,v 1.8 2007/09/29 11:17:57 ajhseppa Exp $ */ #include @@ -137,6 +137,7 @@ bool cIptvProtocolHttp::Connect(void) if (err < 0 && errno != EINPROGRESS) { char tmp[64]; error("ERROR: Connect(): %s", strerror_r(errno, tmp, sizeof(tmp))); + CloseSocket(); return false; } @@ -166,6 +167,7 @@ bool cIptvProtocolHttp::Connect(void) error("Cannot connect to %s\n", streamAddr); char tmp[64]; error("ERROR: %s", strerror_r(socketStatus, tmp, sizeof(tmp))); + CloseSocket(); return false; } @@ -185,12 +187,15 @@ bool cIptvProtocolHttp::Connect(void) if (err < 0) { char tmp[64]; error("ERROR: send(): %s", strerror_r(errno, tmp, sizeof(tmp))); + CloseSocket(); return false; } // Now process headers - if (!ProcessHeaders()) - return false; + if (!ProcessHeaders()) { + CloseSocket(); + return false; + } // Update active flag isActive = true; diff --git a/streamer.c b/streamer.c index 5b27af6..364052f 100644 --- a/streamer.c +++ b/streamer.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: streamer.c,v 1.14 2007/09/21 21:50:52 rahrenbe Exp $ + * $Id: streamer.c,v 1.15 2007/09/29 11:17:57 ajhseppa Exp $ */ #include @@ -57,7 +57,8 @@ bool cIptvStreamer::Open(void) debug("cIptvStreamer::Open()\n"); // Open the protocol if (protocol) - protocol->Open(); + if(!protocol->Open()) + return false; // Start thread Start(); return true;