libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 7c86ad3199ebe0b5cae1c7f5ce6c24821f470c4e
parent 921133b1a584dc203d1358c8fe769abd7cbf32af
Author: Andrey Uzunov <andrey.uzunov@gmail.com>
Date:   Sun,  8 Sep 2013 10:37:24 +0000

spdy: doc -- parameter description fixed

Diffstat:
Msrc/include/microspdy.h | 2+-
Msrc/microspdy/daemon.h | 2++
Msrc/microspdy/internal.h | 4++--
Msrc/microspdy/io.c | 8+++++---
Msrc/microspdy/io.h | 13++++++++++---
Msrc/microspdy/session.c | 32+++++++++++++++++++++++++-------
Msrc/microspdy/session.h | 18++++++++++--------
7 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/src/include/microspdy.h b/src/include/microspdy.h @@ -807,7 +807,7 @@ typedef void * and possibly other stuff needed by the lib. Currently the call * always returns SPDY_YES. * - * @param enum SPDY_IO_SUBSYSTEM io_subsystem the IO subsystem that will + * @param io_subsystem the IO subsystem that will * be initialized. Several can be used with bitwise OR. If no * parameter is set, the default openssl subsystem will be used. * @return SPDY_YES if the library was correctly initialized and its diff --git a/src/microspdy/daemon.h b/src/microspdy/daemon.h @@ -47,6 +47,8 @@ enum SPDY_IO_SUBSYSTEM spdyf_io_initialized; * @param npdcb callback called when HTTP POST params are received * after request * @param fnscb callback called when new stream is opened by a client + * @param fndcb callback called when new data -- within a data frame -- + * is received by the server * @param cls extra argument to all of the callbacks without those * specific only for the framing layer * @param fcls extra argument to all of the callbacks, specific only for diff --git a/src/microspdy/internal.h b/src/microspdy/internal.h @@ -73,10 +73,10 @@ extern void *spdyf_panic_cls; /** * Asserts the validity of an expression. * - * @param expression (bool) + * @param expr (bool) * @param msg message to print on error (const char *) */ -#define SPDYF_ASSERT(expr,msg) \ +#define SPDYF_ASSERT(expr, msg) \ if(!(expr)){\ SPDYF_PANIC(msg);\ abort();\ diff --git a/src/microspdy/io.c b/src/microspdy/io.c @@ -18,7 +18,7 @@ /** * @file io.c - * @brief Functions for IO. + * @brief Generic functions for IO. * @author Andrey Uzunov */ @@ -29,7 +29,8 @@ int -SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, enum SPDY_IO_SUBSYSTEM io_subsystem) +SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, + enum SPDY_IO_SUBSYSTEM io_subsystem) { switch(io_subsystem) { @@ -54,7 +55,8 @@ SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, enum SPDY_IO_SUBSYSTEM io_subsys int -SPDYF_io_set_session(struct SPDY_Session *session, enum SPDY_IO_SUBSYSTEM io_subsystem) +SPDYF_io_set_session(struct SPDY_Session *session, + enum SPDY_IO_SUBSYSTEM io_subsystem) { switch(io_subsystem) { diff --git a/src/microspdy/io.h b/src/microspdy/io.h @@ -184,26 +184,33 @@ typedef int * @return returned value will be used by the write function to return */ typedef int -(*SPDYF_IOAfterWrite) (struct SPDY_Session *session, int was_written); +(*SPDYF_IOAfterWrite) (struct SPDY_Session *session, + int was_written); /** * Sets callbacks for the daemon with regard to the IO subsystem. * * @param daemon + * @param io_subsystem the IO subsystem that will + * be initialized and used by daemon. * @return SPDY_YES on success or SPDY_NO otherwise */ int -SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, enum SPDY_IO_SUBSYSTEM io_subsystem); +SPDYF_io_set_daemon(struct SPDY_Daemon *daemon, + enum SPDY_IO_SUBSYSTEM io_subsystem); /** * Sets callbacks for the session with regard to the IO subsystem. * * @param session + * @param io_subsystem the IO subsystem that will + * be initialized and used by session. * @return SPDY_YES on success or SPDY_NO otherwise */ int -SPDYF_io_set_session(struct SPDY_Session *session, enum SPDY_IO_SUBSYSTEM io_subsystem); +SPDYF_io_set_session(struct SPDY_Session *session, + enum SPDY_IO_SUBSYSTEM io_subsystem); #endif diff --git a/src/microspdy/session.c b/src/microspdy/session.c @@ -159,6 +159,8 @@ spdyf_handler_read_syn_stream (struct SPDY_Session *session) free(name_value_strm); } + //SPDYF_DEBUG("syn_stream received: id %i", session->current_stream_id); + //change state to wait for new frame session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; free(frame); @@ -235,6 +237,8 @@ spdyf_handler_read_goaway (struct SPDY_Session *session) case SPDY_GOAWAY_STATUS_INTERNAL_ERROR: break; } + + //SPDYF_DEBUG("goaway received: status %i", status); } session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; @@ -256,7 +260,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) struct SPDYF_Control_Frame *frame; uint32_t stream_id; int32_t status_int; - enum SPDY_RST_STREAM_STATUS status; + //enum SPDY_RST_STREAM_STATUS status; //for debug struct SPDYF_Stream *stream; SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status, @@ -285,7 +289,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) session->read_buffer_beginning += 4; memcpy(&status_int, session->read_buffer + session->read_buffer_beginning, 4); - status = ntohl(status_int); + //status = ntohl(status_int); //for debug session->read_buffer_beginning += 4; session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; @@ -304,7 +308,7 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session) stream = stream->next; } - SPDYF_DEBUG("Received RST_STREAM; status=%i; id=%i",status,stream_id); + //SPDYF_DEBUG("Received RST_STREAM; status=%i; id=%i",status,stream_id); //do something according to the status //TODO @@ -361,9 +365,7 @@ spdyf_handler_read_data (struct SPDY_Session *session) if(NULL == stream || stream->is_in_closed || NULL == session->daemon->received_data_cb) { if(NULL == session->daemon->received_data_cb) - SPDYF_DEBUG("No callback for DATA frame set"); - - SPDYF_DEBUG("Ignoring DATA frame!"); + SPDYF_DEBUG("No callback for DATA frame set; Ignoring DATA frame!"); //TODO send error? @@ -405,6 +407,9 @@ spdyf_handler_read_data (struct SPDY_Session *session) } //else: do it later } + + //SPDYF_DEBUG("data received: id %i", frame->stream_id); + session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; free(frame); } @@ -499,6 +504,8 @@ SPDYF_handler_write_syn_reply (struct SPDY_Session *session) free(compressed_headers); session->last_replied_to_stream_id = stream->stream_id; + + //SPDYF_DEBUG("syn_reply sent: id %i", stream->stream_id); return SPDY_YES; } @@ -548,6 +555,8 @@ SPDYF_handler_write_goaway (struct SPDY_Session *session) //data is not freed by the destroy function so: //free(response_queue->data); + //SPDYF_DEBUG("goaway sent: status %i", NTOH31(*(uint32_t*)(response_queue->data))); + SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); @@ -717,6 +726,8 @@ SPDYF_handler_write_data (struct SPDY_Session *session) session->write_buffer_offset += ret; session->write_buffer_size = session->write_buffer_offset; } + + //SPDYF_DEBUG("data sent: id %i", NTOH31(data_frame.stream_id)); SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); @@ -761,6 +772,8 @@ SPDYF_handler_write_rst_stream (struct SPDY_Session *session) //data is not freed by the destroy function so: //free(response_queue->data); + //SPDYF_DEBUG("rst_stream sent: id %i", NTOH31((((uint64_t)response_queue->data) & 0xFFFF0000) >> 32)); + SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); @@ -802,6 +815,8 @@ SPDYF_handler_write_window_update (struct SPDY_Session *session) memcpy(session->write_buffer + session->write_buffer_offset, response_queue->data, 8); session->write_buffer_offset += 8; + //SPDYF_DEBUG("window_update sent: id %i", NTOH31((((uint64_t)response_queue->data) & 0xFFFF0000) >> 32)); + SPDYF_ASSERT(0 == session->write_buffer_beginning, "bug1"); SPDYF_ASSERT(session->write_buffer_offset == session->write_buffer_size, "bug2"); @@ -961,7 +976,8 @@ SPDYF_session_read (struct SPDY_Session *session) int -SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) +SPDYF_session_write (struct SPDY_Session *session, + bool only_one_frame) { unsigned int i; int bytes_written; @@ -1033,6 +1049,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) } //just return from the loop to return from this function + ++i; break; } @@ -1049,6 +1066,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame) else { //no need to try the same frame again + ++i; break; } } diff --git a/src/microspdy/session.h b/src/microspdy/session.h @@ -51,20 +51,22 @@ SPDYF_session_read (struct SPDY_Session *session); * queue, and to write data to the TLS socket. * * @param session SPDY_Session for which data will be written. - * @return TODO document after changes - * SPDY_YES if something was written, the status was changed or - * response callback was called but did not provide data - * @return SPDY_YES if something was written, session's status was - * changed or response callback was called but did not provide + * @param only_one_frame when true, the function will write at most one + * SPDY frame to the underlying IO subsystem; + * when false, the function will write up to + * session->max_num_frames SPDY frames + * @return SPDY_YES if the session's internal writing state has changed: + * something was written and/or session's status was + * changed and/or response callback was called but did not provide * data. It is possible that error occurred but was handled * and the status was therefore changed. - * SPDY_NO if nothing happened, e.g. the subsystem wants read/ - * write to be called again. However, it is possible that some + * SPDY_NO if nothing happened. However, it is possible that some * frames were discarded within the call, e.g. frames belonging * to a closed stream. */ int -SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame); +SPDYF_session_write (struct SPDY_Session *session, + bool only_one_frame); /**