diff options
Diffstat (limited to 'src/microspdy/session.c')
-rw-r--r-- | src/microspdy/session.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/microspdy/session.c b/src/microspdy/session.c index 6374201d..4a6d8525 100644 --- a/src/microspdy/session.c +++ b/src/microspdy/session.c | |||
@@ -129,7 +129,7 @@ spdyf_handler_read_syn_stream (struct SPDY_Session *session) | |||
129 | if(0 == name_value_strm_size || 0 == compressed_data_size) | 129 | if(0 == name_value_strm_size || 0 == compressed_data_size) |
130 | { | 130 | { |
131 | //Protocol error: send RST_STREAM | 131 | //Protocol error: send RST_STREAM |
132 | if(SPDY_YES != SPDYF_prepare_rst_stream(session, session->current_stream_id, | 132 | if(SPDY_YES != SPDYF_prepare_rst_stream(session, session->streams_head, |
133 | SPDY_RST_STREAM_STATUS_PROTOCOL_ERROR)) | 133 | SPDY_RST_STREAM_STATUS_PROTOCOL_ERROR)) |
134 | { | 134 | { |
135 | //no memory, try later to send RST | 135 | //no memory, try later to send RST |
@@ -571,11 +571,22 @@ SPDYF_handler_write_data (struct SPDY_Session *session) | |||
571 | 571 | ||
572 | if(ret < 0 || ret > response_queue->response->rcb_block_size) | 572 | if(ret < 0 || ret > response_queue->response->rcb_block_size) |
573 | { | 573 | { |
574 | //TODO send RST_STREAM (app error) | 574 | free(session->write_buffer); |
575 | session->write_buffer = NULL; | ||
576 | |||
577 | //send RST_STREAM | ||
578 | if(SPDY_YES == (ret = SPDYF_prepare_rst_stream(session, | ||
579 | response_queue->stream, | ||
580 | SPDY_RST_STREAM_STATUS_INTERNAL_ERROR))) | ||
581 | { | ||
582 | return SPDY_NO; | ||
583 | } | ||
584 | |||
585 | //else no memory | ||
575 | //for now close session | 586 | //for now close session |
587 | //TODO what? | ||
576 | session->status = SPDY_SESSION_STATUS_CLOSING; | 588 | session->status = SPDY_SESSION_STATUS_CLOSING; |
577 | 589 | ||
578 | free(session->write_buffer); | ||
579 | return SPDY_NO; | 590 | return SPDY_NO; |
580 | } | 591 | } |
581 | if(0 == ret && more) | 592 | if(0 == ret && more) |
@@ -619,6 +630,7 @@ SPDYF_handler_write_data (struct SPDY_Session *session) | |||
619 | session->status = SPDY_SESSION_STATUS_CLOSING; | 630 | session->status = SPDY_SESSION_STATUS_CLOSING; |
620 | 631 | ||
621 | free(session->write_buffer); | 632 | free(session->write_buffer); |
633 | session->write_buffer = NULL; | ||
622 | return SPDY_NO; | 634 | return SPDY_NO; |
623 | } | 635 | } |
624 | 636 | ||
@@ -992,7 +1004,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) | |||
992 | if(session->write_buffer_beginning == session->write_buffer_size) | 1004 | if(session->write_buffer_beginning == session->write_buffer_size) |
993 | { | 1005 | { |
994 | //that response is handled, remove it from queue | 1006 | //that response is handled, remove it from queue |
995 | free(session->write_buffer); | 1007 | free(session->write_buffer); |
996 | session->write_buffer = NULL; | 1008 | session->write_buffer = NULL; |
997 | session->write_buffer_size = 0; | 1009 | session->write_buffer_size = 0; |
998 | queue_head = session->response_queue_head; | 1010 | queue_head = session->response_queue_head; |
@@ -1175,7 +1187,7 @@ SPDYF_session_idle (struct SPDY_Session *session) | |||
1175 | session->read_buffer_beginning = session->read_buffer_offset; | 1187 | session->read_buffer_beginning = session->read_buffer_offset; |
1176 | 1188 | ||
1177 | SPDYF_prepare_rst_stream(session, | 1189 | SPDYF_prepare_rst_stream(session, |
1178 | session->current_stream_id, //may be 0 here which is not good | 1190 | session->current_stream_id > 0 ? session->streams_head : NULL, //may be 0 here which is not good |
1179 | SPDY_RST_STREAM_STATUS_FRAME_TOO_LARGE); | 1191 | SPDY_RST_STREAM_STATUS_FRAME_TOO_LARGE); |
1180 | 1192 | ||
1181 | //actually the read buffer can be bigger than the | 1193 | //actually the read buffer can be bigger than the |
@@ -1541,13 +1553,19 @@ SPDYF_prepare_goaway (struct SPDY_Session *session, | |||
1541 | 1553 | ||
1542 | int | 1554 | int |
1543 | SPDYF_prepare_rst_stream (struct SPDY_Session *session, | 1555 | SPDYF_prepare_rst_stream (struct SPDY_Session *session, |
1544 | uint32_t stream_id, | 1556 | struct SPDYF_Stream * stream, |
1545 | enum SPDY_RST_STREAM_STATUS status) | 1557 | enum SPDY_RST_STREAM_STATUS status) |
1546 | { | 1558 | { |
1547 | struct SPDYF_Response_Queue *response_to_queue; | 1559 | struct SPDYF_Response_Queue *response_to_queue; |
1548 | struct SPDYF_Control_Frame *control_frame; | 1560 | struct SPDYF_Control_Frame *control_frame; |
1549 | uint32_t *data; | 1561 | uint32_t *data; |
1562 | uint32_t stream_id; | ||
1550 | 1563 | ||
1564 | if(NULL == stream) | ||
1565 | stream_id = 0; | ||
1566 | else | ||
1567 | stream_id = stream->stream_id; | ||
1568 | |||
1551 | if(NULL == (response_to_queue = malloc(sizeof(struct SPDYF_Response_Queue)))) | 1569 | if(NULL == (response_to_queue = malloc(sizeof(struct SPDYF_Response_Queue)))) |
1552 | { | 1570 | { |
1553 | return SPDY_NO; | 1571 | return SPDY_NO; |
@@ -1579,6 +1597,7 @@ SPDYF_prepare_rst_stream (struct SPDY_Session *session, | |||
1579 | response_to_queue->process_response_handler = &SPDYF_handler_write_rst_stream; | 1597 | response_to_queue->process_response_handler = &SPDYF_handler_write_rst_stream; |
1580 | response_to_queue->data = data; | 1598 | response_to_queue->data = data; |
1581 | response_to_queue->data_size = 8; | 1599 | response_to_queue->data_size = 8; |
1600 | response_to_queue->stream = stream; | ||
1582 | 1601 | ||
1583 | SPDYF_queue_response (response_to_queue, | 1602 | SPDYF_queue_response (response_to_queue, |
1584 | session, | 1603 | session, |