[vlc-commits] http: don't try to re-open connection if it previously failed

Thomas Guillem git at videolan.org
Sat Apr 2 15:48:43 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Mar 30 09:44:44 2016 +0200| [86502818041d7b07985ef59e79d862a075443758] | committer: Rémi Denis-Courmont

http: don't try to re-open connection if it previously failed

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=86502818041d7b07985ef59e79d862a075443758
---

 modules/access/http/file.c |    7 +++++++
 modules/access/http/live.c |    7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/modules/access/http/file.c b/modules/access/http/file.c
index 5695c7f..542e6a3 100644
--- a/modules/access/http/file.c
+++ b/modules/access/http/file.c
@@ -44,6 +44,7 @@ struct vlc_http_file
     struct vlc_http_resource resource;
     struct vlc_http_msg *resp;
     uintmax_t offset;
+    bool failed;
 };
 
 static int vlc_http_file_req(struct vlc_http_msg *req,
@@ -132,6 +133,7 @@ struct vlc_http_file *vlc_http_file_create(struct vlc_http_mgr *mgr,
 
     file->resp = NULL;
     file->offset = 0;
+    file->failed = false;
     return file;
 }
 
@@ -139,9 +141,14 @@ int vlc_http_file_get_status(struct vlc_http_file *file)
 {
     if (file->resp == NULL)
     {
+        if (file->failed)
+            return -1;
         file->resp = vlc_http_file_open(file, file->offset);
         if (file->resp == NULL)
+        {
+            file->failed = true;
             return -1;
+        }
     }
     return vlc_http_msg_get_status(file->resp);
 }
diff --git a/modules/access/http/live.c b/modules/access/http/live.c
index a1f44cd..8a620e8 100644
--- a/modules/access/http/live.c
+++ b/modules/access/http/live.c
@@ -35,6 +35,7 @@ struct vlc_http_live
 {
     struct vlc_http_resource resource;
     struct vlc_http_msg *resp;
+    bool failed;
 };
 
 static int vlc_http_live_req(struct vlc_http_msg *req,
@@ -74,6 +75,7 @@ struct vlc_http_live *vlc_http_live_create(struct vlc_http_mgr *mgr,
     }
 
     live->resp = NULL;
+    live->failed = false;
     return live;
 }
 
@@ -81,9 +83,14 @@ int vlc_http_live_get_status(struct vlc_http_live *live)
 {
     if (live->resp == NULL)
     {
+        if (live->failed)
+            return -1;
         live->resp = vlc_http_live_open(live);
         if (live->resp == NULL)
+        {
+            live->failed = true;
             return -1;
+        }
     }
     return vlc_http_msg_get_status(live->resp);
 }



More information about the vlc-commits mailing list