diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 08:51:06 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-30 08:51:06 +0000 |
| commit | 68ee8f144242965c9650ad99604d1717c0f84c18 (patch) | |
| tree | 7327fe5fcc7b45d0ade16767c74e918b8ba6f328 /src/core | |
| parent | 14be46ee9862352fc055da8005e9bdf3dd1bc16e (diff) | |
| download | nginx-68ee8f144242965c9650ad99604d1717c0f84c18.tar.gz nginx-68ee8f144242965c9650ad99604d1717c0f84c18.tar.bz2 | |
nginx-0.0.1-2003-10-30-11:51:06 import
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/ngx_conf_file.c | 49 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.h | 12 | ||||
| -rw-r--r-- | src/core/ngx_hunk.c | 90 | ||||
| -rw-r--r-- | src/core/ngx_hunk.h | 9 | ||||
| -rw-r--r-- | src/core/ngx_output_chain.c | 6 |
5 files changed, 74 insertions, 92 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index e9e931525..5818636a8 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -61,7 +61,7 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename) } ngx_test_null(cf->conf_file->hunk, - ngx_create_temp_hunk(cf->pool, 1024, 0, 0), + ngx_create_temp_hunk(cf->pool, 1024), NGX_CONF_ERROR); cf->conf_file->file.fd = fd; @@ -722,7 +722,7 @@ char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - char *p = conf; + char *p = conf; ngx_str_t *value; ngx_bufs_t *bufs; @@ -749,6 +749,51 @@ char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } +char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + char *p = conf; + + int *np, i, m; + ngx_str_t *value; + ngx_conf_bitmask_t *mask; + + + np = (int *) (p + cmd->offset); + value = (ngx_str_t *) cf->args->elts; + mask = cmd->post; + + for (i = 1; i < cf->args->nelts; i++) { + for (m = 0; mask[m].name.len != 0; m++) { + + if (mask[m].name.len != value[i].len + && ngx_strcasecmp(mask[m].name.data, value[i].data) != 0) + { + continue; + } + + if (*np & mask[m].mask) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "duplicate value \"%s\"", value[i].data); + + } else { + *np |= mask[m].mask; + } + + break; + } + + if (mask[m].name.len == 0) { + ngx_conf_log_error(NGX_LOG_WARN, cf, 0, + "invalid value \"%s\"", value[i].data); + + return NGX_CONF_ERROR; + } + } + + return NGX_CONF_OK; +} + + char *ngx_conf_unsupported(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { return "unsupported on this platform"; diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index c132d07ac..4bf674751 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -150,6 +150,12 @@ typedef struct { } ngx_conf_num_bounds_t; +typedef struct { + ngx_str_t name; + int mask; +} ngx_conf_bitmask_t; + + char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); @@ -214,6 +220,11 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); } \ } +#define ngx_conf_merge_bitmask_value(conf, prev, default) \ + if (conf == 0) { \ + conf = (prev == 0) ? default : prev; \ + } + #define addressof(addr) ((int) &addr) @@ -233,6 +244,7 @@ char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c index d69c0df58..3799cef78 100644 --- a/src/core/ngx_hunk.c +++ b/src/core/ngx_hunk.c @@ -3,19 +3,21 @@ #include <ngx_core.h> -ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, - int before, int after) +ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size) { ngx_hunk_t *h; - ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); + ngx_test_null(h, ngx_alloc_hunk(pool), NULL); - ngx_test_null(h->pre_start, ngx_palloc(pool, size + before + after), NULL); + ngx_test_null(h->start, ngx_palloc(pool, size), NULL); + + h->pos = h->start; + h->last = h->start; + + h->file_pos = 0; + h->file_last = 0; - h->start = h->pos = h->last = h->pre_start + before; - h->file_pos = h->file_last = 0; h->end = h->last + size; - h->post_end = h->end + after; h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; h->file = NULL; @@ -68,80 +70,6 @@ ngx_chain_t *ngx_create_chain_of_hunks(ngx_pool_t *pool, ngx_bufs_t *bufs) } -ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) -{ - ngx_hunk_t *h; - - ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); - - if (hunk->type & NGX_HUNK_TEMP && hunk->pos - hunk->pre_start >= size) { - /* keep hunk->start unchanged - used in restore */ - h->pre_start = hunk->pre_start; - h->end = h->post_end = hunk->pre_start = hunk->pos; - h->start = h->pos = h->last = h->end - size; - h->file_pos = h->file_last = 0; - - h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; - h->file = NULL; - h->shadow = NULL; - - h->tag = 0; - - } else { - ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); - h->start = h->pos = h->last = h->pre_start; - h->end = h->post_end = h->start + size; - h->file_pos = h->file_last = 0; - - h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; - h->file = NULL; - h->shadow = NULL; - - h->tag = 0; - } - - return h; -} - - -ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) -{ - ngx_hunk_t *h; - - ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); - - if (hunk->type & NGX_HUNK_TEMP - && hunk->last == hunk->end - && hunk->post_end - hunk->end >= size) - { - h->post_end = hunk->post_end; - h->pre_start = h->start = h->pos = h->last = hunk->post_end = - hunk->last; - h->file_pos = h->file_last = 0; - - h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; - h->file = NULL; - h->shadow = NULL; - - h->tag = 0; - - } else { - ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); - h->start = h->pos = h->last = h->pre_start; - h->end = h->post_end = h->start + size; - h->file_pos = h->file_last = 0; - - h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; - h->file = NULL; - h->shadow = NULL; - - h->tag = 0; - } - - return h; -} - - int ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in) { ngx_chain_t *cl, **ll; diff --git a/src/core/ngx_hunk.h b/src/core/ngx_hunk.h index 82c5cc6f4..3de78aa20 100644 --- a/src/core/ngx_hunk.h +++ b/src/core/ngx_hunk.h @@ -50,8 +50,6 @@ struct ngx_hunk_s { int type; char *start; /* start of hunk */ char *end; /* end of hunk */ - char *pre_start; /* start of pre-allocated hunk */ - char *post_end; /* end of post-allocated hunk */ ngx_hunk_tag_t tag; ngx_file_t *file; ngx_hunk_t *shadow; @@ -100,7 +98,7 @@ typedef struct { ngx_chain_t **last; ngx_connection_t *connection; ngx_pool_t *pool; -} ngx_chain_write_ctx_t; +} ngx_chain_writer_ctx_t; #define NGX_CHAIN_ERROR (ngx_chain_t *) NGX_ERROR @@ -123,8 +121,7 @@ typedef struct { (size_t) (h->file_last - h->file_pos)) -ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, - int before, int after); +ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size); #define ngx_alloc_hunk(pool) ngx_palloc(pool, sizeof(ngx_hunk_t)) #define ngx_calloc_hunk(pool) ngx_pcalloc(pool, sizeof(ngx_hunk_t)) @@ -151,7 +148,7 @@ ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in); -int ngx_chain_write(void *data, ngx_chain_t *in); +int ngx_chain_writer(void *data, ngx_chain_t *in); int ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in); void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy, diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index 4ab9b96aa..b50cf9074 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -108,7 +108,7 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) } ngx_test_null(ctx->hunk, - ngx_create_temp_hunk(ctx->pool, size, 0, 0), + ngx_create_temp_hunk(ctx->pool, size), NGX_ERROR); ctx->hunk->tag = ctx->tag; ctx->hunk->type |= NGX_HUNK_RECYCLED; @@ -253,9 +253,9 @@ ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _ } -int ngx_chain_write(void *data, ngx_chain_t *in) +int ngx_chain_writer(void *data, ngx_chain_t *in) { - ngx_chain_write_ctx_t *ctx = data; + ngx_chain_writer_ctx_t *ctx = data; ngx_chain_t *cl; |
