From ee7c767c165ababe5649e0024d42e7429745e2f6 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 10 Jun 2013 01:20:28 +0200 Subject: [PATCH] Limited player upload peak using CLI max-chunks-per-second parameter --- src/Player.php | 4 ++-- src/constants/GeneralConstants.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Player.php b/src/Player.php index 3d2f4a4de..e2bd9ccbd 100644 --- a/src/Player.php +++ b/src/Player.php @@ -155,7 +155,7 @@ class Player{ foreach($this->chunkCount as $i => $count){ if(isset($this->recoveryQueue[$count])){ - $this->server->schedule(1, array($this, "getNextChunk")); + $this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk")); return; }else{ unset($this->chunkCount[$i]); @@ -207,7 +207,7 @@ class Player{ } } - $this->server->schedule(1, array($this, "getNextChunk")); + $this->server->schedule(MAX_CHUNK_RATE, array($this, "getNextChunk")); } public function save(){ diff --git a/src/constants/GeneralConstants.php b/src/constants/GeneralConstants.php index d6d609b4e..4b7592341 100644 --- a/src/constants/GeneralConstants.php +++ b/src/constants/GeneralConstants.php @@ -37,6 +37,7 @@ define("VIEWER", 3); //Players +define("MAX_CHUNK_RATE", 20 / arg("max-chunks-per-second", 3.5)); //Default rate ~172 kB/s define("PLAYER_MAX_RECOVERY_BUFFER", 1024); define("PLAYER_SURVIVAL_SLOTS", 36);