Commit 636f84ba authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

change signature of ngx_http_push_stream_send_response_chunk method to simplify the use

parent 49ac6540
...@@ -151,7 +151,7 @@ static ngx_int_t ngx_http_push_stream_send_only_header_response(ngx_h ...@@ -151,7 +151,7 @@ static ngx_int_t ngx_http_push_stream_send_only_header_response(ngx_h
static u_char * ngx_http_push_stream_str_replace(u_char *org, u_char *find, u_char *replace, ngx_pool_t *temp_pool); static u_char * ngx_http_push_stream_str_replace(u_char *org, u_char *find, u_char *replace, ngx_pool_t *temp_pool);
static ngx_buf_t * ngx_http_push_stream_get_formatted_message(ngx_http_push_stream_loc_conf_t *pslcf, ngx_http_push_stream_channel_t *channel, ngx_buf_t *buf, ngx_pool_t *temp_pool); static ngx_buf_t * ngx_http_push_stream_get_formatted_message(ngx_http_push_stream_loc_conf_t *pslcf, ngx_http_push_stream_channel_t *channel, ngx_buf_t *buf, 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_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 ngx_str_t *chunk_text, ngx_flag_t last_buffer); 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_ping(ngx_log_t *log, ngx_http_push_stream_loc_conf_t *pslcf); 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_loc_conf_t *pslcf); static ngx_int_t ngx_http_push_stream_memory_cleanup(ngx_log_t *log, ngx_http_push_stream_loc_conf_t *pslcf);
......
...@@ -232,7 +232,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t ...@@ -232,7 +232,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
ngx_sprintf(header_response.data, (char *) head->data, hostname->data, currenttime->data, shm_data->channels, shm_data->broadcast_channels); ngx_sprintf(header_response.data, (char *) head->data, hostname->data, currenttime->data, shm_data->channels, shm_data->broadcast_channels);
header_response.len = ngx_strlen(header_response.data); header_response.len = ngx_strlen(header_response.data);
ngx_http_push_stream_send_response_chunk(r, &header_response, 0); ngx_http_push_stream_send_response_chunk(r, header_response.data, header_response.len,0);
// send content body // send content body
cur = ngx_queue_head(&queue_channel_info); cur = ngx_queue_head(&queue_channel_info);
...@@ -257,7 +257,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t ...@@ -257,7 +257,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
r->keepalive = 0; r->keepalive = 0;
// send content tail // send content tail
ngx_http_push_stream_send_response_chunk(r, tail, 1); ngx_http_push_stream_send_response_chunk(r, tail->data, tail->len, 1);
return NGX_DONE; return NGX_DONE;
} }
...@@ -263,11 +263,10 @@ ngx_http_push_stream_send_worker_ping_message(void) ...@@ -263,11 +263,10 @@ ngx_http_push_stream_send_worker_ping_message(void)
ngx_http_push_stream_worker_subscriber_t *cur = sentinel; ngx_http_push_stream_worker_subscriber_t *cur = sentinel;
if ((ngx_http_push_stream_ping_buf != NULL) && (!ngx_queue_empty(&sentinel->queue))) { if ((ngx_http_push_stream_ping_buf != NULL) && (!ngx_queue_empty(&sentinel->queue))) {
ngx_str_t aux = ngx_string(ngx_http_push_stream_ping_buf->pos); uint len = ngx_buf_size(ngx_http_push_stream_ping_buf);
aux.len = ngx_buf_size(ngx_http_push_stream_ping_buf);
while ((cur = (ngx_http_push_stream_worker_subscriber_t *) ngx_queue_next(&cur->queue)) != sentinel) { while ((cur = (ngx_http_push_stream_worker_subscriber_t *) ngx_queue_next(&cur->queue)) != sentinel) {
if (cur->request != NULL) { if (cur->request != NULL) {
ngx_http_push_stream_send_response_chunk(cur->request, &aux, 0); ngx_http_push_stream_send_response_chunk(cur->request, ngx_http_push_stream_ping_buf->pos, len, 0);
} }
} }
} }
...@@ -385,12 +384,11 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan ...@@ -385,12 +384,11 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan
cur = sentinel; cur = sentinel;
if (msg != NULL) { if (msg != NULL) {
ngx_str_t message = ngx_string(msg->buf->pos); uint len = ngx_buf_size(msg->buf);
message.len = ngx_buf_size(msg->buf);
// now let's respond to some requests! // now let's respond to some requests!
while ((cur = (ngx_http_push_stream_subscriber_t *) ngx_queue_next(&cur->queue)) != sentinel) { while ((cur = (ngx_http_push_stream_subscriber_t *) ngx_queue_next(&cur->queue)) != sentinel) {
ngx_http_push_stream_send_response_chunk(cur->request, &message, 0); ngx_http_push_stream_send_response_chunk(cur->request, msg->buf->pos, len, 0);
} }
} }
......
...@@ -240,10 +240,7 @@ ngx_http_push_stream_subscriber_assign_channel(ngx_slab_pool_t *shpool, ngx_http ...@@ -240,10 +240,7 @@ ngx_http_push_stream_subscriber_assign_channel(ngx_slab_pool_t *shpool, ngx_http
// positioning at first message, and send the others // positioning at first message, and send the others
while ((qtd > 0) && (!message->deleted) && ((message = (ngx_http_push_stream_msg_t *) ngx_queue_next(&message->queue)) != message_sentinel)) { while ((qtd > 0) && (!message->deleted) && ((message = (ngx_http_push_stream_msg_t *) ngx_queue_next(&message->queue)) != message_sentinel)) {
if (start == 0) { if (start == 0) {
ngx_str_t msg = ngx_string(message->buf->pos); ngx_http_push_stream_send_response_chunk(r, message->buf->pos, ngx_buf_size(message->buf), 0);
msg.len = ngx_buf_size(message->buf);
ngx_http_push_stream_send_response_chunk(r, &msg, 0);
qtd--; qtd--;
} else { } else {
......
...@@ -112,14 +112,14 @@ ngx_http_push_stream_send_response_content_header(ngx_http_request_t *r, ngx_htt ...@@ -112,14 +112,14 @@ ngx_http_push_stream_send_response_content_header(ngx_http_request_t *r, ngx_htt
ngx_int_t rc = NGX_OK; ngx_int_t rc = NGX_OK;
if (pslcf->header_template.len > 0) { if (pslcf->header_template.len > 0) {
rc = ngx_http_push_stream_send_response_chunk(r, &pslcf->header_template, 0); rc = ngx_http_push_stream_send_response_chunk(r, pslcf->header_template.data, pslcf->header_template.len, 0);
} }
return rc; return rc;
} }
static ngx_int_t static ngx_int_t
ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const ngx_str_t *chunk_text, ngx_flag_t las_buffer) ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const u_char *chunk_text, uint chunk_len, ngx_flag_t las_buffer)
{ {
ngx_buf_t *b; ngx_buf_t *b;
ngx_chain_t *out; ngx_chain_t *out;
...@@ -137,9 +137,9 @@ ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const ngx_str_t ...@@ -137,9 +137,9 @@ ngx_http_push_stream_send_response_chunk(ngx_http_request_t *r, const ngx_str_t
b->last_buf = las_buffer; b->last_buf = las_buffer;
b->flush = 1; b->flush = 1;
b->memory = 1; b->memory = 1;
b->pos = chunk_text->data; b->pos = (u_char *)chunk_text;
b->start = b->pos; b->start = b->pos;
b->end = b->pos + chunk_text->len; b->end = b->pos + chunk_len;
b->last = b->end; b->last = b->end;
out->buf = b; out->buf = b;
......
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