diff options
author | UbitUmarov | 2015-08-18 21:03:34 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-18 21:03:34 +0100 |
commit | 2cac56340a079fad8a16736778b6ebef78fb6d56 (patch) | |
tree | 90cb9963be59cf802d97961abff1dfddaea2a3bd /OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |
parent | Track selected objects per client (diff) | |
download | opensim-SC-2cac56340a079fad8a16736778b6ebef78fb6d56.zip opensim-SC-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.gz opensim-SC-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.bz2 opensim-SC-2cac56340a079fad8a16736778b6ebef78fb6d56.tar.xz |
try to serialize http requests from same connection, so they are processed
in order. ( next commits will be about necessary keepAlive changes needed)
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 6aa9479..e636c38 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Text; | 32 | using System.Text; |
32 | using HttpServer; | 33 | using HttpServer; |
@@ -44,6 +45,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
44 | public readonly IHttpRequest Request; | 45 | public readonly IHttpRequest Request; |
45 | public readonly int RequestTime; | 46 | public readonly int RequestTime; |
46 | public readonly UUID RequestID; | 47 | public readonly UUID RequestID; |
48 | public int contextHash; | ||
49 | |||
50 | private void GenContextHash() | ||
51 | { | ||
52 | Random rnd = new Random(); | ||
53 | contextHash = 0; | ||
54 | if (Request.Headers["remote_addr"] != null) | ||
55 | contextHash = (Request.Headers["remote_addr"]).GetHashCode() << 16; | ||
56 | else | ||
57 | contextHash = rnd.Next() << 16; | ||
58 | if (Request.Headers["remote_port"] != null) | ||
59 | { | ||
60 | string[] strPorts = Request.Headers["remote_port"].Split(new char[] { ',' }); | ||
61 | contextHash += Int32.Parse(strPorts[0]); | ||
62 | } | ||
63 | else | ||
64 | contextHash += rnd.Next() & 0xffff; | ||
65 | } | ||
47 | 66 | ||
48 | public PollServiceHttpRequest( | 67 | public PollServiceHttpRequest( |
49 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) | 68 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) |
@@ -53,6 +72,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
53 | Request = pRequest; | 72 | Request = pRequest; |
54 | RequestTime = System.Environment.TickCount; | 73 | RequestTime = System.Environment.TickCount; |
55 | RequestID = UUID.Random(); | 74 | RequestID = UUID.Random(); |
75 | GenContextHash(); | ||
56 | } | 76 | } |
57 | 77 | ||
58 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | 78 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) |
@@ -65,6 +85,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
65 | response.SendChunked = false; | 85 | response.SendChunked = false; |
66 | response.ContentLength64 = buffer.Length; | 86 | response.ContentLength64 = buffer.Length; |
67 | response.ContentEncoding = Encoding.UTF8; | 87 | response.ContentEncoding = Encoding.UTF8; |
88 | response.ReuseContext = false; | ||
68 | 89 | ||
69 | try | 90 | try |
70 | { | 91 | { |
@@ -93,5 +114,22 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
93 | PollServiceArgs.RequestsHandled++; | 114 | PollServiceArgs.RequestsHandled++; |
94 | } | 115 | } |
95 | } | 116 | } |
117 | |||
118 | } | ||
119 | |||
120 | class PollServiceHttpRequestComparer : IEqualityComparer<PollServiceHttpRequest> | ||
121 | { | ||
122 | public bool Equals(PollServiceHttpRequest b1, PollServiceHttpRequest b2) | ||
123 | { | ||
124 | if (b1.contextHash != b2.contextHash) | ||
125 | return false; | ||
126 | bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext); | ||
127 | return b; | ||
128 | } | ||
129 | |||
130 | public int GetHashCode(PollServiceHttpRequest b2) | ||
131 | { | ||
132 | return (int)b2.contextHash; | ||
133 | } | ||
96 | } | 134 | } |
97 | } \ No newline at end of file | 135 | } \ No newline at end of file |