Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpListenerSession.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
using
System.Threading
;
3
4
namespace
System.Net
;
5
6
internal
sealed
class
HttpListenerSession
7
{
8
public
readonly
HttpListener
Listener
;
9
10
public
readonly
SafeHandle
RequestQueueHandle
;
11
12
private
ThreadPoolBoundHandle
_requestQueueBoundHandle
;
13
14
public
ThreadPoolBoundHandle
RequestQueueBoundHandle
15
{
16
get
17
{
18
if
(
_requestQueueBoundHandle
==
null
)
19
{
20
lock (
this
)
21
{
22
if
(
_requestQueueBoundHandle
==
null
)
23
{
24
_requestQueueBoundHandle
=
ThreadPoolBoundHandle
.
BindHandle
(
RequestQueueHandle
);
25
if
(
System
.
Net
.
NetEventSource
.
Log
.IsEnabled())
26
{
27
System
.
Net
.
NetEventSource
.
Info
($
"ThreadPoolBoundHandle.BindHandle({RequestQueueHandle}) -> {_requestQueueBoundHandle}"
,
null
,
"RequestQueueBoundHandle"
);
28
}
29
}
30
}
31
}
32
return
_requestQueueBoundHandle
;
33
}
34
}
35
36
public
unsafe
HttpListenerSession
(
HttpListener
listener)
37
{
38
Listener
= listener;
39
HttpRequestQueueV2Handle
pReqQueueHandle;
40
uint num = global::Interop.HttpApi.HttpCreateRequestQueue(global::Interop.HttpApi.s_version,
null
,
null
, 0u, out pReqQueueHandle);
41
if
(num != 0)
42
{
43
throw
new
HttpListenerException
((
int
)num);
44
}
45
if
(
HttpListener
.
SkipIOCPCallbackOnSuccess
&& !global::Interop.Kernel32.SetFileCompletionNotificationModes(pReqQueueHandle, global::Interop.Kernel32.FileCompletionNotificationModes.SkipCompletionPortOnSuccess | global::Interop.Kernel32.FileCompletionNotificationModes.SkipSetEventOnHandle))
46
{
47
throw
new
HttpListenerException
(
Marshal
.
GetLastPInvokeError
());
48
}
49
RequestQueueHandle
= pReqQueueHandle;
50
}
51
52
public
unsafe
void
CloseRequestQueueHandle
()
53
{
54
lock (
this
)
55
{
56
if
(!
RequestQueueHandle
.
IsInvalid
)
57
{
58
if
(
System
.
Net
.
NetEventSource
.
Log
.IsEnabled())
59
{
60
System
.
Net
.
NetEventSource
.
Info
($
"Dispose ThreadPoolBoundHandle: {_requestQueueBoundHandle}"
,
null
,
"CloseRequestQueueHandle"
);
61
}
62
_requestQueueBoundHandle
?.
Dispose
();
63
RequestQueueHandle
.
Dispose
();
64
try
65
{
66
global::Interop.Kernel32.CancelIoEx(
RequestQueueHandle
,
null
);
67
return
;
68
}
69
catch
(
ObjectDisposedException
)
70
{
71
return
;
72
}
73
}
74
}
75
}
76
}
System.Net.HttpListenerException
Definition
HttpListenerException.cs:11
System.Net.HttpListenerSession.RequestQueueHandle
readonly SafeHandle RequestQueueHandle
Definition
HttpListenerSession.cs:10
System.Net.HttpListenerSession.CloseRequestQueueHandle
unsafe void CloseRequestQueueHandle()
Definition
HttpListenerSession.cs:52
System.Net.HttpListenerSession._requestQueueBoundHandle
ThreadPoolBoundHandle _requestQueueBoundHandle
Definition
HttpListenerSession.cs:12
System.Net.HttpListenerSession.Listener
readonly HttpListener Listener
Definition
HttpListenerSession.cs:8
System.Net.HttpListenerSession.RequestQueueBoundHandle
ThreadPoolBoundHandle RequestQueueBoundHandle
Definition
HttpListenerSession.cs:15
System.Net.HttpListenerSession.HttpListenerSession
unsafe HttpListenerSession(HttpListener listener)
Definition
HttpListenerSession.cs:36
System.Net.HttpListenerSession
Definition
HttpListenerSession.cs:7
System.Net.HttpListener.SkipIOCPCallbackOnSuccess
static readonly bool SkipIOCPCallbackOnSuccess
Definition
HttpListener.cs:210
System.Net.HttpListener
Definition
HttpListener.cs:18
System.Net.HttpRequestQueueV2Handle
Definition
HttpRequestQueueV2Handle.cs:6
System.Net.NetEventSource.Log
static readonly System.Net.NetEventSource Log
Definition
NetEventSource.cs:20
System.Net.NetEventSource.Info
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
Definition
NetEventSource.cs:192
System.Net.NetEventSource
Definition
NetEventSource.cs:12
System.ObjectDisposedException
Definition
ObjectDisposedException.cs:9
System.Runtime.InteropServices.Marshal.GetLastPInvokeError
static int GetLastPInvokeError()
System.Runtime.InteropServices.Marshal
Definition
Marshal.cs:14
System.Runtime.InteropServices.SafeHandle.Dispose
void Dispose()
Definition
SafeHandle.cs:57
System.Runtime.InteropServices.SafeHandle.IsInvalid
bool IsInvalid
Definition
SafeHandle.cs:20
System.Runtime.InteropServices.SafeHandle
Definition
SafeHandle.cs:7
System.Threading.ThreadPoolBoundHandle.BindHandle
static ThreadPoolBoundHandle BindHandle(SafeHandle handle)
Definition
ThreadPoolBoundHandle.cs:18
System.Threading.ThreadPoolBoundHandle.Dispose
void Dispose()
Definition
ThreadPoolBoundHandle.cs:126
System.Threading.ThreadPoolBoundHandle
Definition
ThreadPoolBoundHandle.cs:6
System.Net
Definition
HttpClientJsonExtensions.cs:8
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.Threading
Definition
TaskToApm.cs:3
System
Definition
BlockingCollection.cs:8
source
System.Net.HttpListener
System.Net
HttpListenerSession.cs
Generated by
1.10.0