Skip to content

Commit

Permalink
Merge pull request alibaba#265 from zhuzhaoyuan/fix-coding-style-1.5.0
Browse files Browse the repository at this point in the history
fixed coding style
  • Loading branch information
yaoweibin committed Jun 14, 2013
2 parents 0c15cfb + 9e5646a commit eb1a07a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/core/ngx_palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,21 @@ ngx_prealloc(ngx_pool_t *pool, void *p, size_t old_size, size_t new_size)

return NULL;
}

if (old_size <= pool->max) {
for (node = pool; node; node = node->d.next) {
if ((u_char *)p + old_size == node->d.last
&& (u_char *)p + new_size <= node->d.end) {
node->d.last = (u_char *)p + new_size;
return p;
}
}
}
}

if (new_size <= old_size) {
return p;
}

new = ngx_palloc(pool, new_size);
if (new == NULL) {
return NULL;
Expand Down
1 change: 0 additions & 1 deletion src/core/ngx_segment_tree.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@


/*
* Copyright (C) 2010-2013 Alibaba Group Holding Limited
*/
Expand Down
16 changes: 8 additions & 8 deletions src/http/modules/ngx_http_geoip_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static ngx_http_variable_t ngx_http_geoip_vars[] = {

{ ngx_string("geoip_country_code"), NULL,
ngx_http_geoip_country_variable,
NGX_GEOIP_COUNTRY_CODE, 0, 0 },
NGX_GEOIP_COUNTRY_CODE, 0, 0 },

{ ngx_string("geoip_country_code3"), NULL,
ngx_http_geoip_country_variable,
Expand Down Expand Up @@ -467,17 +467,17 @@ ngx_http_geoip_region_variable(ngx_http_request_t *r,
char *val;
size_t len;
GeoIPRegion *gr;

ngx_http_geoip_conf_t *gcf;

gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);

if (gcf->region == NULL) {
goto not_found;
}

gr = GeoIP_region_by_ipnum(gcf->region, ngx_http_geoip_addr(r, gcf));

if (gr == NULL) {
goto not_found;
}
Expand Down Expand Up @@ -840,7 +840,7 @@ ngx_http_geoip_region(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
}

switch (gcf->region->databaseType) {
case GEOIP_REGION_EDITION_REV0:
case GEOIP_REGION_EDITION_REV1:
Expand Down Expand Up @@ -1029,8 +1029,8 @@ ngx_http_geoip_cleanup(void *data)
if (gcf->country) {
GeoIP_delete(gcf->country);
}
if (gcf->region) {

if (gcf->region) {
GeoIP_delete(gcf->region);
}

Expand Down
3 changes: 2 additions & 1 deletion src/http/modules/ngx_http_upstream_keepalive_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ ngx_http_upstream_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)


static char *
ngx_http_upstream_keepalive_timeout(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_upstream_keepalive_timeout(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf)
{
ngx_http_upstream_srv_conf_t *uscf;
ngx_http_upstream_keepalive_srv_conf_t *kcf;
Expand Down
9 changes: 6 additions & 3 deletions src/http/modules/tfs/ngx_http_tfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ ngx_http_tfs_finalize_state(ngx_http_tfs_t *t, ngx_int_t rc)
if (t->decline_handler) {
rc = t->decline_handler(t);
if (rc == NGX_ERROR) {
ngx_http_tfs_finalize_request(r, t, NGX_HTTP_INTERNAL_SERVER_ERROR);
ngx_http_tfs_finalize_request(r, t,
NGX_HTTP_INTERNAL_SERVER_ERROR);
}
}
return;
Expand Down Expand Up @@ -2347,10 +2348,12 @@ ngx_http_tfs_batch_process_end(ngx_http_tfs_t *t)
}

if (t->request_timeout) {
ngx_http_tfs_finalize_request(t->data, t, NGX_HTTP_REQUEST_TIME_OUT);
ngx_http_tfs_finalize_request(t->data, t,
NGX_HTTP_REQUEST_TIME_OUT);

} else if (t->client_abort) {
ngx_http_tfs_finalize_request(t->data, t, NGX_HTTP_CLIENT_CLOSED_REQUEST);
ngx_http_tfs_finalize_request(t->data, t,
NGX_HTTP_CLIENT_CLOSED_REQUEST);

} else {
ngx_http_tfs_finalize_state(t, NGX_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/http/modules/tfs/ngx_http_tfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ struct ngx_http_tfs_main_conf_s {
ngx_msec_t tfs_read_timeout;

ngx_msec_t tair_timeout;
ngx_http_tfs_tair_instance_t dup_instances[NGX_HTTP_TFS_MAX_CLUSTER_COUNT];
ngx_http_tfs_tair_instance_t dup_instances[NGX_HTTP_TFS_MAX_CLUSTER_COUNT];

size_t send_lowat;
size_t buffer_size;
Expand Down
14 changes: 8 additions & 6 deletions src/http/modules/tfs/ngx_http_tfs_data_server_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,11 +1359,12 @@ ngx_http_tfs_get_segment_for_read(ngx_http_tfs_t *t)

/* find out the segment we should start with */
seg_count = t->seg_head->count;
max_seg_count = (b->last - (u_char *)seg_info) / sizeof(ngx_http_tfs_segment_info_t);
max_seg_count = (b->last - (u_char *) seg_info)
/ sizeof(ngx_http_tfs_segment_info_t);
if (t->seg_head->count > max_seg_count) {
ngx_log_error(NGX_LOG_ERR, t->log, 0,
"seg_count in seg_head larger than max seg_count, %uD > %uD, "
" seg_head may be corrupted.",
"seg_count in seg_head larger than max seg_count, "
"%uD > %uD, seg_head may be corrupted.",
t->seg_head->count, max_seg_count);
seg_count = max_seg_count - 1;
}
Expand Down Expand Up @@ -1592,11 +1593,12 @@ ngx_http_tfs_get_segment_for_delete(ngx_http_tfs_t *t)

/* all data segments plus meta segment */
seg_count = t->seg_head->count + 1;
max_seg_count = (b->last - (u_char *)seg_info) / sizeof(ngx_http_tfs_segment_info_t);
max_seg_count = (b->last - (u_char *) seg_info)
/ sizeof(ngx_http_tfs_segment_info_t);
if (t->seg_head->count > max_seg_count) {
ngx_log_error(NGX_LOG_ERR, t->log, 0,
"seg_count in seg_head larger than max seg_count, %uD > %uD, "
"seg_head may be corrupted",
"seg_count in seg_head larger than max seg_count, "
"%uD > %uD, seg_head may be corrupted",
t->seg_head->count, max_seg_count);
seg_count = max_seg_count;
}
Expand Down
6 changes: 4 additions & 2 deletions src/http/modules/tfs/ngx_http_tfs_duplicate.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ ngx_http_tfs_dedup_set(ngx_http_tfs_dedup_ctx_t *ctx,
data_len = 0;

if (!ctx->md5_sumed) {
rc = ngx_http_tfs_sum_md5(ctx->file_data, ctx->tair_key, &data_len, log);
rc = ngx_http_tfs_sum_md5(ctx->file_data, ctx->tair_key, &data_len,
log);
if (rc == NGX_ERROR) {
return NGX_ERROR;
}
Expand Down Expand Up @@ -192,7 +193,8 @@ ngx_http_tfs_dedup_remove(ngx_http_tfs_dedup_ctx_t *ctx,
data_len = 0;

if (!ctx->md5_sumed) {
rc = ngx_http_tfs_sum_md5(ctx->file_data, ctx->tair_key, &data_len, log);
rc = ngx_http_tfs_sum_md5(ctx->file_data, ctx->tair_key, &data_len,
log);
if (rc == NGX_ERROR) {
return NGX_ERROR;
}
Expand Down
3 changes: 2 additions & 1 deletion src/http/modules/tfs/ngx_http_tfs_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static void ngx_http_tfs_read_body_handler(ngx_http_request_t *r);
static char *ngx_http_tfs_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);

static char *ngx_http_tfs_rcs_heartbeat(ngx_conf_t *cf, ngx_http_tfs_upstream_t *tu);
static char *ngx_http_tfs_rcs_heartbeat(ngx_conf_t *cf,
ngx_http_tfs_upstream_t *tu);

static char *ngx_http_tfs_rcs_zone(ngx_conf_t *cf, ngx_http_tfs_upstream_t *tu);
static char *ngx_http_tfs_block_cache_zone(ngx_conf_t *cf, ngx_command_t *cmd,
Expand Down
3 changes: 2 additions & 1 deletion src/http/ngx_http_special_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ ngx_http_send_special_response(ngx_http_request_t *r,
: sizeof(ngx_http_error_banner) - 1;

} else if (clcf->server_tag_type == NGX_HTTP_SERVER_TAG_CUSTOMIZED) {
r->headers_out.content_length_n += sizeof(ngx_http_error_powered_by) - 1;
r->headers_out.content_length_n += sizeof(ngx_http_error_powered_by)
- 1;
r->headers_out.content_length_n += clcf->server_tag.len;
}

Expand Down
16 changes: 8 additions & 8 deletions src/os/unix/ngx_process_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,16 +1375,16 @@ ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data)
void *ident[4];
ngx_event_t ev;

/*
* Set correct process type since closing listening Unix domain socket
* in a master process also removes the Unix domain socket file.
*/
ngx_process = NGX_PROCESS_HELPER;
/*
* Set correct process type since closing listening Unix domain socket
* in a master process also removes the Unix domain socket file.
*/
ngx_process = NGX_PROCESS_HELPER;

ngx_close_listening_sockets(cycle);
ngx_close_listening_sockets(cycle);

/* Set a moderate number of connections for a helper process. */
cycle->connection_n = 512;
/* Set a moderate number of connections for a helper process. */
cycle->connection_n = 512;

ngx_worker_process_init(cycle, -1);

Expand Down

0 comments on commit eb1a07a

Please sign in to comment.