Skip to content

Commit 8d01faa

Browse files
committed
Core - ResourceHandler free resources in Dispose instead of Cancel
There is no example of Cancel in the source code and the description in the doc doesn't really provide a clear explanation of it's intended use case. See code comment for further details
1 parent 6a2175a commit 8d01faa

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CefSharp/ResourceHandler.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,14 @@ void IResourceHandler.GetResponseHeaders(IResponse response, out long responseLe
219219

220220
void IResourceHandler.Cancel()
221221
{
222-
Stream = null;
223-
tempBuffer = null;
222+
// Prior to Prior to https://bitbucket.org/chromiumembedded/cef/commits/90301bdb7fd0b32137c221f38e8785b3a8ad8aa4
223+
// This method was unexpectedly being called during Read (from a different thread),
224+
// changes to the threading model were made and I haven't confirmed if this is still
225+
// the case.
226+
//
227+
// The documentation for Cancel is vaigue and there aren't any examples that
228+
// illustrage it's intended use case so for now we'll just keep things
229+
// simple and free our resources in Dispose
224230
}
225231

226232
bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback)
@@ -988,8 +994,10 @@ public virtual void Dispose()
988994
if (AutoDisposeStream && Stream != null)
989995
{
990996
Stream.Dispose();
991-
Stream = null;
992997
}
998+
999+
Stream = null;
1000+
tempBuffer = null;
9931001
}
9941002
}
9951003
}

0 commit comments

Comments
 (0)