From: Matteo Nastasi Date: Sat, 4 Apr 2020 18:58:52 +0000 (+0200) Subject: sharding on sockets with input data X-Git-Tag: v5.8.0~8^2~2 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=56c0ce2aa8b9ddfc4cdf97802c5e70bc56577cc7;p=brisk.git sharding on sockets with input data --- diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index c187d91..2035e9d 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -706,7 +706,9 @@ class Sac_a_push { $lastime = 0; $dump_users = TRUE; + $sock_shard_cur = -1; while ($this->main_loop) { + $sock_shard_cur = ($sock_shard_cur + 1) % SOCK_SHARD_N; $this->app->sess_cur_set(FALSE); $this->curtime = time(); if ($lastime != ($this->curtime >> 2)) { @@ -828,7 +830,7 @@ class Sac_a_push { stream_set_blocking($new_unix, $this->blocking_mode); $this->direct_mgmt($new_unix); } // not socket_list nor socket_list_cmd - else { // already opened socket + else if ($id % SOCK_SHARD_N == $sock_shard_cur) { // already opened socket $buf = fread($sock, 4096); // if socket is closed if ($buf == FALSE || feof($sock)) { diff --git a/web/spush/brisk-spush.phh b/web/spush/brisk-spush.phh index 8ff55c1..77b842a 100644 --- a/web/spush/brisk-spush.phh +++ b/web/spush/brisk-spush.phh @@ -26,6 +26,7 @@ $DOCUMENT_ROOT=""; $HTTP_HOST="dodo.birds.lan"; define('USOCK_PATH_PFX', "/tmp/brisk"); define('USOCK_POOL_N', 10); +define('SOCK_SHARD_N', 2); define('PENDINGPAGE_CONTINUE', 0); define('PENDINGPAGE_WAITDATA', 1);