From 200012f1b540912acf58e9e69610d80166ac2324 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 26 Mar 2012 23:35:20 +0900 Subject: [PATCH] Removed SPDYLAY_SPDY2_PRI_LOWEST and SPDYLAY_SPDY3_PRI_LOWEST macros. Made spdylay_session_get_pri_lowest() to get the lowest priority value for the current session. This change allows the application code to get the lowest priority value without knowing the protocol version which the current session uses. --- lib/includes/spdylay/spdylay.h | 41 +++++++++++++--------------------- lib/spdylay_session.c | 4 ++-- lib/spdylay_session.h | 16 ++++++++----- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/lib/includes/spdylay/spdylay.h b/lib/includes/spdylay/spdylay.h index f1003435..c0444be4 100644 --- a/lib/includes/spdylay/spdylay.h +++ b/lib/includes/spdylay/spdylay.h @@ -415,17 +415,6 @@ typedef enum { SPDYLAY_GOAWAY_INTERNAL_ERROR = 11 } spdylay_goaway_status_code; -/** - * @macro - * Lowest priority value in SPDY/2, which is 3. - */ -#define SPDYLAY_SPDY2_PRI_LOWEST 3 -/** - * @macro - * Lowest priority value in SPDY/3, which is 7. - */ -#define SPDYLAY_SPDY3_PRI_LOWEST 7 - /** * @struct * The control frame header. @@ -468,10 +457,9 @@ typedef struct { */ int32_t assoc_stream_id; /** - * The priority of this frame. 0 (Highest) to - * :macro:`SPDYLAY_SPDY2_PRI_LOWEST` or - * :macro:`SPDYLAY_SPDY3_PRI_LOWEST` (lowest), depending on the - * protocol version. + * The priority of this frame. 0 is the highest priority value. Use + * `spdylay_session_get_pri_lowest()` to know the lowest priority + * value. */ uint8_t pri; /** @@ -1240,6 +1228,13 @@ void* spdylay_session_get_stream_user_data(spdylay_session *session, */ size_t spdylay_session_get_outbound_queue_size(spdylay_session *session); +/** + * @function + * + * Returns lowest priority value for the |session|. + */ +uint8_t spdylay_session_get_pri_lowest(spdylay_session *session); + /** * @function * @@ -1247,11 +1242,8 @@ size_t spdylay_session_get_outbound_queue_size(spdylay_session *session); * frames. * * The |pri| is priority of this request. 0 is the highest priority - * value. If the |session| is initialized with the version - * :macro:`SPDYLAY_PROTO_SPDY2`, the lowest priority value is - * :macro:`SPDYLAY_SPDY2_PRI_LOWEST`. If the |session| is initialized - * with the version :macro:`SPDYLAY_PROTO_SPDY3`, the lowest priority - * value is :macro:`SPDYLAY_SPDY3_PRI_LOWEST`. + * value. Use `spdylay_session_get_pri_lowest()` to know the lowest + * priority value for this |session|. * * The |nv| contains the name/value pairs. For i > 0, ``nv[2*i]`` * contains a pointer to the name string and ``nv[2*i+1]`` contains a @@ -1372,13 +1364,10 @@ int spdylay_submit_response(spdylay_session *session, * * The |assoc_stream_id| is used for server-push. If |session| is * initialized for client use, |assoc_stream_id| is ignored. - + * * The |pri| is priority of this request. 0 is the highest priority - * value. If the |session| is initialized with the version - * :macro:`SPDYLAY_PROTO_SPDY2`, the lowest priority value is - * :macro:`SPDYLAY_SPDY2_PRI_LOWEST`. If the |session| is initialized - * with the version :macro:`SPDYLAY_PROTO_SPDY3`, the lowest priority - * value is :macro:`SPDYLAY_SPDY3_PRI_LOWEST`. + * value. Use `spdylay_session_get_pri_lowest()` to know the lowest + * priority value for this |session|. * * The |nv| contains the name/value pairs. For i > 0, ``nv[2*i]`` * contains a pointer to the name string and ``nv[2*i+1]`` contains a diff --git a/lib/spdylay_session.c b/lib/spdylay_session.c index f4640289..6c2c207c 100644 --- a/lib/spdylay_session.c +++ b/lib/spdylay_session.c @@ -2322,9 +2322,9 @@ int spdylay_session_resume_data(spdylay_session *session, int32_t stream_id) uint8_t spdylay_session_get_pri_lowest(spdylay_session *session) { if(session->version == SPDYLAY_PROTO_SPDY2) { - return SPDYLAY_SPDY2_PRI_LOWEST; + return SPDYLAY_PRI_LOWEST_SPDY2; } else if(session->version == SPDYLAY_PROTO_SPDY3) { - return SPDYLAY_SPDY3_PRI_LOWEST; + return SPDYLAY_PRI_LOWEST_SPDY3; } else { return 0; } diff --git a/lib/spdylay_session.h b/lib/spdylay_session.h index c1408e14..589e6893 100644 --- a/lib/spdylay_session.h +++ b/lib/spdylay_session.h @@ -38,6 +38,17 @@ #include "spdylay_buffer.h" #include "spdylay_outbound_item.h" +/** + * @macro + * Lowest priority value in SPDY/2, which is 3. + */ +#define SPDYLAY_PRI_LOWEST_SPDY2 3 +/** + * @macro + * Lowest priority value in SPDY/3, which is 7. + */ +#define SPDYLAY_PRI_LOWEST_SPDY3 7 + typedef struct { spdylay_outbound_item *item; /* Buffer for outbound frames. Used to pack one frame. The memory @@ -472,11 +483,6 @@ spdylay_outbound_item* spdylay_session_pop_next_ob_item spdylay_outbound_item* spdylay_session_get_next_ob_item (spdylay_session *session); -/* - * Returns lowest priority value. - */ -uint8_t spdylay_session_get_pri_lowest(spdylay_session *session); - /* * Updates local settings with the |iv|. The number of elements in the * array pointed by the |iv| is given by the |niv|. This function