forked from mirrors/kore
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.
This commit is contained in:
parent
1dd7407a41
commit
875b3a46e6
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue