Skip to content

Commit 2f557fb

Browse files
committed
align conventions
1 parent c28fa73 commit 2f557fb

25 files changed

+606
-593
lines changed

ngx_child_http_request.c

+53-53
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
typedef struct {
1515
ngx_buf_t* request_buffer;
1616
ngx_http_status_t status;
17-
} child_request_base_context_t; // fields common to dump requests and child requests
17+
} ngx_child_request_base_context_t; // fields common to dump requests and child requests
1818

1919
typedef struct {
20-
child_request_base_context_t base; // must be first
20+
ngx_child_request_base_context_t base; // must be first
2121

22-
child_request_callback_t callback;
22+
ngx_child_request_callback_t callback;
2323
void* callback_context;
2424

2525
u_char* headers_buffer;
@@ -31,7 +31,7 @@ typedef struct {
3131
off_t response_buffer_size;
3232

3333
ngx_http_upstream_conf_t* upstream_conf;
34-
} child_request_context_t;
34+
} ngx_child_request_context_t;
3535

3636
// globals
3737
static ngx_str_t child_http_hide_headers[] = {
@@ -47,7 +47,7 @@ static ngx_int_t
4747
ngx_http_vod_create_request(ngx_http_request_t *r)
4848
{
4949
ngx_chain_t *cl;
50-
child_request_base_context_t* ctx;
50+
ngx_child_request_base_context_t* ctx;
5151

5252
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ngx_http_vod_create_request: started");
5353

@@ -88,7 +88,7 @@ ngx_http_vod_reinit_request(ngx_http_request_t *r)
8888
static ngx_int_t
8989
ngx_http_vod_process_header(ngx_http_request_t *r)
9090
{
91-
child_request_context_t* ctx;
91+
ngx_child_request_context_t* ctx;
9292
ngx_http_upstream_t *u;
9393
ngx_table_elt_t *h;
9494
ngx_int_t rc;
@@ -173,7 +173,7 @@ ngx_http_vod_process_header(ngx_http_request_t *r)
173173

174174
if (rc == NGX_HTTP_PARSE_HEADER_DONE) // finished reading all headers
175175
{
176-
// in case of dump_request, no need to do anything
176+
// in case of ngx_dump_request, no need to do anything
177177
if (is_dump_request(r))
178178
{
179179
return NGX_OK;
@@ -235,7 +235,7 @@ ngx_http_vod_process_header(ngx_http_request_t *r)
235235
static ngx_int_t
236236
ngx_http_vod_process_status_line(ngx_http_request_t *r)
237237
{
238-
child_request_base_context_t* ctx;
238+
ngx_child_request_base_context_t* ctx;
239239
ngx_http_upstream_t *u;
240240
size_t len;
241241
ngx_int_t rc;
@@ -299,7 +299,7 @@ ngx_http_vod_abort_request(ngx_http_request_t *r)
299299
static ngx_int_t
300300
ngx_http_vod_filter_init(void *data)
301301
{
302-
child_request_context_t* ctx;
302+
ngx_child_request_context_t* ctx;
303303
ngx_http_request_t *r = data;
304304
ngx_http_upstream_t *u;
305305

@@ -337,7 +337,7 @@ ngx_http_vod_filter(void *data, ssize_t bytes)
337337
}
338338

339339
static ngx_int_t
340-
create_upstream(
340+
ngx_create_upstream(
341341
ngx_http_request_t *r,
342342
ngx_http_upstream_conf_t* conf)
343343
{
@@ -349,7 +349,7 @@ create_upstream(
349349
if (rc != NGX_OK)
350350
{
351351
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
352-
"create_upstream: failed to create upstream rc=%i", rc);
352+
"ngx_create_upstream: failed to create upstream rc=%i", rc);
353353
return NGX_ERROR;
354354
}
355355

@@ -372,7 +372,7 @@ create_upstream(
372372
}
373373

374374
static ngx_flag_t
375-
should_proxy_header(ngx_table_elt_t* header, child_request_params_t* params)
375+
ngx_should_proxy_header(ngx_table_elt_t* header, ngx_child_request_params_t* params)
376376
{
377377
if (header->key.len == sizeof("host") - 1 &&
378378
ngx_memcmp(header->lowcase_key, "host", sizeof("host") - 1) == 0)
@@ -398,10 +398,10 @@ should_proxy_header(ngx_table_elt_t* header, child_request_params_t* params)
398398
}
399399

400400
static ngx_buf_t*
401-
init_request_buffer(
401+
ngx_init_request_buffer(
402402
ngx_http_request_t *r,
403403
ngx_buf_t* request_buffer,
404-
child_request_params_t* params)
404+
ngx_child_request_params_t* params)
405405
{
406406
ngx_http_core_srv_conf_t *cscf;
407407
ngx_list_part_t *part;
@@ -453,7 +453,7 @@ init_request_buffer(
453453
i = 0;
454454
}
455455

456-
if (!should_proxy_header(&header[i], params))
456+
if (!ngx_should_proxy_header(&header[i], params))
457457
{
458458
continue;
459459
}
@@ -475,7 +475,7 @@ init_request_buffer(
475475
if (b == NULL)
476476
{
477477
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
478-
"init_request_buffer: ngx_create_temp_buf failed");
478+
"ngx_init_request_buffer: ngx_create_temp_buf failed");
479479
return NULL;
480480
}
481481
p = b->last;
@@ -537,7 +537,7 @@ init_request_buffer(
537537
i = 0;
538538
}
539539

540-
if (!should_proxy_header(&header[i], params))
540+
if (!ngx_should_proxy_header(&header[i], params))
541541
{
542542
continue;
543543
}
@@ -560,39 +560,39 @@ init_request_buffer(
560560
}
561561

562562
ngx_int_t
563-
dump_request(
563+
ngx_dump_request(
564564
ngx_http_request_t *r,
565565
ngx_http_upstream_conf_t* upstream_conf,
566-
child_request_params_t* params)
566+
ngx_child_request_params_t* params)
567567
{
568-
child_request_base_context_t* ctx;
568+
ngx_child_request_base_context_t* ctx;
569569
ngx_int_t rc;
570570

571-
// replace the module context - after calling dump_request the caller is not allowed to use the context
571+
// replace the module context - after calling ngx_dump_request the caller is not allowed to use the context
572572
ctx = ngx_pcalloc(r->pool, sizeof(*ctx));
573573
if (ctx == NULL)
574574
{
575575
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
576-
"dump_request: ngx_pcalloc failed");
576+
"ngx_dump_request: ngx_pcalloc failed");
577577
return NGX_ERROR;
578578
}
579579
ngx_http_set_ctx(r, ctx, ngx_http_vod_module);
580580

581581
// create an upstream
582-
rc = create_upstream(r, upstream_conf);
582+
rc = ngx_create_upstream(r, upstream_conf);
583583
if (rc != NGX_OK)
584584
{
585585
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
586-
"dump_request: create_upstream failed %i", rc);
586+
"ngx_dump_request: ngx_create_upstream failed %i", rc);
587587
return rc;
588588
}
589589

590590
// build the request
591-
ctx->request_buffer = init_request_buffer(r, NULL, params);
591+
ctx->request_buffer = ngx_init_request_buffer(r, NULL, params);
592592
if (ctx->request_buffer == NULL)
593593
{
594594
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
595-
"dump_request: init_request_buffer failed");
595+
"ngx_dump_request: ngx_init_request_buffer failed");
596596
return NGX_ERROR;
597597
}
598598

@@ -603,19 +603,19 @@ dump_request(
603603
}
604604

605605
ngx_int_t
606-
child_request_internal_handler(ngx_http_request_t *r)
606+
ngx_child_request_internal_handler(ngx_http_request_t *r)
607607
{
608-
child_request_context_t* ctx;
608+
ngx_child_request_context_t* ctx;
609609
ngx_http_upstream_t *u;
610610
ngx_int_t rc;
611611

612612
// create the upstream
613613
ctx = ngx_http_get_module_ctx(r, ngx_http_vod_module);
614-
rc = create_upstream(r, ctx->upstream_conf);
614+
rc = ngx_create_upstream(r, ctx->upstream_conf);
615615
if (rc != NGX_OK)
616616
{
617617
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
618-
"child_request_internal_handler: create_upstream failed %i", rc);
618+
"ngx_child_request_internal_handler: ngx_create_upstream failed %i", rc);
619619
return rc;
620620
}
621621

@@ -632,7 +632,7 @@ child_request_internal_handler(ngx_http_request_t *r)
632632
if (ngx_list_init(&u->headers_in.headers, r->pool, 8, sizeof(ngx_table_elt_t)) != NGX_OK)
633633
{
634634
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
635-
"child_request_internal_handler: ngx_list_init failed");
635+
"ngx_child_request_internal_handler: ngx_list_init failed");
636636
return NGX_ERROR;
637637
}
638638

@@ -652,9 +652,9 @@ child_request_internal_handler(ngx_http_request_t *r)
652652
}
653653

654654
static ngx_int_t
655-
child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
655+
ngx_child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
656656
{
657-
child_request_context_t* ctx;
657+
ngx_child_request_context_t* ctx;
658658
ngx_http_upstream_t *u;
659659

660660
ctx = ngx_http_get_module_ctx(r, ngx_http_vod_module);
@@ -664,21 +664,21 @@ child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
664664
}
665665

666666
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
667-
"child_request_finished_handler: called rc=%i, r=%p", rc, r);
667+
"ngx_child_request_finished_handler: called rc=%i, r=%p", rc, r);
668668

669669
u = r->upstream;
670670
if (rc == NGX_OK)
671671
{
672672
if (u->state && u->state->status != NGX_HTTP_OK && u->state->status != NGX_HTTP_PARTIAL_CONTENT)
673673
{
674674
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
675-
"child_request_finished_handler: upstream returned a bad status %ui", u->state->status);
675+
"ngx_child_request_finished_handler: upstream returned a bad status %ui", u->state->status);
676676
rc = NGX_HTTP_BAD_GATEWAY;
677677
}
678678
else if (u->length != 0)
679679
{
680680
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
681-
"child_request_finished_handler: upstream connection was closed with %O bytes left to read", u->length);
681+
"ngx_child_request_finished_handler: upstream connection was closed with %O bytes left to read", u->length);
682682
rc = NGX_HTTP_BAD_GATEWAY;
683683
}
684684
}
@@ -691,18 +691,18 @@ child_request_finished_handler(ngx_http_request_t *r, void *data, ngx_int_t rc)
691691

