Added eof member to spdylay_data to indicate all data are read.
Ensure that if flags contains SPDYLAY_FLAG_FIN, only the last DATA frame has FLAG_FIN set.
This commit is contained in:
parent
d4ba423248
commit
b81b5a3116
|
@ -201,6 +201,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t stream_id;
|
int32_t stream_id;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
|
/* Initially eof is 0. It becomes 1 if all data are read. */
|
||||||
|
uint8_t eof;
|
||||||
spdylay_data_provider data_prd;
|
spdylay_data_provider data_prd;
|
||||||
} spdylay_data;
|
} spdylay_data;
|
||||||
|
|
||||||
|
|
|
@ -700,7 +700,10 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
|
||||||
if(type == SPDYLAY_DATA) {
|
if(type == SPDYLAY_DATA) {
|
||||||
if(session->callbacks.on_data_send_callback) {
|
if(session->callbacks.on_data_send_callback) {
|
||||||
session->callbacks.on_data_send_callback
|
session->callbacks.on_data_send_callback
|
||||||
(session, frame->data.flags, frame->data.stream_id,
|
(session,
|
||||||
|
frame->data.eof ? frame->data.flags :
|
||||||
|
(frame->data.flags & (~SPDYLAY_FLAG_FIN)),
|
||||||
|
frame->data.stream_id,
|
||||||
session->aob.framebuflen-SPDYLAY_HEAD_LEN, session->user_data);
|
session->aob.framebuflen-SPDYLAY_HEAD_LEN, session->user_data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -792,7 +795,7 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
|
||||||
is unreachable. */
|
is unreachable. */
|
||||||
abort();
|
abort();
|
||||||
case SPDYLAY_DATA:
|
case SPDYLAY_DATA:
|
||||||
if(frame->data.flags & SPDYLAY_FLAG_FIN) {
|
if(frame->data.eof && (frame->data.flags & SPDYLAY_FLAG_FIN)) {
|
||||||
spdylay_stream *stream =
|
spdylay_stream *stream =
|
||||||
spdylay_session_get_stream(session, frame->data.stream_id);
|
spdylay_session_get_stream(session, frame->data.stream_id);
|
||||||
if(stream) {
|
if(stream) {
|
||||||
|
@ -806,7 +809,7 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
|
||||||
int r;
|
int r;
|
||||||
/* If session is closed or RST_STREAM was queued, we won't send
|
/* If session is closed or RST_STREAM was queued, we won't send
|
||||||
further data. */
|
further data. */
|
||||||
if((frame->data.flags & SPDYLAY_FLAG_FIN) ||
|
if(frame->data.eof ||
|
||||||
!spdylay_session_is_data_allowed(session, frame->data.stream_id)) {
|
!spdylay_session_is_data_allowed(session, frame->data.stream_id)) {
|
||||||
spdylay_active_outbound_item_reset(&session->aob);
|
spdylay_active_outbound_item_reset(&session->aob);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1662,10 +1665,12 @@ ssize_t spdylay_session_pack_data_overwrite(spdylay_session *session,
|
||||||
spdylay_put_uint32be(&buf[0], frame->stream_id);
|
spdylay_put_uint32be(&buf[0], frame->stream_id);
|
||||||
spdylay_put_uint32be(&buf[4], r);
|
spdylay_put_uint32be(&buf[4], r);
|
||||||
if(eof) {
|
if(eof) {
|
||||||
flags |= SPDYLAY_FLAG_FIN;
|
frame->eof = 1;
|
||||||
|
if(frame->flags & SPDYLAY_FLAG_FIN) {
|
||||||
|
flags |= SPDYLAY_FLAG_FIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buf[4] = flags;
|
buf[4] = flags;
|
||||||
frame->flags = flags;
|
|
||||||
return r+8;
|
return r+8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue