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.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-03-26 23:35:20 +09:00
parent 262cda86e8
commit 200012f1b5
3 changed files with 28 additions and 33 deletions

View File

@ -415,17 +415,6 @@ typedef enum {
SPDYLAY_GOAWAY_INTERNAL_ERROR = 11 SPDYLAY_GOAWAY_INTERNAL_ERROR = 11
} spdylay_goaway_status_code; } 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 * @struct
* The control frame header. * The control frame header.
@ -468,10 +457,9 @@ typedef struct {
*/ */
int32_t assoc_stream_id; int32_t assoc_stream_id;
/** /**
* The priority of this frame. 0 (Highest) to * The priority of this frame. 0 is the highest priority value. Use
* :macro:`SPDYLAY_SPDY2_PRI_LOWEST` or * `spdylay_session_get_pri_lowest()` to know the lowest priority
* :macro:`SPDYLAY_SPDY3_PRI_LOWEST` (lowest), depending on the * value.
* protocol version.
*/ */
uint8_t pri; 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); 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 * @function
* *
@ -1247,11 +1242,8 @@ size_t spdylay_session_get_outbound_queue_size(spdylay_session *session);
* frames. * frames.
* *
* The |pri| is priority of this request. 0 is the highest priority * The |pri| is priority of this request. 0 is the highest priority
* value. If the |session| is initialized with the version * value. Use `spdylay_session_get_pri_lowest()` to know the lowest
* :macro:`SPDYLAY_PROTO_SPDY2`, the lowest priority value is * priority value for this |session|.
* :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`.
* *
* The |nv| contains the name/value pairs. For i > 0, ``nv[2*i]`` * 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 * 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 * The |assoc_stream_id| is used for server-push. If |session| is
* initialized for client use, |assoc_stream_id| is ignored. * initialized for client use, |assoc_stream_id| is ignored.
*
* The |pri| is priority of this request. 0 is the highest priority * The |pri| is priority of this request. 0 is the highest priority
* value. If the |session| is initialized with the version * value. Use `spdylay_session_get_pri_lowest()` to know the lowest
* :macro:`SPDYLAY_PROTO_SPDY2`, the lowest priority value is * priority value for this |session|.
* :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`.
* *
* The |nv| contains the name/value pairs. For i > 0, ``nv[2*i]`` * 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 * contains a pointer to the name string and ``nv[2*i+1]`` contains a

View File

@ -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) uint8_t spdylay_session_get_pri_lowest(spdylay_session *session)
{ {
if(session->version == SPDYLAY_PROTO_SPDY2) { if(session->version == SPDYLAY_PROTO_SPDY2) {
return SPDYLAY_SPDY2_PRI_LOWEST; return SPDYLAY_PRI_LOWEST_SPDY2;
} else if(session->version == SPDYLAY_PROTO_SPDY3) { } else if(session->version == SPDYLAY_PROTO_SPDY3) {
return SPDYLAY_SPDY3_PRI_LOWEST; return SPDYLAY_PRI_LOWEST_SPDY3;
} else { } else {
return 0; return 0;
} }

View File

@ -38,6 +38,17 @@
#include "spdylay_buffer.h" #include "spdylay_buffer.h"
#include "spdylay_outbound_item.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 { typedef struct {
spdylay_outbound_item *item; spdylay_outbound_item *item;
/* Buffer for outbound frames. Used to pack one frame. The memory /* 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_outbound_item* spdylay_session_get_next_ob_item
(spdylay_session *session); (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 * Updates local settings with the |iv|. The number of elements in the
* array pointed by the |iv| is given by the |niv|. This function * array pointed by the |iv| is given by the |niv|. This function