You are not logged in.
Pages: 1
Hi, ab.
I am trying something similer to restws.longwork, with additional implementation of CallbackReleased procedure.
IDataService = interface(IInvokable)
['{9DDC69FF-5212-4F64-9B98-ABFBF14A27D4}']
....
procedure CallbackReleased(const callback: IInvokable; const interfaceName: RawUTF8);
TDataService = class(TInjectableObjectRest, IDataService)
protected
fClients: TInterfaceDynArray;
....
procedure TDataService.CallbackReleased(const callback: IInvokable; const interfaceName: RawUTF8);
begin
InterfaceArrayDelete(fClients, callback);
end;
When a client released, this procedure is processed then av occurred in mormot.core.interfaces
procedure TInterfaceMethodExecuteRaw.AfterExecute;
var
i, a: PtrInt;
arg: PInterfaceMethodArgument;
begin
// finalize managed arrays for each call
Finalize(fRawUtf8s);
Finalize(fStrings);
Finalize(fWideStrings);
if fMethod^.ArgsManagedFirst >= 0 then
begin
for i := 0 to fMethod^.ArgsUsedCount[imvvObject] - 1 do
fObjects[i].Free;
for i := 0 to fMethod^.ArgsUsedCount[imvvInterface] - 1 do
IUnknown(fInterfaces[i]) := nil; <-------------- av here Line7372
Am I implementing it in a wrong way?
My env: Win10/X64/Delphi XE/git@20220123
Best regards.
Last edited by uian2000 (2022-02-28 14:36:52)
Offline
Hi ab,I think I may have found the key to the problem. The point is that the same interface is repeatedly released.
When I commented out InterfaceArrayDelete in CallbackReleased, server keeps running without av but callbacks were not released either.
I guess there's something wrong with this point in the framework.
You've mentioned a concept about re-release of interface (weak pointer), is it related here?
regards.
uian
Last edited by uian2000 (2022-02-24 01:43:09)
Offline
Client subscribes a service by calling service.Subscribe(aClientName, aClientInterface).
Then service will do this work by calling methid InterfaceArrayAdd(fClients, aClientInterface) .
I'll try mormot1 later, with the result posted here.
thanks
Offline
Hi, ab
I've made a pull request to demonstrate this issue.
Ex31-chat server/client works well in mormot1, but can go wrong in mormot2.
regards.
uian
Offline
I guess it will be fixed by https://github.com/synopse/mORMot2/commit/034b23e7
I also took the liberty to refactor the sample (and rename its files for consistency).
Thanks for the input, and sorry for the issue.
Offline
Thanks, ab. you are amazing.
I've walked pass these lines for many times, but found nothing.
This pr do fix this issue.
Thank you again!
regards.
uian
Offline
Pages: 1