Commit bf35d0f9 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

renaming some functions, constants and variables

parent b434a517
......@@ -70,7 +70,7 @@ typedef struct {
} ngx_http_push_stream_loc_conf_t;
// shared memory segment name
static ngx_str_t ngx_push_stream_shm_name = ngx_string("push_stream_module");
static ngx_str_t ngx_http_push_stream_shm_name = ngx_string("push_stream_module");
// message queue
typedef struct {
......@@ -199,7 +199,7 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_EMPTY = ngx_string("");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_BACKTRACK_SEP = ngx_string(".b");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_SLASH = ngx_string("/");
static const ngx_str_t NGX_PUSH_STREAM_DATE_FORMAT_ISO_8601 = ngx_string("%4d-%02d-%02dT%02d:%02d:%02d");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_DATE_FORMAT_ISO_8601 = ngx_string("%4d-%02d-%02dT%02d:%02d:%02d");
//// headers
static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_ALLOW = ngx_string("Allow");
......
......@@ -179,13 +179,13 @@ static ngx_http_push_stream_content_subtype_t subtypes[] = {
&NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_LAST_ITEM_YAML }
};
static const ngx_int_t NGX_PUSH_STREAM_PING_MESSAGE_ID = -1;
static const ngx_str_t NGX_PUSH_STREAM_PING_MESSAGE_TEXT = ngx_string("");
static const ngx_str_t NGX_PUSH_STREAM_PING_CHANNEL_ID = ngx_string("");
static const ngx_int_t NGX_HTTP_PUSH_STREAM_PING_MESSAGE_ID = -1;
static const ngx_str_t NGX_HTTP_PUSH_STREAM_PING_MESSAGE_TEXT = ngx_string("");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_PING_CHANNEL_ID = ngx_string("");
static const ngx_str_t NGX_PUSH_STREAM_TOKEN_MESSAGE_ID = ngx_string("~id~");
static const ngx_str_t NGX_PUSH_STREAM_TOKEN_MESSAGE_CHANNEL = ngx_string("~channel~");
static const ngx_str_t NGX_PUSH_STREAM_TOKEN_MESSAGE_TEXT = ngx_string("~text~");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_ID = ngx_string("~id~");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_CHANNEL = ngx_string("~channel~");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_TEXT = ngx_string("~text~");
ngx_event_t ngx_http_push_stream_ping_event;
ngx_event_t ngx_http_push_stream_disconnect_event;
......@@ -203,7 +203,7 @@ static u_char * ngx_http_push_stream_str_replace(u_char *org, u_char
static ngx_str_t * ngx_http_push_stream_get_formatted_message(ngx_http_request_t *r, ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_pool_t *temp_pool);
static ngx_str_t * ngx_http_push_stream_format_message(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *message, ngx_str_t message_template, ngx_pool_t *temp_pool);
static ngx_int_t ngx_http_push_stream_send_response_content_header(ngx_http_request_t *r, ngx_http_push_stream_loc_conf_t *pslcf);
static ngx_int_t ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const u_char *chunk_text, uint chunk_len, ngx_flag_t last_buffer);
static ngx_int_t ngx_http_push_stream_send_response_text(ngx_http_request_t *r, const u_char *text, uint len, ngx_flag_t last_buffer);
static ngx_int_t ngx_http_push_stream_send_ping(ngx_log_t *log, ngx_http_push_stream_loc_conf_t *pslcf);
static ngx_int_t ngx_http_push_stream_memory_cleanup(ngx_log_t *log, ngx_http_push_stream_main_conf_t *psmcf);
static ngx_int_t ngx_http_push_stream_buffer_cleanup(ngx_log_t *log, ngx_http_push_stream_loc_conf_t *pslcf);
......
......@@ -299,9 +299,9 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
return rc;
}
ngx_http_push_stream_send_response_chunk(r, header_response.data, header_response.len,0);
ngx_http_push_stream_send_response_text(r, header_response.data, header_response.len,0);
ngx_http_output_filter(r, first);
return ngx_http_push_stream_send_response_chunk(r, tail->data, tail->len, 1);
return ngx_http_push_stream_send_response_text(r, tail->data, tail->len, 1);
}
static ngx_int_t
......
......@@ -317,7 +317,7 @@ ngx_http_push_stream_send_worker_ping_message(void)
if (cur->request != NULL) {
ngx_str_t *str = ngx_http_push_stream_get_formatted_message(cur->request, NULL, ngx_http_push_stream_ping_msg, cur->request->pool);
if (str != NULL) {
ngx_http_push_stream_send_response_chunk(cur->request, str->data, str->len, 0);
ngx_http_push_stream_send_response_text(cur->request, str->data, str->len, 0);
}
}
}
......@@ -450,7 +450,7 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan
while ((cur = (ngx_http_push_stream_subscriber_t *) ngx_queue_next(&cur->queue)) != sentinel) {
ngx_str_t *str = ngx_http_push_stream_get_formatted_message(cur->request, channel, msg, cur->request->pool);
if (str != NULL) {
ngx_http_push_stream_send_response_chunk(cur->request, str->data, str->len, 0);
ngx_http_push_stream_send_response_text(cur->request, str->data, str->len, 0);
}
}
}
......
......@@ -563,7 +563,7 @@ ngx_http_push_stream_subscriber(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static ngx_int_t
ngx_http_push_stream_set_up_shm(ngx_conf_t *cf, size_t shm_size)
{
ngx_http_push_stream_shm_zone = ngx_shared_memory_add(cf, &ngx_push_stream_shm_name, shm_size, &ngx_http_push_stream_module);
ngx_http_push_stream_shm_zone = ngx_shared_memory_add(cf, &ngx_http_push_stream_shm_name, shm_size, &ngx_http_push_stream_module);
if (ngx_http_push_stream_shm_zone == NULL) {
return NGX_ERROR;
......@@ -615,7 +615,7 @@ ngx_http_push_stream_init_shm_zone(ngx_shm_zone_t *shm_zone, void *data)
ngx_rbtree_init(&d->channels_to_delete, remove_sentinel, ngx_http_push_stream_rbtree_insert);
// create ping message
ngx_http_push_stream_ping_msg = ngx_http_push_stream_convert_char_to_msg_on_shared_locked(NGX_PUSH_STREAM_PING_MESSAGE_TEXT.data, NGX_PUSH_STREAM_PING_MESSAGE_TEXT.len, NULL, NGX_PUSH_STREAM_PING_MESSAGE_ID, ngx_cycle->pool);
ngx_http_push_stream_ping_msg = ngx_http_push_stream_convert_char_to_msg_on_shared_locked(NGX_HTTP_PUSH_STREAM_PING_MESSAGE_TEXT.data, NGX_HTTP_PUSH_STREAM_PING_MESSAGE_TEXT.len, NULL, NGX_HTTP_PUSH_STREAM_PING_MESSAGE_ID, ngx_cycle->pool);
if (ngx_http_push_stream_ping_msg == NULL) {
return NGX_ERROR;
}
......
......@@ -271,7 +271,7 @@ ngx_http_push_stream_subscriber_assign_channel(ngx_slab_pool_t *shpool, ngx_http
if (start == 0) {
ngx_str_t *str = ngx_http_push_stream_get_formatted_message(r, channel, message, r->pool);
if (str != NULL) {
ngx_http_push_stream_send_response_chunk(r, str->data, str->len, 0);
ngx_http_push_stream_send_response_text(r, str->data, str->len, 0);
}
qtd--;
......
......@@ -164,19 +164,19 @@ ngx_http_push_stream_send_response_content_header(ngx_http_request_t *r, ngx_htt
ngx_int_t rc = NGX_OK;
if (pslcf->header_template.len > 0) {
rc = ngx_http_push_stream_send_response_chunk(r, pslcf->header_template.data, pslcf->header_template.len, 0);
rc = ngx_http_push_stream_send_response_text(r, pslcf->header_template.data, pslcf->header_template.len, 0);
}
return rc;
}
static ngx_int_t
ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const u_char *chunk_text, uint chunk_len, ngx_flag_t last_buffer)
ngx_http_push_stream_send_response_text(ngx_http_request_t *r, const u_char *text, uint len, ngx_flag_t last_buffer)
{
ngx_buf_t *b;
ngx_chain_t *out;
if (chunk_text == NULL) {
if (text == NULL) {
return NGX_ERROR;
}
......@@ -189,9 +189,9 @@ ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const u_char *ch
b->last_buf = last_buffer;
b->flush = 1;
b->memory = 1;
b->pos = (u_char *)chunk_text;
b->pos = (u_char *) text;
b->start = b->pos;
b->end = b->pos + chunk_len;
b->end = b->pos + len;
b->last = b->end;
out->buf = b;
......@@ -592,9 +592,9 @@ ngx_http_push_stream_format_message(ngx_http_push_stream_channel_t *channel, ngx
u_char char_id[NGX_INT_T_LEN];
ngx_memset(char_id, '\0', NGX_INT_T_LEN);
u_char *msg = NGX_PUSH_STREAM_PING_MESSAGE_TEXT.data;
u_char *channel_id = NGX_PUSH_STREAM_PING_CHANNEL_ID.data;
ngx_int_t message_id = NGX_PUSH_STREAM_PING_MESSAGE_ID;
u_char *msg = NGX_HTTP_PUSH_STREAM_PING_MESSAGE_TEXT.data;
u_char *channel_id = NGX_HTTP_PUSH_STREAM_PING_CHANNEL_ID.data;
ngx_int_t message_id = NGX_HTTP_PUSH_STREAM_PING_MESSAGE_ID;
if (channel != NULL) {
channel_id = channel->id.data;
......@@ -610,9 +610,9 @@ ngx_http_push_stream_format_message(ngx_http_push_stream_channel_t *channel, ngx
ngx_sprintf(char_id, "%d", message_id);
txt = ngx_http_push_stream_str_replace(template, NGX_PUSH_STREAM_TOKEN_MESSAGE_ID.data, char_id, 0, pool);
txt = ngx_http_push_stream_str_replace(txt, NGX_PUSH_STREAM_TOKEN_MESSAGE_CHANNEL.data, channel_id, 0, pool);
txt = ngx_http_push_stream_str_replace(txt, NGX_PUSH_STREAM_TOKEN_MESSAGE_TEXT.data, msg, 0, pool);
txt = ngx_http_push_stream_str_replace(template, NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_ID.data, char_id, 0, pool);
txt = ngx_http_push_stream_str_replace(txt, NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_CHANNEL.data, channel_id, 0, pool);
txt = ngx_http_push_stream_str_replace(txt, NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_TEXT.data, msg, 0, pool);
} else if (message != NULL) {
ngx_str_t msg = ngx_string(message->buf->pos);
......@@ -706,7 +706,7 @@ ngx_http_push_stream_get_formatted_current_time(ngx_pool_t *pool)
currenttime->data = (u_char *) (currenttime + 1);
ngx_memset(currenttime->data, '\0', 20);
ngx_gmtime(ngx_time(), &tm);
ngx_sprintf(currenttime->data, (char *) NGX_PUSH_STREAM_DATE_FORMAT_ISO_8601.data, tm.ngx_tm_year, tm.ngx_tm_mon, tm.ngx_tm_mday, tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec);
ngx_sprintf(currenttime->data, (char *) NGX_HTTP_PUSH_STREAM_DATE_FORMAT_ISO_8601.data, tm.ngx_tm_year, tm.ngx_tm_mon, tm.ngx_tm_mday, tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec);
currenttime->len = ngx_strlen(currenttime->data);
} else {
currenttime = &NGX_HTTP_PUSH_STREAM_EMPTY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment