From fc07a62337999ae954df389057ede5f50b5f6dde Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 27 Jan 2014 21:22:33 +0900 Subject: [PATCH] Rename nghttp2_data as nghttp2_private_data This is a preparation to add public nghttp2_data struct to nghttp2_frame union. --- lib/nghttp2_frame.c | 6 +++--- lib/nghttp2_frame.h | 10 ++++++---- lib/nghttp2_outbound_item.c | 2 +- lib/nghttp2_outbound_item.h | 5 +++-- lib/nghttp2_session.c | 12 ++++++------ lib/nghttp2_session.h | 4 ++-- lib/nghttp2_submit.c | 4 ++-- tests/nghttp2_session_test.c | 4 ++-- 8 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index 734528ae..adb05650 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -181,17 +181,17 @@ void nghttp2_frame_window_update_init(nghttp2_window_update *frame, void nghttp2_frame_window_update_free(nghttp2_window_update *frame) {} -void nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags, +void nghttp2_frame_data_init(nghttp2_private_data *frame, uint8_t flags, int32_t stream_id, const nghttp2_data_provider *data_prd) { - memset(frame, 0, sizeof(nghttp2_data)); + memset(frame, 0, sizeof(nghttp2_private_data)); /* At this moment, the length of DATA frame is unknown */ nghttp2_frame_set_hd(&frame->hd, 0, NGHTTP2_DATA, flags, stream_id); frame->data_prd = *data_prd; } -void nghttp2_frame_data_free(nghttp2_data *frame) +void nghttp2_frame_data_free(nghttp2_private_data *frame) {} /* diff --git a/lib/nghttp2_frame.h b/lib/nghttp2_frame.h index 8b4dfa5f..ec07e373 100644 --- a/lib/nghttp2_frame.h +++ b/lib/nghttp2_frame.h @@ -58,7 +58,9 @@ typedef enum { /** * @struct - * The DATA frame. It has the following members: + * + * The DATA frame used in the library privately. It has the following + * members: */ typedef struct { nghttp2_frame_hd hd; @@ -72,7 +74,7 @@ typedef struct { * exclusively by nghttp2 library and not in the spec. */ uint8_t eof; -} nghttp2_data; +} nghttp2_private_data; int nghttp2_frame_is_data_frame(uint8_t *head); @@ -414,11 +416,11 @@ void nghttp2_frame_window_update_init(nghttp2_window_update *frame, void nghttp2_frame_window_update_free(nghttp2_window_update *frame); -void nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags, +void nghttp2_frame_data_init(nghttp2_private_data *frame, uint8_t flags, int32_t stream_id, const nghttp2_data_provider *data_prd); -void nghttp2_frame_data_free(nghttp2_data *frame); +void nghttp2_frame_data_free(nghttp2_private_data *frame); /* * Makes copy of |iv| and return the copy. The |niv| is the number of diff --git a/lib/nghttp2_outbound_item.c b/lib/nghttp2_outbound_item.c index 84d2b659..26782013 100644 --- a/lib/nghttp2_outbound_item.c +++ b/lib/nghttp2_outbound_item.c @@ -64,7 +64,7 @@ void nghttp2_outbound_item_free(nghttp2_outbound_item *item) break; } } else if(item->frame_cat == NGHTTP2_CAT_DATA) { - nghttp2_data *data_frame; + nghttp2_private_data *data_frame; data_frame = nghttp2_outbound_item_get_data_frame(item); nghttp2_frame_data_free(data_frame); } else { diff --git a/lib/nghttp2_outbound_item.h b/lib/nghttp2_outbound_item.h index e9e6c00a..d0b53b49 100644 --- a/lib/nghttp2_outbound_item.h +++ b/lib/nghttp2_outbound_item.h @@ -47,7 +47,7 @@ typedef struct { void *frame; void *aux_data; /* Type of |frame|. NGHTTP2_CTRL: nghttp2_frame*, NGHTTP2_DATA: - nghttp2_data* */ + nghttp2_private_data* */ nghttp2_frame_category frame_cat; /* The priority used in priority comparion */ int32_t pri; @@ -63,6 +63,7 @@ void nghttp2_outbound_item_free(nghttp2_outbound_item *item); #define nghttp2_outbound_item_get_ctrl_frame(ITEM) ((nghttp2_frame*)ITEM->frame) #define nghttp2_outbound_item_get_ctrl_frame_type(ITEM) \ (((nghttp2_frame*)ITEM->frame)->hd.type) -#define nghttp2_outbound_item_get_data_frame(ITEM) ((nghttp2_data*)ITEM->frame) +#define nghttp2_outbound_item_get_data_frame(ITEM) \ + ((nghttp2_private_data*)ITEM->frame) #endif /* NGHTTP2_OUTBOUND_ITEM_H */ diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 14b59dd7..da553bd9 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -420,7 +420,7 @@ static int outbound_item_update_pri return 0; } } else { - if(((nghttp2_data*)item->frame)->hd.stream_id != stream->stream_id) { + if(((nghttp2_private_data*)item->frame)->hd.stream_id != stream->stream_id) { return 0; } } @@ -535,7 +535,7 @@ int nghttp2_session_add_frame(nghttp2_session *session, r = nghttp2_pq_push(&session->ob_pq, item); } } else if(frame_cat == NGHTTP2_CAT_DATA) { - nghttp2_data *data_frame = (nghttp2_data*)abs_frame; + nghttp2_private_data *data_frame = (nghttp2_private_data*)abs_frame; nghttp2_stream *stream; stream = nghttp2_session_get_stream(session, data_frame->hd.stream_id); if(stream) { @@ -1264,7 +1264,7 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session, } else if(item->frame_cat == NGHTTP2_CAT_DATA) { size_t next_readmax; nghttp2_stream *stream; - nghttp2_data *data_frame; + nghttp2_private_data *data_frame; int r; data_frame = nghttp2_outbound_item_get_data_frame(item); r = nghttp2_session_predicate_data_send(session, data_frame->hd.stream_id); @@ -1572,7 +1572,7 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session) nghttp2_active_outbound_item_reset(&session->aob); } else if(item->frame_cat == NGHTTP2_CAT_DATA) { int r; - nghttp2_data *data_frame; + nghttp2_private_data *data_frame; data_frame = nghttp2_outbound_item_get_data_frame(session->aob.item); if(session->callbacks.on_data_send_callback) { if(session->callbacks.on_data_send_callback @@ -1763,7 +1763,7 @@ int nghttp2_session_send(nghttp2_session *session) } else { if(session->aob.item->frame_cat == NGHTTP2_CAT_DATA && session->aob.framebufoff + sentlen > NGHTTP2_FRAME_HEAD_LENGTH) { - nghttp2_data *frame; + nghttp2_private_data *frame; nghttp2_stream *stream; uint16_t len; if(session->aob.framebufoff < NGHTTP2_FRAME_HEAD_LENGTH) { @@ -4029,7 +4029,7 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, ssize_t nghttp2_session_pack_data(nghttp2_session *session, uint8_t **buf_ptr, size_t *buflen_ptr, size_t datamax, - nghttp2_data *frame) + nghttp2_private_data *frame) { ssize_t framelen = datamax+8, r; int eof_flags; diff --git a/lib/nghttp2_session.h b/lib/nghttp2_session.h index c5236a13..fab43caa 100644 --- a/lib/nghttp2_session.h +++ b/lib/nghttp2_session.h @@ -220,7 +220,7 @@ int nghttp2_session_is_my_stream_id(nghttp2_session *session, * |frame_cat| must be either NGHTTP2_CTRL or NGHTTP2_DATA. If the * |frame_cat| is NGHTTP2_CTRL, the |frame| must be a pointer to * nghttp2_frame. If the |frame_cat| is NGHTTP2_DATA, it must be a - * pointer to nghttp2_data. |aux_data| is a pointer to the arbitrary + * pointer to nghttp2_private_data. |aux_data| is a pointer to the arbitrary * data. Its interpretation is defined per the type of the frame. When * this function succeeds, it takes ownership of |frame| and * |aux_data|, so caller must not free them on success. @@ -530,7 +530,7 @@ nghttp2_stream* nghttp2_session_get_stream(nghttp2_session *session, ssize_t nghttp2_session_pack_data(nghttp2_session *session, uint8_t **buf_ptr, size_t *buflen_ptr, size_t datamax, - nghttp2_data *frame); + nghttp2_private_data *frame); /* * Returns top of outbound frame queue. This function returns NULL if diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index ced1a831..e74ec94d 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -301,10 +301,10 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, const nghttp2_data_provider *data_prd) { int r; - nghttp2_data *data_frame; + nghttp2_private_data *data_frame; uint8_t nflags = 0; - data_frame = malloc(sizeof(nghttp2_data)); + data_frame = malloc(sizeof(nghttp2_private_data)); if(data_frame == NULL) { return NGHTTP2_ERR_NOMEM; } diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 8cd5cc4d..f63d931e 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -3576,7 +3576,7 @@ void test_nghttp2_session_data_read_temporal_failure(void) my_user_data ud; nghttp2_data_provider data_prd; nghttp2_frame frame; - nghttp2_data *data_frame; + nghttp2_private_data *data_frame; nghttp2_stream *stream; size_t data_size = 128*1024; @@ -3599,7 +3599,7 @@ void test_nghttp2_session_data_read_temporal_failure(void) stream = nghttp2_session_get_stream(session, 1); CU_ASSERT(NULL != stream->deferred_data); CU_ASSERT(NGHTTP2_CAT_DATA == stream->deferred_data->frame_cat); - data_frame = (nghttp2_data*)stream->deferred_data->frame; + data_frame = (nghttp2_private_data*)stream->deferred_data->frame; data_frame->data_prd.read_callback = temporal_failure_data_source_read_callback;