change share of almost empty class httpclient, to just share of used SocketsHttpHandler, This simpifies handling of timeout, otherwise problematic

This commit is contained in:
UbitUmarov
2023-05-26 20:27:24 +01:00
parent c90858576c
commit e950c502ad
13 changed files with 108 additions and 127 deletions

View File

@@ -41,6 +41,7 @@ using OpenSim.Region.Framework.Scenes;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using OpenSim.Services.Interfaces;
using System.Net.Http;
namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
@@ -597,9 +598,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
ArrayList SendParams = new ArrayList();
SendParams.Add(xmlrpcdata);
XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
HttpClient hclient = null;
try
{
XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, WebUtil.SharedHttpClientWithRedir, 6000);
hclient = WebUtil.GetNewGlobalHttpClient(10000);
XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, hclient);
Hashtable responseData = (Hashtable)GridResp.Value;
if (responseData.ContainsKey("success"))
{
@@ -621,6 +624,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
{
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} : {1}", reginfo.ServerURI.ToString(), e.Message);
}
finally
{
hclient?.Dispose();
}
return false;
}

View File

@@ -42,6 +42,7 @@ using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Mono.Addins;
using System.Net.Http;
/*****************************************************
*
@@ -686,9 +687,11 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
ArrayList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest(mName, parameters);
HttpClient hclient = null;
try
{
XmlRpcResponse resp = req.Send(DestURL, WebUtil.SharedHttpClientWithRedir, 30000);
hclient = WebUtil.GetNewGlobalHttpClient(-1);
XmlRpcResponse resp = req.Send(DestURL, hclient);
if (resp != null)
{
Hashtable respParms;
@@ -733,6 +736,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
_finished = true;
httpThread = null;
Watchdog.RemoveThread();
hclient?.Dispose();
}
}

View File

@@ -283,9 +283,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
HttpResponseMessage responseMessage = null;
HttpRequestMessage request = null;
HttpClient client = null;
try
{
HttpClient client = WebUtil.SharedHttpClientWithRedir;
client = WebUtil.GetNewGlobalHttpClient(-1);
request = new(HttpMethod.Post, m_uri);
request.Headers.ExpectContinue = false;
@@ -307,6 +308,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{
request?.Dispose();
responseMessage?.Dispose();
client?.Dispose();
}
}
}