692692
// Note: must not return positive error codes (like NGX_HTTP_INTERNAL_SERVER_ERROR)
693693
ngx_int_t
694-
child_request_start(
694+
ngx_child_request_start(
695695
ngx_http_request_t *r,
696-
child_request_buffers_t* buffers,
697-
child_request_callback_t callback,
696+
ngx_child_request_buffers_t* buffers,
697+
ngx_child_request_callback_t callback,
698698
void* callback_context,
699699
ngx_http_upstream_conf_t* upstream_conf,
700700
ngx_str_t* internal_location,
701-
child_request_params_t* params,
701+
ngx_child_request_params_t* params,
702702
off_t max_response_length,
703703
u_char* response_buffer)
704704
{
705-
child_request_context_t* child_ctx;
705+
ngx_child_request_context_t* child_ctx;
706706
ngx_http_post_subrequest_t *psr;
707707
ngx_http_request_t *sr;
708708
ngx_str_t args = ngx_null_string;
@@ -723,17 +723,17 @@ child_request_start(
723723
if (buffers->headers_buffer == NULL)
724724
{
725725
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
726-
"child_request_start: ngx_palloc failed (1)");
726+
"ngx_child_request_start: ngx_palloc failed (1)");
727727
return NGX_ERROR;
728728
}
729729
}
730730

