Lines Matching refs:session

44 spdyf_handler_read_syn_stream (struct SPDY_Session *session)  in spdyf_handler_read_syn_stream()  argument
53 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status in spdyf_handler_read_syn_stream()
54 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status, in spdyf_handler_read_syn_stream()
57 frame = (struct SPDYF_Control_Frame *)session->frame_handler_cls; in spdyf_handler_read_syn_stream()
60 if(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status) in spdyf_handler_read_syn_stream()
69 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_syn_stream()
74 if(SPDY_YES != SPDYF_stream_new(session)) in spdyf_handler_read_syn_stream()
82 session->current_stream_id = session->streams_head->stream_id; in spdyf_handler_read_syn_stream()
86 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES; in spdyf_handler_read_syn_stream()
90 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY; in spdyf_handler_read_syn_stream()
99 if(session->read_buffer_offset - session->read_buffer_beginning < compressed_data_size) in spdyf_handler_read_syn_stream()
107 SPDYF_zlib_inflate(&session->zlib_recv_stream, in spdyf_handler_read_syn_stream()
108 session->read_buffer + session->read_buffer_beginning, in spdyf_handler_read_syn_stream()
123 session->status = SPDY_SESSION_STATUS_FLUSHING; in spdyf_handler_read_syn_stream()
125 SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_INTERNAL_ERROR, false); in spdyf_handler_read_syn_stream()
133 if(SPDY_YES != SPDYF_prepare_rst_stream(session, session->streams_head, in spdyf_handler_read_syn_stream()
151 session->streams_head->headers = headers; in spdyf_handler_read_syn_stream()
153 if(SPDY_YES != session->daemon->fnew_stream_cb(session->daemon->fcls, session->streams_head)) in spdyf_handler_read_syn_stream()
160 session->read_buffer_beginning += compressed_data_size; in spdyf_handler_read_syn_stream()
167 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_syn_stream()
181 spdyf_handler_read_goaway (struct SPDY_Session *session) in spdyf_handler_read_goaway() argument
188 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status, in spdyf_handler_read_goaway()
191 frame = (struct SPDYF_Control_Frame *)session->frame_handler_cls; in spdyf_handler_read_goaway()
196 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES; in spdyf_handler_read_goaway()
207 if((session->read_buffer_offset - session->read_buffer_beginning) < frame->length) in spdyf_handler_read_goaway()
215 session->is_goaway_received = true; in spdyf_handler_read_goaway()
219 memcpy(&last_good_stream_id, session->read_buffer + session->read_buffer_beginning, 4); in spdyf_handler_read_goaway()
221 session->read_buffer_beginning += 4; in spdyf_handler_read_goaway()
223 memcpy(&status_int, session->read_buffer + session->read_buffer_beginning, 4); in spdyf_handler_read_goaway()
225 session->read_buffer_beginning += 4; in spdyf_handler_read_goaway()
246 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_goaway()
260 spdyf_handler_read_rst_stream (struct SPDY_Session *session) in spdyf_handler_read_rst_stream() argument
268 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status, in spdyf_handler_read_rst_stream()
271 frame = (struct SPDYF_Control_Frame *)session->frame_handler_cls; in spdyf_handler_read_rst_stream()
278 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES; in spdyf_handler_read_rst_stream()
282 if((session->read_buffer_offset - session->read_buffer_beginning) < frame->length) in spdyf_handler_read_rst_stream()
289 memcpy(&stream_id, session->read_buffer + session->read_buffer_beginning, 4); in spdyf_handler_read_rst_stream()
291 session->read_buffer_beginning += 4; in spdyf_handler_read_rst_stream()
293 memcpy(&status_int, session->read_buffer + session->read_buffer_beginning, 4); in spdyf_handler_read_rst_stream()
295 session->read_buffer_beginning += 4; in spdyf_handler_read_rst_stream()
297 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_rst_stream()
301 stream = session->streams_head; in spdyf_handler_read_rst_stream()
332 spdyf_handler_read_data (struct SPDY_Session *session) in spdyf_handler_read_data() argument
338 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status in spdyf_handler_read_data()
339 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status, in spdyf_handler_read_data()
346 frame = (struct SPDYF_Data_Frame *)session->frame_handler_cls; in spdyf_handler_read_data()
349 if(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status) in spdyf_handler_read_data()
353 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES; in spdyf_handler_read_data()
357 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY; in spdyf_handler_read_data()
362 if(session->read_buffer_offset - session->read_buffer_beginning in spdyf_handler_read_data()
365 stream = SPDYF_stream_find(frame->stream_id, session); in spdyf_handler_read_data()
367 if(NULL == stream || stream->is_in_closed || NULL == session->daemon->received_data_cb) in spdyf_handler_read_data()
369 if(NULL == session->daemon->received_data_cb) in spdyf_handler_read_data()
375 session->read_buffer_beginning += frame->length; in spdyf_handler_read_data()
376 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_data()
381 ret = session->daemon->freceived_data_cb(session->daemon->cls, in spdyf_handler_read_data()
383 session->read_buffer + session->read_buffer_beginning, in spdyf_handler_read_data()
387 session->read_buffer_beginning += frame->length; in spdyf_handler_read_data()
405 if(SPDY_YES == SPDYF_prepare_window_update(session, stream, in spdyf_handler_read_data()
415 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in spdyf_handler_read_data()
422 SPDYF_handler_write_syn_reply (struct SPDY_Session *session) in SPDYF_handler_write_syn_reply() argument
424 struct SPDYF_Response_Queue *response_queue = session->response_queue_head; in SPDYF_handler_write_syn_reply()
433 SPDYF_ASSERT(NULL == session->write_buffer, "the function is called not in the correct moment"); in SPDYF_handler_write_syn_reply()
437 if(SPDY_YES != SPDYF_zlib_deflate(&session->zlib_send_stream, in SPDYF_handler_write_syn_reply()
449 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_handler_write_syn_reply()
463 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_syn_reply()
469 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_handler_write_syn_reply()
475 session->write_buffer_beginning = 0; in SPDYF_handler_write_syn_reply()
476 session->write_buffer_offset = 0; in SPDYF_handler_write_syn_reply()
477 session->write_buffer_size = total_size; in SPDYF_handler_write_syn_reply()
483 …memcpy(session->write_buffer + session->write_buffer_offset,&control_frame,sizeof(struct SPDYF_Con… in SPDYF_handler_write_syn_reply()
484 session->write_buffer_offset += sizeof(struct SPDYF_Control_Frame); in SPDYF_handler_write_syn_reply()
488 memcpy(session->write_buffer + session->write_buffer_offset, &stream_id_nbo, 4); in SPDYF_handler_write_syn_reply()
489 session->write_buffer_offset += 4; in SPDYF_handler_write_syn_reply()
492 …memcpy(session->write_buffer + session->write_buffer_offset, compressed_headers, compressed_header… in SPDYF_handler_write_syn_reply()
493 session->write_buffer_offset += compressed_headers_size; in SPDYF_handler_write_syn_reply()
495 SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); in SPDYF_handler_write_syn_reply()
496 SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); in SPDYF_handler_write_syn_reply()
508 session->last_replied_to_stream_id = stream->stream_id; in SPDYF_handler_write_syn_reply()
517 SPDYF_handler_write_goaway (struct SPDY_Session *session) in SPDYF_handler_write_goaway() argument
519 struct SPDYF_Response_Queue *response_queue = session->response_queue_head; in SPDYF_handler_write_goaway()
524 SPDYF_ASSERT(NULL == session->write_buffer, "the function is called not in the correct moment"); in SPDYF_handler_write_goaway()
528 session->is_goaway_sent = true; in SPDYF_handler_write_goaway()
534 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_goaway()
538 session->write_buffer_beginning = 0; in SPDYF_handler_write_goaway()
539 session->write_buffer_offset = 0; in SPDYF_handler_write_goaway()
540 session->write_buffer_size = total_size; in SPDYF_handler_write_goaway()
546 …memcpy(session->write_buffer + session->write_buffer_offset,&control_frame,sizeof(struct SPDYF_Con… in SPDYF_handler_write_goaway()
547 session->write_buffer_offset += sizeof(struct SPDYF_Control_Frame); in SPDYF_handler_write_goaway()
550 last_good_stream_id = HTON31(session->last_replied_to_stream_id); in SPDYF_handler_write_goaway()
551 memcpy(session->write_buffer + session->write_buffer_offset, &last_good_stream_id, 4); in SPDYF_handler_write_goaway()
552 session->write_buffer_offset += 4; in SPDYF_handler_write_goaway()
555 memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 4); in SPDYF_handler_write_goaway()
556 session->write_buffer_offset += 4; in SPDYF_handler_write_goaway()
562 SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); in SPDYF_handler_write_goaway()
563 SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); in SPDYF_handler_write_goaway()
570 SPDYF_handler_write_data (struct SPDY_Session *session) in SPDYF_handler_write_data() argument
572 struct SPDYF_Response_Queue *response_queue = session->response_queue_head; in SPDYF_handler_write_data()
579 SPDYF_ASSERT(NULL == session->write_buffer, "the function is called not in the correct moment"); in SPDYF_handler_write_data()
591 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_data()
595 session->write_buffer_beginning = 0; in SPDYF_handler_write_data()
596 session->write_buffer_offset = 0; in SPDYF_handler_write_data()
597 session->write_buffer_size = total_size; in SPDYF_handler_write_data()
603 …memcpy(session->write_buffer + session->write_buffer_offset,&data_frame,sizeof(struct SPDYF_Data_F… in SPDYF_handler_write_data()
604 session->write_buffer_offset += sizeof(struct SPDYF_Data_Frame); in SPDYF_handler_write_data()
607 …memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, response_queue-… in SPDYF_handler_write_data()
608 session->write_buffer_offset += response_queue->data_size; in SPDYF_handler_write_data()
619 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_data()
623 session->write_buffer_beginning = 0; in SPDYF_handler_write_data()
624 session->write_buffer_offset = 0; in SPDYF_handler_write_data()
625 session->write_buffer_size = total_size; in SPDYF_handler_write_data()
628 session->write_buffer + sizeof(struct SPDYF_Data_Frame), in SPDYF_handler_write_data()
634 free(session->write_buffer); in SPDYF_handler_write_data()
635 session->write_buffer = NULL; in SPDYF_handler_write_data()
638 if(SPDY_YES == (ret = SPDYF_prepare_rst_stream(session, in SPDYF_handler_write_data()
648 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_handler_write_data()
655 free(session->write_buffer); in SPDYF_handler_write_data()
656 session->write_buffer = NULL; in SPDYF_handler_write_data()
657 session->write_buffer_size = 0; in SPDYF_handler_write_data()
663 session->response_queue_head = response_queue->next; in SPDYF_handler_write_data()
664 session->response_queue_head->prev = NULL; in SPDYF_handler_write_data()
665 session->response_queue_tail->next = response_queue; in SPDYF_handler_write_data()
666 response_queue->prev = session->response_queue_tail; in SPDYF_handler_write_data()
668 session->response_queue_tail = response_queue; in SPDYF_handler_write_data()
690 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_handler_write_data()
692 free(session->write_buffer); in SPDYF_handler_write_data()
693 session->write_buffer = NULL; in SPDYF_handler_write_data()
702 session->response_queue_tail = new_response_queue; in SPDYF_handler_write_data()
724 memcpy(session->write_buffer + session->write_buffer_offset, in SPDYF_handler_write_data()
727 session->write_buffer_offset += sizeof(struct SPDYF_Data_Frame); in SPDYF_handler_write_data()
728 session->write_buffer_offset += ret; in SPDYF_handler_write_data()
729 session->write_buffer_size = session->write_buffer_offset; in SPDYF_handler_write_data()
734 SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); in SPDYF_handler_write_data()
735 SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); in SPDYF_handler_write_data()
742 SPDYF_handler_write_rst_stream (struct SPDY_Session *session) in SPDYF_handler_write_rst_stream() argument
744 struct SPDYF_Response_Queue *response_queue = session->response_queue_head; in SPDYF_handler_write_rst_stream()
748 SPDYF_ASSERT(NULL == session->write_buffer, "the function is called not in the correct moment"); in SPDYF_handler_write_rst_stream()
756 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_rst_stream()
760 session->write_buffer_beginning = 0; in SPDYF_handler_write_rst_stream()
761 session->write_buffer_offset = 0; in SPDYF_handler_write_rst_stream()
762 session->write_buffer_size = total_size; in SPDYF_handler_write_rst_stream()
768 …memcpy(session->write_buffer + session->write_buffer_offset,&control_frame,sizeof(struct SPDYF_Con… in SPDYF_handler_write_rst_stream()
769 session->write_buffer_offset += sizeof(struct SPDYF_Control_Frame); in SPDYF_handler_write_rst_stream()
772 memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 8); in SPDYF_handler_write_rst_stream()
773 session->write_buffer_offset += 8; in SPDYF_handler_write_rst_stream()
779 SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); in SPDYF_handler_write_rst_stream()
780 SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); in SPDYF_handler_write_rst_stream()
787 SPDYF_handler_write_window_update (struct SPDY_Session *session) in SPDYF_handler_write_window_update() argument
789 struct SPDYF_Response_Queue *response_queue = session->response_queue_head; in SPDYF_handler_write_window_update()
793 SPDYF_ASSERT(NULL == session->write_buffer, "the function is called not in the correct moment"); in SPDYF_handler_write_window_update()
801 if(NULL == (session->write_buffer = malloc(total_size))) in SPDYF_handler_write_window_update()
805 session->write_buffer_beginning = 0; in SPDYF_handler_write_window_update()
806 session->write_buffer_offset = 0; in SPDYF_handler_write_window_update()
807 session->write_buffer_size = total_size; in SPDYF_handler_write_window_update()
813 …memcpy(session->write_buffer + session->write_buffer_offset,&control_frame,sizeof(struct SPDYF_Con… in SPDYF_handler_write_window_update()
814 session->write_buffer_offset += sizeof(struct SPDYF_Control_Frame); in SPDYF_handler_write_window_update()
817 memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 8); in SPDYF_handler_write_window_update()
818 session->write_buffer_offset += 8; in SPDYF_handler_write_window_update()
822 SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); in SPDYF_handler_write_window_update()
823 SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); in SPDYF_handler_write_window_update()
830 SPDYF_handler_ignore_frame (struct SPDY_Session *session) in SPDYF_handler_ignore_frame() argument
834 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status in SPDYF_handler_ignore_frame()
835 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status, in SPDYF_handler_ignore_frame()
839 frame = (struct SPDYF_Control_Frame *)session->frame_handler_cls; in SPDYF_handler_ignore_frame()
842 if(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status) in SPDYF_handler_ignore_frame()
846 session->status = SPDY_SESSION_STATUS_IGNORE_BYTES; in SPDYF_handler_ignore_frame()
850 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY; in SPDYF_handler_ignore_frame()
855 if(session->read_buffer_offset - session->read_buffer_beginning in SPDYF_handler_ignore_frame()
858 session->read_buffer_beginning += frame->length; in SPDYF_handler_ignore_frame()
859 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in SPDYF_handler_ignore_frame()
866 SPDYF_session_read (struct SPDY_Session *session) in SPDYF_session_read() argument
872 if(SPDY_SESSION_STATUS_CLOSING == session->status in SPDYF_session_read()
873 || SPDY_SESSION_STATUS_FLUSHING == session->status) in SPDYF_session_read()
877 if (session->read_buffer_size == session->read_buffer_offset) in SPDYF_session_read()
882 actual_buf_size = session->read_buffer_offset in SPDYF_session_read()
883 - session->read_buffer_beginning; in SPDYF_session_read()
884 switch(session->status) in SPDYF_session_read()
899 SPDYF_ASSERT(NULL != session->frame_handler_cls, in SPDYF_session_read()
901 if(session->frame_handler != &spdyf_handler_read_data) in SPDYF_session_read()
904 < ((struct SPDYF_Control_Frame *)session->frame_handler_cls)->length) in SPDYF_session_read()
910 < ((struct SPDYF_Data_Frame *)session->frame_handler_cls)->length) in SPDYF_session_read()
924 memmove(session->read_buffer, in SPDYF_session_read()
925 session->read_buffer + session->read_buffer_beginning, in SPDYF_session_read()
926 session->read_buffer_offset - session->read_buffer_beginning); in SPDYF_session_read()
928 session->read_buffer_offset -= session->read_buffer_beginning; in SPDYF_session_read()
929 session->read_buffer_beginning = 0; in SPDYF_session_read()
939 session->last_activity = SPDYF_monotonic_time(); in SPDYF_session_read()
942 bytes_read = session->fio_recv(session, in SPDYF_session_read()
943 session->read_buffer + session->read_buffer_offset, in SPDYF_session_read()
944 session->read_buffer_size - session->read_buffer_offset); in SPDYF_session_read()
951 shutdown (session->socket_fd, SHUT_RD); in SPDYF_session_read()
952 session->read_closed = true; in SPDYF_session_read()
953 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_read()
959 SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_INTERNAL_ERROR, false); in SPDYF_session_read()
961 session->status = SPDY_SESSION_STATUS_FLUSHING; in SPDYF_session_read()
974 session->read_buffer_offset += bytes_read; in SPDYF_session_read()
981 SPDYF_session_write (struct SPDY_Session *session, in SPDYF_session_write() argument
989 if(SPDY_SESSION_STATUS_CLOSING == session->status) in SPDYF_session_write()
992 if(SPDY_NO == session->fio_before_write(session)) in SPDYF_session_write()
998 : i < session->max_num_frames; in SPDYF_session_write()
1003 if(NULL == session->write_buffer) in SPDYF_session_write()
1006 response_queue = session->response_queue_head; in SPDYF_session_write()
1018 DLL_remove(session->response_queue_head,session->response_queue_tail,response_queue); in SPDYF_session_write()
1026 response_queue = session->response_queue_head; in SPDYF_session_write()
1029 if(NULL == session->response_queue_head) in SPDYF_session_write()
1034 if(SPDY_NO == session->response_queue_head->process_response_handler(session)) in SPDYF_session_write()
1038 if(SPDY_SESSION_STATUS_CLOSING == session->status) in SPDYF_session_write()
1041 if(session->response_queue_head->is_data in SPDYF_session_write()
1043 != session->response_queue_head->control_frame->type) in SPDYF_session_write()
1045 session->status = SPDY_SESSION_STATUS_FLUSHING; in SPDYF_session_write()
1046 SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_INTERNAL_ERROR, true); in SPDYF_session_write()
1047 SPDYF_session_write(session,true); in SPDYF_session_write()
1048 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_write()
1061 if(0 == session->write_buffer_size)//nothing to write in SPDYF_session_write()
1063 if(response_queue != session->response_queue_head) in SPDYF_session_write()
1077 session->last_activity = SPDYF_monotonic_time(); in SPDYF_session_write()
1080 bytes_written = session->fio_send(session, in SPDYF_session_write()
1081 session->write_buffer + session->write_buffer_beginning, in SPDYF_session_write()
1082 session->write_buffer_offset - session->write_buffer_beginning); in SPDYF_session_write()
1089 shutdown (session->socket_fd, SHUT_RD); in SPDYF_session_write()
1090 session->read_closed = true; in SPDYF_session_write()
1091 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_write()
1097 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_write()
1111 session->write_buffer_beginning += bytes_written; in SPDYF_session_write()
1114 if(session->write_buffer_beginning == session->write_buffer_size) in SPDYF_session_write()
1117 free(session->write_buffer); in SPDYF_session_write()
1118 session->write_buffer = NULL; in SPDYF_session_write()
1119 session->write_buffer_size = 0; in SPDYF_session_write()
1120 queue_head = session->response_queue_head; in SPDYF_session_write()
1123 session->response_queue_head = NULL; in SPDYF_session_write()
1124 session->response_queue_tail = NULL; in SPDYF_session_write()
1128 session->response_queue_head = queue_head->next; in SPDYF_session_write()
1129 session->response_queue_head->prev = NULL; in SPDYF_session_write()
1145 if(SPDY_SESSION_STATUS_FLUSHING == session->status in SPDYF_session_write()
1146 && NULL == session->response_queue_head) in SPDYF_session_write()
1147 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_write()
1150 return session->fio_after_write(session, i>0 ? SPDY_YES : SPDY_NO); in SPDYF_session_write()
1155 SPDYF_session_idle (struct SPDY_Session *session) in SPDYF_session_idle() argument
1163 if(SPDY_SESSION_STATUS_CLOSING != session->status in SPDYF_session_idle()
1164 && session->daemon->session_timeout in SPDYF_session_idle()
1165 && (session->last_activity + session->daemon->session_timeout < SPDYF_monotonic_time())) in SPDYF_session_idle()
1167 session->status = SPDY_SESSION_STATUS_CLOSING; in SPDYF_session_idle()
1169 SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_OK, true); in SPDYF_session_idle()
1170 SPDYF_session_write(session,true); in SPDYF_session_idle()
1173 switch(session->status) in SPDYF_session_idle()
1177 session->current_stream_id = 0; in SPDYF_session_idle()
1180 if(session->read_buffer_offset - session->read_buffer_beginning in SPDYF_session_idle()
1186 if(0x80 == *(uint8_t *)(session->read_buffer + session->read_buffer_beginning) in SPDYF_session_idle()
1187 && SPDY_VERSION == *((uint8_t *)session->read_buffer + session->read_buffer_beginning + 1)) in SPDYF_session_idle()
1198 session->read_buffer + session->read_buffer_beginning, in SPDYF_session_idle()
1200 session->read_buffer_beginning += sizeof(struct SPDYF_Control_Frame); in SPDYF_session_idle()
1203 session->status = SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER; in SPDYF_session_idle()
1207 session->frame_handler = &spdyf_handler_read_syn_stream; in SPDYF_session_idle()
1210 session->frame_handler = &spdyf_handler_read_goaway; in SPDYF_session_idle()
1213 session->frame_handler = &spdyf_handler_read_rst_stream; in SPDYF_session_idle()
1216 session->frame_handler = &SPDYF_handler_ignore_frame; in SPDYF_session_idle()
1218 session->frame_handler_cls = control_frame; in SPDYF_session_idle()
1221 else if(0 == *(uint8_t *)(session->read_buffer + session->read_buffer_beginning)) in SPDYF_session_idle()
1233 session->read_buffer + session->read_buffer_beginning, in SPDYF_session_idle()
1235 session->read_buffer_beginning += sizeof(struct SPDYF_Data_Frame); in SPDYF_session_idle()
1238 session->status = SPDY_SESSION_STATUS_WAIT_FOR_BODY; in SPDYF_session_idle()
1239 session->frame_handler = &spdyf_handler_read_data; in SPDYF_session_idle()
1240 session->frame_handler_cls = data_frame; in SPDYF_session_idle()
1256 session->status = SPDY_SESSION_STATUS_FLUSHING; in SPDYF_session_idle()
1257 SPDYF_prepare_goaway(session, SPDY_GOAWAY_STATUS_PROTOCOL_ERROR,false); in SPDYF_session_idle()
1267 if(NULL!=session->frame_handler) in SPDYF_session_idle()
1269 read_buffer_beginning = session->read_buffer_beginning; in SPDYF_session_idle()
1272 session->frame_handler(session); in SPDYF_session_idle()
1274 if(SPDY_SESSION_STATUS_IGNORE_BYTES == session->status) in SPDYF_session_idle()
1277 if(session->frame_handler != &spdyf_handler_read_data) in SPDYF_session_idle()
1279 frame_length = ((struct SPDYF_Control_Frame *)session->frame_handler_cls)->length; in SPDYF_session_idle()
1283 frame_length = ((struct SPDYF_Data_Frame *)session->frame_handler_cls)->length; in SPDYF_session_idle()
1293 session->read_ignore_bytes = frame_length in SPDYF_session_idle()
1295 - session->read_buffer_offset; in SPDYF_session_idle()
1297 session->read_buffer_beginning = session->read_buffer_offset; in SPDYF_session_idle()
1299 SPDYF_prepare_rst_stream(session, in SPDYF_session_idle()
1300session->current_stream_id > 0 ? session->streams_head : NULL, //may be 0 here which is not good in SPDYF_session_idle()
1305 session->status = session->read_ignore_bytes in SPDYF_session_idle()
1309 free(session->frame_handler_cls); in SPDYF_session_idle()
1314 if(SPDY_SESSION_STATUS_IGNORE_BYTES != session->status) in SPDYF_session_idle()
1321 SPDYF_ASSERT(session->read_ignore_bytes > 0, in SPDYF_session_idle()
1323 if(session->read_ignore_bytes in SPDYF_session_idle()
1324 > session->read_buffer_offset - session->read_buffer_beginning) in SPDYF_session_idle()
1326 session->read_ignore_bytes -= in SPDYF_session_idle()
1327 session->read_buffer_offset - session->read_buffer_beginning; in SPDYF_session_idle()
1328 session->read_buffer_beginning = session->read_buffer_offset; in SPDYF_session_idle()
1332 session->read_buffer_beginning += session->read_ignore_bytes; in SPDYF_session_idle()
1333 session->read_ignore_bytes = 0; in SPDYF_session_idle()
1334 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in SPDYF_session_idle()
1340 if(NULL!=session->frame_handler) in SPDYF_session_idle()
1341 session->frame_handler(session); in SPDYF_session_idle()
1351 SPDYF_session_close(session); in SPDYF_session_idle()
1360 SPDYF_session_close (struct SPDY_Session *session) in SPDYF_session_close() argument
1362 struct SPDY_Daemon *daemon = session->daemon; in SPDYF_session_close()
1363 int by_client = session->read_closed ? SPDY_YES : SPDY_NO; in SPDYF_session_close()
1366 session->fio_close_session(session); in SPDYF_session_close()
1367 shutdown (session->socket_fd, in SPDYF_session_close()
1368 session->read_closed ? SHUT_WR : SHUT_RDWR); in SPDYF_session_close()
1369 session->read_closed = true; in SPDYF_session_close()
1374 session); in SPDYF_session_close()
1378 session); in SPDYF_session_close()
1383 daemon->session_closed_cb(daemon->cls, session, by_client); in SPDYF_session_close()
1393 struct SPDY_Session *session = NULL; in SPDYF_session_accept() local
1414 if (NULL == (session = malloc (sizeof (struct SPDY_Session)))) in SPDYF_session_accept()
1418 memset (session, 0, sizeof (struct SPDY_Session)); in SPDYF_session_accept()
1420 session->daemon = daemon; in SPDYF_session_accept()
1421 session->socket_fd = new_socket_fd; in SPDYF_session_accept()
1422 session->max_num_frames = daemon->max_num_frames; in SPDYF_session_accept()
1424 ret = SPDYF_io_set_session(session, daemon->io_subsystem); in SPDYF_session_accept()
1428 if(SPDY_YES != session->fio_new_session(session)) in SPDYF_session_accept()
1434 session->read_buffer_size = SPDYF_BUFFER_SIZE; in SPDYF_session_accept()
1435 if (NULL == (session->read_buffer = malloc (session->read_buffer_size))) in SPDYF_session_accept()
1437 session->fio_close_session(session); in SPDYF_session_accept()
1442 if (NULL == (session->addr = malloc (addr_len))) in SPDYF_session_accept()
1444 session->fio_close_session(session); in SPDYF_session_accept()
1447 memcpy (session->addr, addr, addr_len); in SPDYF_session_accept()
1449 session->addr_len = addr_len; in SPDYF_session_accept()
1450 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; in SPDYF_session_accept()
1453 if(SPDY_YES != SPDYF_zlib_deflate_init(&session->zlib_send_stream)) in SPDYF_session_accept()
1455 session->fio_close_session(session); in SPDYF_session_accept()
1458 if(SPDY_YES != SPDYF_zlib_inflate_init(&session->zlib_recv_stream)) in SPDYF_session_accept()
1460 session->fio_close_session(session); in SPDYF_session_accept()
1461 SPDYF_zlib_deflate_end(&session->zlib_send_stream); in SPDYF_session_accept()
1466 DLL_insert(daemon->sessions_head,daemon->sessions_tail,session); in SPDYF_session_accept()
1468 session->last_activity = SPDYF_monotonic_time(); in SPDYF_session_accept()
1471 daemon->new_session_cb(daemon->cls, session); in SPDYF_session_accept()
1481 if(NULL != session) in SPDYF_session_accept()
1483 if(NULL != session->addr) in SPDYF_session_accept()
1484 free (session->addr); in SPDYF_session_accept()
1485 if(NULL != session->read_buffer) in SPDYF_session_accept()
1486 free (session->read_buffer); in SPDYF_session_accept()
1487 free (session); in SPDYF_session_accept()
1495 struct SPDY_Session *session, in SPDYF_queue_response() argument
1514 response_to_queue->prev = session->response_queue_tail; in SPDYF_queue_response()
1515 if (NULL == session->response_queue_head) in SPDYF_queue_response()
1516 session->response_queue_head = response_to_queue; in SPDYF_queue_response()
1518 session->response_queue_tail->next = response_to_queue; in SPDYF_queue_response()
1519 session->response_queue_tail = last; in SPDYF_queue_response()
1525 last->next = session->response_queue_head; in SPDYF_queue_response()
1526 if (NULL == session->response_queue_tail) in SPDYF_queue_response()
1527 session->response_queue_tail = last; in SPDYF_queue_response()
1529 session->response_queue_head->prev = response_to_queue; in SPDYF_queue_response()
1530 session->response_queue_head = response_to_queue; in SPDYF_queue_response()
1534 if(NULL == session->response_queue_tail) in SPDYF_queue_response()
1536 session->response_queue_head = response_to_queue; in SPDYF_queue_response()
1537 session->response_queue_tail = last; in SPDYF_queue_response()
1542 pos = session->response_queue_tail; in SPDYF_queue_response()
1553 session->response_queue_head->prev = last; in SPDYF_queue_response()
1554 last->next = session->response_queue_head; in SPDYF_queue_response()
1555 session->response_queue_head = response_to_queue; in SPDYF_queue_response()
1562 session->response_queue_tail = last; in SPDYF_queue_response()
1575 SPDYF_session_destroy(struct SPDY_Session *session) in SPDYF_session_destroy() argument
1580 (void)close (session->socket_fd); in SPDYF_session_destroy()
1581 SPDYF_zlib_deflate_end(&session->zlib_send_stream); in SPDYF_session_destroy()
1582 SPDYF_zlib_inflate_end(&session->zlib_recv_stream); in SPDYF_session_destroy()
1585 while (NULL != (response_queue = session->response_queue_head)) in SPDYF_session_destroy()
1587 DLL_remove (session->response_queue_head, in SPDYF_session_destroy()
1588 session->response_queue_tail, in SPDYF_session_destroy()
1600 while (NULL != (stream = session->streams_head)) in SPDYF_session_destroy()
1602 DLL_remove (session->streams_head, in SPDYF_session_destroy()
1603 session->streams_tail, in SPDYF_session_destroy()
1609 free(session->addr); in SPDYF_session_destroy()
1610 free(session->read_buffer); in SPDYF_session_destroy()
1611 free(session->write_buffer); in SPDYF_session_destroy()
1612 free(session); in SPDYF_session_destroy()
1617 SPDYF_prepare_goaway (struct SPDY_Session *session, in SPDYF_prepare_goaway() argument
1657 session, in SPDYF_prepare_goaway()
1665 SPDYF_prepare_rst_stream (struct SPDY_Session *session, in SPDYF_prepare_rst_stream() argument
1713 session, in SPDYF_prepare_rst_stream()
1721 SPDYF_prepare_window_update (struct SPDY_Session *session, in SPDYF_prepare_window_update() argument
1765 session, in SPDYF_prepare_window_update()