@@ -229,7 +229,7 @@ sub request (;$) {
229
229
return if !$param -> {ping };
230
230
}
231
231
my $list = read_json($config {list_full }) || {};
232
- printlog " readed[$config {list_full}] list size=" , scalar @{$list -> {list }};
232
+ printlog " readed[$config {list_full}] list size=" , scalar @{$list -> {list }} if $config { debug } ;
233
233
my $listk = {map { $_ -> {key } => $_ } @{$list -> {list }}};
234
234
my $old = $listk -> {$param -> {key }};
235
235
$param -> {time } = $old -> {time } if $param -> {off };
@@ -250,13 +250,12 @@ sub request (;$) {
250
250
delete $param -> {action };
251
251
$listk -> {$param -> {key }} = $param ;
252
252
# printlog 'write', Dumper $param if $config{debug};
253
- $list -> {list } = [grep { $_ -> {time } > time - $config {time_purge } } values %$listk ];
254
- file_rewrite($config {list_full }, JSON-> new-> encode($list ));
255
- printlog " writed[$config {list_full}] list size=" , scalar @{$list -> {list }} if $config {debug };
253
+ my $list_full = [grep { $_ -> {time } > time - $config {time_purge } } values %$listk ];
254
+
256
255
$list -> {list } = [
257
256
sort { $b -> {clients } <=> $a -> {clients } || $a -> {start } <=> $b -> {start } }
258
257
grep { $_ -> {time } > time - $config {time_alive } and !$_ -> {off } and (!$config {ping } or !$config {pingable } or $_ -> {ping }) }
259
- @{$list -> { list } }
258
+ @{$list_full }
260
259
];
261
260
$list -> {total } = {clients => 0, servers => 0};
262
261
for (@{$list -> {list }}) {
@@ -265,8 +264,14 @@ sub request (;$) {
265
264
}
266
265
$list -> {total_max }{clients } = $list -> {total }{clients } if $list -> {total_max }{clients } < $list -> {total }{clients };
267
266
$list -> {total_max }{servers } = $list -> {total }{servers } if $list -> {total_max }{servers } < $list -> {total }{servers };
267
+
268
268
file_rewrite($config {list_pub }, JSON-> new-> encode($list ));
269
269
printlog " writed[$config {list_pub}] list size=" , scalar @{$list -> {list }} if $config {debug };
270
+
271
+ $list -> {list } = $list_full ;
272
+ file_rewrite($config {list_full }, JSON-> new-> encode($list ));
273
+ printlog " writed[$config {list_full}] list size=" , scalar @{$list -> {list }} if $config {debug };
274
+
270
275
}
271
276
};
272
277
return [200, [" Content-type" , " application/json" ], [JSON-> new-> encode({})]], $after ;
0 commit comments