731731
// initialize the request buffer
732-
buffers->request_buffer = init_request_buffer(r, buffers->request_buffer, params);
732+
buffers->request_buffer = ngx_init_request_buffer(r, buffers->request_buffer, params);
733733
if (buffers->request_buffer == NULL)
734734
{
735735
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
736-
"child_request_start: init_request_buffer failed");
736+
"ngx_child_request_start: ngx_init_request_buffer failed");
737737
return NGX_ERROR;
738738
}
739739

@@ -742,7 +742,7 @@ child_request_start(
742742
if (child_ctx == NULL)
743743
{
744744
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
745-
"child_request_start: ngx_pcalloc failed");
745+
"ngx_child_request_start: ngx_pcalloc failed");
746746
return NGX_ERROR;
747747
}
748748

@@ -762,7 +762,7 @@ child_request_start(
762762
if (uri.data == NULL)
763763
{
764764
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
765-
"child_request_start: ngx_palloc failed (2)");
765+
"ngx_child_request_start: ngx_palloc failed (2)");
766766
return NGX_ERROR;
767767
}
768768
p = ngx_copy(uri.data, internal_location->data, internal_location->len);
@@ -775,32 +775,32 @@ child_request_start(
775775
if (psr == NULL)
776776
{
777777
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
778-
"child_request_start: ngx_palloc failed (3)");
778+
"ngx_child_request_start: ngx_palloc failed (3)");
779779
return NGX_ERROR;
780780
}
781781

782-
psr->handler = child_request_finished_handler;
782+
psr->handler = ngx_child_request_finished_handler;
783783
psr->data = r;
784784

785785
rc = ngx_http_subrequest(r, &uri, &args, &sr, psr, NGX_HTTP_SUBREQUEST_WAITED | NGX_HTTP_SUBREQUEST_IN_MEMORY);
786786
if (rc == NGX_ERROR)
787787
{
788788
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
789-
"child_request_start: ngx_http_subrequest failed %i", rc);
789+
"ngx_child_request_start: ngx_http_subrequest failed %i", rc);
790790
return rc;
791791
}
792792

793793
// set the context of the subrequest
794794
ngx_http_set_ctx(sr, child_ctx, ngx_http_vod_module);
795795

796796
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
797-
"child_request_start: completed successfully sr=%p", sr);
797+
"ngx_child_request_start: completed successfully sr=%p", sr);
798798

799799
return NGX_AGAIN;
800800
}
801801

802802
void
803-
child_request_free_buffers(ngx_pool_t* pool, child_request_buffers_t* buffers)
803+
ngx_child_request_free_buffers(ngx_pool_t* pool, ngx_child_request_buffers_t* buffers)
804804
{
805805
ngx_pfree(pool, buffers->headers_buffer);
806806
buffers->headers_buffer = NULL;
@@ -809,7 +809,7 @@ child_request_free_buffers(ngx_pool_t* pool, child_request_buffers_t* buffers)
809809
}
810810

811811
void
812-
init_upstream_conf(ngx_http_upstream_conf_t* upstream)
812+
ngx_init_upstream_conf(ngx_http_upstream_conf_t* upstream)
813813
{
814814
upstream->connect_timeout = NGX_CONF_UNSET_MSEC;
815815
upstream->send_timeout = NGX_CONF_UNSET_MSEC;
@@ -836,7 +836,7 @@ init_upstream_conf(ngx_http_upstream_conf_t* upstream)
836836
}
837837

838838
char *
839-
merge_upstream_conf(
839+
ngx_merge_upstream_conf(
840840
ngx_conf_t *cf,
841841
ngx_http_upstream_conf_t* conf_upstream,
842842
ngx_http_upstream_conf_t* prev_upstream)

0 commit comments

Comments
 (0)