Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

origin nginx ngx_http_do_read_client_request_body did not limit upload rate , how did you do it ? #109

Open
ygm521 opened this issue Sep 4, 2018 · 0 comments

Comments

@ygm521
Copy link

ygm521 commented Sep 4, 2018

origin nginx ngx_http_do_read_client_request_body did not limit upload rate , if in function ngx_http_do_read_client_request_body limit upload rate, the cpu is 100%, how did you do it ?
whats the meanning of xxx , thanks!

static void /* {{{ ngx_http_read_upload_client_request_body_handler */
ngx_http_read_upload_client_request_body_handler(ngx_http_request_t *r)
{
	ngx_int_t  rc;
	ngx_http_upload_ctx_t     *u = ngx_http_get_module_ctx(r, ngx_http_upload_module);
	ngx_event_t               *rev = r->connection->read;
	ngx_http_core_loc_conf_t  *clcf;

	if (rev->timedout) {
		if(!rev->delayed) {
			r->connection->timedout = 1;
			upload_shutdown_ctx(u);
			ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
			return;
		}

		//xxx
		rev->timedout = 0;
		rev->delayed = 0;

		if (!rev->ready) {
			clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
			ngx_add_timer(rev, clcf->client_body_timeout);

			if (ngx_handle_read_event(rev, clcf->send_lowat) != NGX_OK) {
				upload_shutdown_ctx(u);
				ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
			}

			return;
		}
	}
	else{
		// xxx
		if (r->connection->read->delayed) {
			clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
			ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0,
						   "http read delayed");

			if (ngx_handle_read_event(rev, clcf->send_lowat) != NGX_OK) {
				upload_shutdown_ctx(u);
				ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
			}

			return;
		}
	}

	//读取请求的包体
	rc = ngx_http_do_read_upload_client_request_body(r);

	if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
		upload_shutdown_ctx(u);
		ngx_http_finalize_request(r, rc);
	}
} /* }}} */
@ygm521 ygm521 changed the title ngx_http_read_upload_client_request_body_handler origin nginx ngx_http_do_read_client_request_body did not limit upload rate , how did you do it ? Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant