fix for gun connections pool
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Wed, 8 Apr 2020 15:46:01 +0000 (18:46 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Wed, 8 Apr 2020 15:46:01 +0000 (18:46 +0300)
CHANGELOG.md
lib/pleroma/gun/conn.ex

index b6e5d807c47f19edf0e09785476dcedbdc495af0..92d1abc4eb122f7c8e1bed2e222a2cafa3accc48 100644 (file)
@@ -20,6 +20,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Mastodon API: Support for `include_types` in `/api/v1/notifications`.
 </details>
 
+### Fixed
+- Gun connections pool `max_connections` option.
+
 ## [2.0.0] - 2019-03-08
 ### Security
 - Mastodon API: Fix being able to request enourmous amount of statuses in timelines leading to DoS. Now limited to 40 per request.
index 20823a7658daa7c926887eda807966737ce20a04..cd25a2e746d1889f9b263daff6a3200917177780 100644 (file)
@@ -49,8 +49,10 @@ defmodule Pleroma.Gun.Conn do
 
     key = "#{uri.scheme}:#{uri.host}:#{uri.port}"
 
+    max_connections = pool_opts[:max_connections] || 250
+
     conn_pid =
-      if Connections.count(name) < opts[:max_connection] do
+      if Connections.count(name) < max_connections do
         do_open(uri, opts)
       else
         close_least_used_and_do_open(name, uri, opts)