nickva commented on code in PR #5469:
URL: https://github.com/apache/couchdb/pull/5469#discussion_r1989955301


##########
src/nouveau/src/nouveau_api.erl:
##########
@@ -318,15 +318,34 @@ send_if_enabled(Url, Header, Method, Body) ->
 send_if_enabled(Url, Header, Method, Body, Options) ->
     case nouveau:enabled() of
         true ->
-            ibrowse:send_req(Url, Header, Method, Body, Options);
+            retry_if_connection_closes(fun() ->
+                ibrowse:send_req(Url, Header, Method, Body, Options)
+            end);
         false ->
             {error, nouveau_not_enabled}
     end.
 
 send_direct_if_enabled(ConnPid, Url, Header, Method, Body, Options) ->
     case nouveau:enabled() of
         true ->
-            ibrowse:send_req_direct(ConnPid, Url, Header, Method, Body, 
Options);
+            retry_if_connection_closes(fun() ->
+                ibrowse:send_req_direct(ConnPid, Url, Header, Method, Body, 
Options)
+            end);
         false ->
             {error, nouveau_not_enabled}
     end.
+
+retry_if_connection_closes(Fun) ->
+    MaxRetries = max(1, config:get_integer("nouveau", "max_retries", 5)),
+    retry_if_connection_closes(Fun, MaxRetries).
+
+retry_if_connection_closes(_Fun, 0) ->
+    {error, connection_closed};

Review Comment:
   There is a `connection_closing` apparently too 
https://github.com/cmullaparthi/ibrowse/blob/22d6fd6baa6e83633aa2923f41589945c1d2dc2f/src/ibrowse.erl#L521
 not sure if we're likely to see that or not



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to