Skip to content

Commit 6d1a043

Browse files
authored
Merge pull request unbit#2714 from jgoulard/uwsgi-2.0
Backporting the max-requests-delta option
2 parents 4d4a6cd + 19825ca commit 6d1a043

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

core/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ void uwsgi_close_request(struct wsgi_request *wsgi_req) {
11891189
// yes, this is pretty useless but we cannot ensure all of the plugin have the same behaviour
11901190
uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].in_request = 0;
11911191

1192-
if (uwsgi.max_requests > 0 && uwsgi.workers[uwsgi.mywid].delta_requests >= uwsgi.max_requests
1192+
if (uwsgi.max_requests > 0 && uwsgi.workers[uwsgi.mywid].delta_requests >= (uwsgi.max_requests + ((uwsgi.mywid-1) * uwsgi.max_requests_delta))
11931193
&& (end_of_request - (uwsgi.workers[uwsgi.mywid].last_spawn * 1000000) >= uwsgi.min_worker_lifetime * 1000000)) {
11941194
goodbye_cruel_world();
11951195
}

core/uwsgi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
277277

278278
{"reaper", no_argument, 'r', "call waitpid(-1,...) after each request to get rid of zombies", uwsgi_opt_true, &uwsgi.reaper, 0},
279279
{"max-requests", required_argument, 'R', "reload workers after the specified amount of managed requests", uwsgi_opt_set_64bit, &uwsgi.max_requests, 0},
280+
{"max-requests-delta", required_argument, 0, "add (worker_id * delta) to the max_requests value of each worker", uwsgi_opt_set_64bit, &uwsgi.max_requests_delta, 0},
280281
{"min-worker-lifetime", required_argument, 0, "number of seconds worker must run before being reloaded (default is 10)", uwsgi_opt_set_64bit, &uwsgi.min_worker_lifetime, 0},
281282
{"max-worker-lifetime", required_argument, 0, "reload workers after the specified amount of seconds (default is disabled)", uwsgi_opt_set_64bit, &uwsgi.max_worker_lifetime, 0},
282283
{"max-worker-lifetime-delta", required_argument, 0, "add (worker_id * delta) seconds to the max_worker_lifetime value of each worker", uwsgi_opt_set_int, &uwsgi.max_worker_lifetime_delta, 0},

uwsgi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,6 +2874,9 @@ struct uwsgi_server {
28742874
// uWSGI 2.0.27
28752875
// This pipe is used to stop event_queue_wait() in threaded workers.
28762876
int loop_stop_pipe[2];
2877+
2878+
// uWSGI 2.0.29
2879+
uint64_t max_requests_delta;
28772880
};
28782881

28792882
struct uwsgi_rpc {

0 commit comments

Comments
 (0)