[vlc-commits] https: add abort parameter to vlc_http_stream_close()

Rémi Denis-Courmont git at videolan.org
Wed Dec 16 21:31:19 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Dec 15 22:36:00 2015 +0200| [e47095014052d6b5df00a51f08d755286b8edb84] | committer: Rémi Denis-Courmont

https: add abort parameter to vlc_http_stream_close()

This is used to distinguish abortive stream termination from normal
clean termination. This is mostly useful for HTTP/1.

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

 modules/access/http/connmgr.c     |    4 ++--
 modules/access/http/file_test.c   |    3 ++-
 modules/access/http/h2conn.c      |    4 ++--
 modules/access/http/h2conn_test.c |    4 ++--
 modules/access/http/message.c     |    2 +-
 modules/access/http/message.h     |    6 +++---
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index 204e014..18fe129 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -120,7 +120,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr,
             if (m != NULL)
                 return m;
 
-            vlc_http_stream_close(s);
+            vlc_http_stream_close(s, false);
             /* NOTE: If the request were not idempotent, NULL should be
              * returned here. POST is not used/supported so far, and CONNECT is
              * treated as if it were idempotent (which turns out OK here). */
@@ -141,7 +141,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr,
             if (m != NULL)
                 return m;
 
-            vlc_http_stream_close(s);
+            vlc_http_stream_close(s, false);
         }
         vlc_h1_conn_release(conn1);
 #endif
diff --git a/modules/access/http/file_test.c b/modules/access/http/file_test.c
index e591b87..a5302c1 100644
--- a/modules/access/http/file_test.c
+++ b/modules/access/http/file_test.c
@@ -191,9 +191,10 @@ static struct block_t *stream_read(struct vlc_http_stream *s)
     return NULL;
 }
 
-static void stream_close(struct vlc_http_stream *s)
+static void stream_close(struct vlc_http_stream *s, bool abort)
 {
     assert(s == &stream);
+    assert(!abort);
 }
 
 static const struct vlc_http_stream_cbs stream_callbacks =
diff --git a/modules/access/http/h2conn.c b/modules/access/http/h2conn.c
index a206e1b..38f8160 100644
--- a/modules/access/http/h2conn.c
+++ b/modules/access/http/h2conn.c
@@ -304,7 +304,7 @@ static block_t *vlc_h2_stream_read(struct vlc_http_stream *stream)
  * Sends an HTTP/2 stream reset, removes the stream from the HTTP/2 connection
  * and deletes any stream resource.
  */
-static void vlc_h2_stream_close(struct vlc_http_stream *stream)
+static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool abort)
 {
     struct vlc_h2_stream *s = (struct vlc_h2_stream *)stream;
     struct vlc_h2_conn *conn = s->conn;
@@ -323,7 +323,7 @@ static void vlc_h2_stream_close(struct vlc_http_stream *stream)
     }
     vlc_mutex_unlock(&conn->lock);
 
-    vlc_h2_stream_error(conn, s->id, VLC_H2_NO_ERROR);
+    vlc_h2_stream_error(conn, s->id, abort ? VLC_H2_CANCEL : VLC_H2_NO_ERROR);
 
     if (s->recv_hdr != NULL)
         vlc_http_msg_destroy(s->recv_hdr);
diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c
index 331ab7d..6b77bb0 100644
--- a/modules/access/http/h2conn_test.c
+++ b/modules/access/http/h2conn_test.c
@@ -156,7 +156,7 @@ int main(void)
     assert(m == NULL);
     b = vlc_http_stream_read(s);
     assert(b == NULL);
-    vlc_http_stream_close(s);
+    vlc_http_stream_close(s, false);
 
     /* Test accepted stream */
     sid += 2;
@@ -245,7 +245,7 @@ int main(void)
 
     /* Test releasing connection before stream */
     conn_destroy();
-    vlc_http_stream_close(s);
+    vlc_http_stream_close(s, false);
 
     return 0;
 }
diff --git a/modules/access/http/message.c b/modules/access/http/message.c
index e7f5853..e7edb0e 100644
--- a/modules/access/http/message.c
+++ b/modules/access/http/message.c
@@ -139,7 +139,7 @@ const char *vlc_http_msg_get_path(const struct vlc_http_msg *m)
 void vlc_http_msg_destroy(struct vlc_http_msg *m)
 {
     if (m->payload != NULL)
-        vlc_http_stream_close(m->payload);
+        vlc_http_stream_close(m->payload, false);
 
     for (unsigned i = 0; i < m->count; i++)
     {
diff --git a/modules/access/http/message.h b/modules/access/http/message.h
index 93be452..1444b2b 100644
--- a/modules/access/http/message.h
+++ b/modules/access/http/message.h
@@ -200,7 +200,7 @@ struct vlc_http_stream_cbs
 {
     struct vlc_http_msg *(*read_headers)(struct vlc_http_stream *);
     struct block_t *(*read)(struct vlc_http_stream *);
-    void (*close)(struct vlc_http_stream *);
+    void (*close)(struct vlc_http_stream *, bool abort);
 };
 
 struct vlc_http_stream
@@ -219,9 +219,9 @@ static inline struct block_t *vlc_http_stream_read(struct vlc_http_stream *s)
     return s->cbs->read(s);
 }
 
-static inline void vlc_http_stream_close(struct vlc_http_stream *s)
+static inline void vlc_http_stream_close(struct vlc_http_stream *s, bool abort)
 {
-    s->cbs->close(s);
+    s->cbs->close(s, abort);
 }
 
 char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *) VLC_USED;



More information about the vlc-commits mailing list