commit 875b3a46e64c8fc1e1abe9ff21bcbe6167051ee6
parent 1dd7407a41ae3cd05f735c744724d9978fd53a21
Author: Joris Vink <joris@coders.se>
Date: Fri, 15 May 2015 19:17:09 +0200
SPDY stream changes.
Allow callers to set an onclose callback method for SPDY streams
so they can get notified when a stream is closed.
Also add SPDY_NO_CLOSE which tells the underlying Kore layer
to not send a FIN for a SPDY stream until a module does it itself.
Diffstat:
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/includes/spdy.h b/includes/spdy.h
@@ -23,6 +23,11 @@
#if defined(__cplusplus)
extern "C" {
#endif
+
+/* XXX */
+struct connection;
+struct http_request;
+
struct spdy_ctrl_frame {
u_int16_t version;
u_int16_t type;
@@ -60,10 +65,10 @@ struct spdy_stream {
u_int32_t frame_size;
u_int32_t recv_wsize;
u_int32_t send_wsize;
+ void (*onclose)(struct connection *, struct spdy_stream *);
- void *httpreq;
+ struct http_request *httpreq;
struct spdy_header_block *hblock;
-
TAILQ_ENTRY(spdy_stream) list;
};
@@ -119,6 +124,7 @@ extern const unsigned char SPDY_dictionary_txt[];
/* internal flags (make sure they don't clash with SPDY stream flags) */
#define SPDY_KORE_FIN 0x10
#define SPDY_DATAFRAME_PRELUDE 0x20
+#define SPDY_NO_CLOSE 0x40
#define SPDY_KEEP_NETBUFS 0
#define SPDY_REMOVE_NETBUFS 1
diff --git a/src/spdy.c b/src/spdy.c
@@ -414,7 +414,7 @@ spdy_update_wsize(struct connection *c, struct spdy_stream *s, u_int32_t len)
s->flags |= SPDY_DATAFRAME_PRELUDE;
}
- if (s->send_size == 0) {
+ if (s->send_size == 0 && !(s->flags & SPDY_NO_CLOSE)) {
if (!(s->flags & SPDY_KORE_FIN)) {
s->flags |= SPDY_KORE_FIN;
kore_debug("sending final frame %u", s->stream_id);
@@ -443,6 +443,9 @@ spdy_stream_close(struct connection *c, struct spdy_stream *s, int rb)
kore_debug("spdy_stream_close(%p, %p) <%d>", c, s, s->stream_id);
+ if (s->onclose != NULL)
+ s->onclose(c, s);
+
if (rb) {
for (nb = TAILQ_FIRST(&(c->send_queue)); nb != NULL; nb = nt) {
nt = TAILQ_NEXT(nb, list);
@@ -525,6 +528,7 @@ spdy_ctrl_frame_syn_stream(struct netbuf *nb)
s->send_size = 0;
s->frame_size = 0;
s->httpreq = NULL;
+ s->onclose = NULL;
s->prio = syn.prio;
s->flags = ctrl.flags;
s->recv_wsize = spdy_recv_wsize;