diff options
Diffstat (limited to 'src/microspdy/session.c')
-rw-r--r-- | src/microspdy/session.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/microspdy/session.c b/src/microspdy/session.c index 918b9fdf..131d3106 100644 --- a/src/microspdy/session.c +++ b/src/microspdy/session.c | |||
@@ -159,6 +159,8 @@ spdyf_handler_read_syn_stream (struct SPDY_Session *session) | |||
159 | free(name_value_strm); | 159 | free(name_value_strm); |
160 | } | 160 | } |
161 | 161 | ||
162 | //SPDYF_DEBUG("syn_stream received: id %i", session->current_stream_id); | ||
163 | |||
162 | //change state to wait for new frame | 164 | //change state to wait for new frame |
163 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; | 165 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; |
164 | free(frame); | 166 | free(frame); |
@@ -235,6 +237,8 @@ spdyf_handler_read_goaway (struct SPDY_Session *session) | |||
235 | case SPDY_GOAWAY_STATUS_INTERNAL_ERROR: | 237 | case SPDY_GOAWAY_STATUS_INTERNAL_ERROR: |
236 | break; | 238 | break; |
237 | } | 239 | } |
240 | |||
241 | //SPDYF_DEBUG("goaway received: status %i", status); | ||
238 | } | 242 | } |
239 | 243 | ||
240 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; | 244 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; |
@@ -256,7 +260,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) | |||
256 | struct SPDYF_Control_Frame *frame; | 260 | struct SPDYF_Control_Frame *frame; |
257 | uint32_t stream_id; | 261 | uint32_t stream_id; |
258 | int32_t status_int; | 262 | int32_t status_int; |
259 | enum SPDY_RST_STREAM_STATUS status; | 263 | //enum SPDY_RST_STREAM_STATUS status; //for debug |
260 | struct SPDYF_Stream *stream; | 264 | struct SPDYF_Stream *stream; |
261 | 265 | ||
262 | SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status, | 266 | SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status, |
@@ -285,7 +289,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) | |||
285 | session->read_buffer_beginning += 4; | 289 | session->read_buffer_beginning += 4; |
286 | 290 | ||
287 | memcpy(&status_int, session->read_buffer + session->read_buffer_beginning, 4); | 291 | memcpy(&status_int, session->read_buffer + session->read_buffer_beginning, 4); |
288 | status = ntohl(status_int); | 292 | //status = ntohl(status_int); //for debug |
289 | session->read_buffer_beginning += 4; | 293 | session->read_buffer_beginning += 4; |
290 | 294 | ||
291 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; | 295 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; |
@@ -304,7 +308,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) | |||
304 | stream = stream->next; | 308 | stream = stream->next; |
305 | } | 309 | } |
306 | 310 | ||
307 | SPDYF_DEBUG("Received RST_STREAM; status=%i; id=%i",status,stream_id); | 311 | //SPDYF_DEBUG("Received RST_STREAM; status=%i; id=%i",status,stream_id); |
308 | 312 | ||
309 | //do something according to the status | 313 | //do something according to the status |
310 | //TODO | 314 | //TODO |
@@ -361,9 +365,7 @@ spdyf_handler_read_data (struct SPDY_Session *session) | |||
361 | if(NULL == stream || stream->is_in_closed || NULL == session->daemon->received_data_cb) | 365 | if(NULL == stream || stream->is_in_closed || NULL == session->daemon->received_data_cb) |
362 | { | 366 | { |
363 | if(NULL == session->daemon->received_data_cb) | 367 | if(NULL == session->daemon->received_data_cb) |
364 | SPDYF_DEBUG("No callback for DATA frame set"); | 368 | SPDYF_DEBUG("No callback for DATA frame set; Ignoring DATA frame!"); |
365 | |||
366 | SPDYF_DEBUG("Ignoring DATA frame!"); | ||
367 | 369 | ||
368 | //TODO send error? | 370 | //TODO send error? |
369 | 371 | ||
@@ -405,6 +407,9 @@ spdyf_handler_read_data (struct SPDY_Session *session) | |||
405 | } | 407 | } |
406 | //else: do it later | 408 | //else: do it later |
407 | } | 409 | } |
410 | |||
411 | //SPDYF_DEBUG("data received: id %i", frame->stream_id); | ||
412 | |||
408 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; | 413 | session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; |
409 | free(frame); | 414 | free(frame); |
410 | } | 415 | } |
@@ -499,6 +504,8 @@ SPDYF_handler_write_syn_reply (struct SPDY_Session *session) | |||
499 | free(compressed_headers); | 504 | free(compressed_headers); |
500 | 505 | ||
501 | session->last_replied_to_stream_id = stream->stream_id; | 506 | session->last_replied_to_stream_id = stream->stream_id; |
507 | |||
508 | //SPDYF_DEBUG("syn_reply sent: id %i", stream->stream_id); | ||
502 | 509 | ||
503 | return SPDY_YES; | 510 | return SPDY_YES; |
504 | } | 511 | } |
@@ -548,6 +555,8 @@ SPDYF_handler_write_goaway (struct SPDY_Session *session) | |||
548 | //data is not freed by the destroy function so: | 555 | //data is not freed by the destroy function so: |
549 | //free(response_queue->data); | 556 | //free(response_queue->data); |
550 | 557 | ||
558 | //SPDYF_DEBUG("goaway sent: status %i", NTOH31(*(uint32_t*)(response_queue->data))); | ||
559 | |||
551 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); | 560 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); |
552 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); | 561 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); |
553 | 562 | ||
@@ -717,6 +726,8 @@ SPDYF_handler_write_data (struct SPDY_Session *session) | |||
717 | session->write_buffer_offset += ret; | 726 | session->write_buffer_offset += ret; |
718 | session->write_buffer_size = session->write_buffer_offset; | 727 | session->write_buffer_size = session->write_buffer_offset; |
719 | } | 728 | } |
729 | |||
730 | //SPDYF_DEBUG("data sent: id %i", NTOH31(data_frame.stream_id)); | ||
720 | 731 | ||
721 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); | 732 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); |
722 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); | 733 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); |
@@ -761,6 +772,8 @@ SPDYF_handler_write_rst_stream (struct SPDY_Session *session) | |||
761 | //data is not freed by the destroy function so: | 772 | //data is not freed by the destroy function so: |
762 | //free(response_queue->data); | 773 | //free(response_queue->data); |
763 | 774 | ||
775 | //SPDYF_DEBUG("rst_stream sent: id %i", NTOH31((((uint64_t)response_queue->data) & 0xFFFF0000) >> 32)); | ||
776 | |||
764 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); | 777 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); |
765 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); | 778 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); |
766 | 779 | ||
@@ -802,6 +815,8 @@ SPDYF_handler_write_window_update (struct SPDY_Session *session) | |||
802 | memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 8); | 815 | memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 8); |
803 | session->write_buffer_offset += 8; | 816 | session->write_buffer_offset += 8; |
804 | 817 | ||
818 | //SPDYF_DEBUG("window_update sent: id %i", NTOH31((((uint64_t)response_queue->data) & 0xFFFF0000) >> 32)); | ||
819 | |||
805 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); | 820 | SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); |
806 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); | 821 | SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); |
807 | 822 | ||
@@ -961,7 +976,8 @@ SPDYF_session_read (struct SPDY_Session *session) | |||
961 | 976 | ||
962 | 977 | ||
963 | int | 978 | int |
964 | SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) | 979 | SPDYF_session_write (struct SPDY_Session *session, |
980 | bool only_one_frame) | ||
965 | { | 981 | { |
966 | unsigned int i; | 982 | unsigned int i; |
967 | int bytes_written; | 983 | int bytes_written; |
@@ -1033,6 +1049,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) | |||
1033 | } | 1049 | } |
1034 | 1050 | ||
1035 | //just return from the loop to return from this function | 1051 | //just return from the loop to return from this function |
1052 | ++i; | ||
1036 | break; | 1053 | break; |
1037 | } | 1054 | } |
1038 | 1055 | ||
@@ -1049,6 +1066,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) | |||
1049 | else | 1066 | else |
1050 | { | 1067 | { |
1051 | //no need to try the same frame again | 1068 | //no need to try the same frame again |
1069 | ++i; | ||
1052 | break; | 1070 | break; |
1053 | } | 1071 | } |
1054 | } | 1072 | } |