Close open files when a session expires or is terminated
Posted: 20 Sep 2018, 13:06
Hi,
I am implementing an OPCUA server that exports a few files using the OPCUA FileType model.
Therefore, I derived a custom class from OpcUa::FileType, in order to have more control over file operations and file handles.
I would like the server to automatically close files when the session that was used to open the files, ends.
Looking for an appropriate callback, I found NodeManager::sessionClosed(Session*).
However, the documentation says that this callback is executed after the session was closed.
On the other hand, when calling FileType::Close(const ServiceContext& serviceContext, OpcUa_UInt32 FileHandle),
I find that this function expects that the session is not yet closed!
The session is found inside the serviceContext. FileType::Close returns Bad_InvalidArgument if the session is already closed.
I tested that the same method call to FileType::Close works, when the session is still active.
Is there any callback that I can use, that is executed when the session should be closed, but before the session actually becomes invalid?
Or is there any other way to close a file where the FileHandle is known, but the session no longer exists?
The selected session should really not be important, when I want to close a file on the server.
Best,
D. Rothe
I am implementing an OPCUA server that exports a few files using the OPCUA FileType model.
Therefore, I derived a custom class from OpcUa::FileType, in order to have more control over file operations and file handles.
I would like the server to automatically close files when the session that was used to open the files, ends.
Looking for an appropriate callback, I found NodeManager::sessionClosed(Session*).
However, the documentation says that this callback is executed after the session was closed.
On the other hand, when calling FileType::Close(const ServiceContext& serviceContext, OpcUa_UInt32 FileHandle),
I find that this function expects that the session is not yet closed!
The session is found inside the serviceContext. FileType::Close returns Bad_InvalidArgument if the session is already closed.
I tested that the same method call to FileType::Close works, when the session is still active.
Is there any callback that I can use, that is executed when the session should be closed, but before the session actually becomes invalid?
Or is there any other way to close a file where the FileHandle is known, but the session no longer exists?
The selected session should really not be important, when I want to close a file on the server.
Best,
D. Rothe