Skip to content

Commit 27192c6

Browse files
NGloreousshirhatti
authored andcommitted
Unset delegation propery from source queue. This removes the process from the target URL group and allows the delegation rule to be added back later on in the processes lifetime
1 parent da3e434 commit 27192c6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Servers/HttpSys/src/DelegationRule.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
1313
public class DelegationRule : IDisposable
1414
{
1515
private readonly ILogger _logger;
16+
private readonly UrlGroup _sourceQueueUrlGroup;
1617
/// <summary>
1718
/// The name of the Http.Sys request queue
1819
/// </summary>
@@ -23,8 +24,9 @@ public class DelegationRule : IDisposable
2324
public string UrlPrefix { get; }
2425
internal RequestQueue Queue { get; }
2526

26-
internal DelegationRule(string queueName, string urlPrefix, ILogger logger)
27+
internal DelegationRule(UrlGroup sourceQueueUrlGroup, string queueName, string urlPrefix, ILogger logger)
2728
{
29+
_sourceQueueUrlGroup = sourceQueueUrlGroup;
2830
_logger = logger;
2931
QueueName = queueName;
3032
UrlPrefix = urlPrefix;
@@ -34,6 +36,7 @@ internal DelegationRule(string queueName, string urlPrefix, ILogger logger)
3436
/// <inheritdoc />
3537
public void Dispose()
3638
{
39+
_sourceQueueUrlGroup.UnSetDelegationProperty(Queue, throwOnError: false);
3740
Queue.UrlGroup?.Dispose();
3841
Queue?.Dispose();
3942
}

src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ internal unsafe void SetDelegationProperty(RequestQueue destination)
8080
SetProperty(HttpApiTypes.HTTP_SERVER_PROPERTY.HttpServerDelegationProperty, new IntPtr(&propertyInfo), (uint)RequestPropertyInfoSize);
8181
}
8282

83+
internal unsafe void UnSetDelegationProperty(RequestQueue destination, bool throwOnError = true)
84+
{
85+
var propertyInfo = new HttpApiTypes.HTTP_BINDING_INFO();
86+
propertyInfo.Flags = HttpApiTypes.HTTP_FLAGS.NONE;
87+
propertyInfo.RequestQueueHandle = destination.Handle.DangerousGetHandle();
88+
89+
SetProperty(HttpApiTypes.HTTP_SERVER_PROPERTY.HttpServerDelegationProperty, new IntPtr(&propertyInfo), (uint)RequestPropertyInfoSize, throwOnError);
90+
}
91+
8392
internal void SetProperty(HttpApiTypes.HTTP_SERVER_PROPERTY property, IntPtr info, uint infosize, bool throwOnError = true)
8493
{
8594
Debug.Assert(info != IntPtr.Zero, "SetUrlGroupProperty called with invalid pointer");

src/Servers/HttpSys/src/ServerDelegationPropertyFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public ServerDelegationPropertyFeature(RequestQueue queue, ILogger logger)
2121

2222
public DelegationRule CreateDelegationRule(string queueName, string uri)
2323
{
24-
var rule = new DelegationRule(queueName, uri, _logger);
24+
var rule = new DelegationRule(_queue.UrlGroup, queueName, uri, _logger);
2525
_queue.UrlGroup.SetDelegationProperty(rule.Queue);
2626
return rule;
2727
}

0 commit comments

Comments
 (0)