Protect against session deleted in separate thread

The session can be deleted either through normal request or forceful closure of connection.

Reproducible with open-etp-client

const ct2 = new ResqmlClient(); ct2.openSession(serverUrl, XmlUtils.createDefaultJWT()) .then(() => { ct2.getDataspaces(); ct2.disconnect(); })

and running open-etp-server with -j2 or more threads. Log:

[2023-08-21 11:29:27.956] Info: SVR >RES ~3 $2 #1(2) Core(0).OpenSession(2) F
[2023-08-21 11:29:27.958] Info: SVR <REQ ~3 $2 #4(0) Dataspace(24).GetDataspaces(1) F -5
[2023-08-21 11:29:28.959] Info: SVR <REQ ~1 $2 #6(0) Core(0).CloseSession(5) F -5
[2023-08-21 11:29:28.960] Info: SVR SESSION CLOSED ~1 $2
[2023-08-21 11:29:29.590] Info: SVR >RES Session is in terminated state ~2 $1 #4(0) Dataspace(24).GetDataspaces(1) F

Server and client crashes

Edited by Fabiola Rivera