-
Notifications
You must be signed in to change notification settings - Fork 8
/
10676.diff
126 lines (115 loc) · 4.82 KB
/
10676.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
commit 21771329dd2f13568f458a925671f9db80bc8ade
Author: Julius Pfrommer <[email protected]>
Date: Sat Oct 6 15:36:45 2018 +0200
Subscription: Close subscriptions before closing the SecureChannel
diff --git a/src/server/ua_session.c b/src/server/ua_session.c
index 075c9ccfa..34f16f6aa 100644
--- a/src/server/ua_session.c
+++ b/src/server/ua_session.c
@@ -25,30 +25,17 @@ void UA_Session_init(UA_Session *session) {
void UA_Session_deleteMembersCleanup(UA_Session *session, UA_Server* server) {
UA_Session_detachFromSecureChannel(session);
UA_ApplicationDescription_deleteMembers(&session->clientDescription);
UA_NodeId_deleteMembers(&session->header.authenticationToken);
UA_NodeId_deleteMembers(&session->sessionId);
UA_String_deleteMembers(&session->sessionName);
UA_ByteString_deleteMembers(&session->serverNonce);
struct ContinuationPointEntry *cp, *temp;
LIST_FOREACH_SAFE(cp, &session->continuationPoints, pointers, temp) {
LIST_REMOVE(cp, pointers);
UA_ByteString_deleteMembers(&cp->identifier);
UA_BrowseDescription_deleteMembers(&cp->browseDescription);
UA_free(cp);
}
-
-#ifdef UA_ENABLE_SUBSCRIPTIONS
- UA_Subscription *sub, *tempsub;
- LIST_FOREACH_SAFE(sub, &session->serverSubscriptions, listEntry, tempsub) {
- UA_Session_deleteSubscription(server, session, sub->subscriptionId);
- }
-
- UA_PublishResponseEntry *entry;
- while((entry = UA_Session_dequeuePublishReq(session))) {
- UA_PublishResponse_deleteMembers(&entry->response);
- UA_free(entry);
- }
-#endif
}
void UA_Session_attachToSecureChannel(UA_Session *session, UA_SecureChannel *channel) {
diff --git a/src/server/ua_session_manager.c b/src/server/ua_session_manager.c
index 910c225eb..be7de86d8 100644
--- a/src/server/ua_session_manager.c
+++ b/src/server/ua_session_manager.c
@@ -1,16 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
* Copyright 2014, 2017 (c) Florian Palm
* Copyright 2015 (c) Sten Grüner
* Copyright 2015 (c) Oleksiy Vasylyev
* Copyright 2017 (c) Stefan Profanter, fortiss GmbH
*/
#include "ua_session_manager.h"
#include "ua_server_internal.h"
+#include "ua_subscription.h"
UA_StatusCode
UA_SessionManager_init(UA_SessionManager *sm, UA_Server *server) {
@@ -20,15 +21,6 @@ UA_SessionManager_init(UA_SessionManager *sm, UA_Server *server) {
return UA_STATUSCODE_GOOD;
}
-void UA_SessionManager_deleteMembers(UA_SessionManager *sm) {
- session_list_entry *current, *temp;
- LIST_FOREACH_SAFE(current, &sm->sessions, pointers, temp) {
- LIST_REMOVE(current, pointers);
- UA_Session_deleteMembersCleanup(¤t->session, sm->server);
- UA_free(current);
- }
-}
-
/* Delayed callback to free the session memory */
static void
removeSessionCallback(UA_Server *server, session_list_entry *entry) {
@@ -37,25 +29,46 @@ removeSessionCallback(UA_Server *server, session_list_entry *entry) {
static void
removeSession(UA_SessionManager *sm, session_list_entry *sentry) {
+ /* Remove the Subscriptions */
+#ifdef UA_ENABLE_SUBSCRIPTIONS
+ UA_Subscription *sub, *tempsub;
+ LIST_FOREACH_SAFE(sub, &sentry->session.serverSubscriptions, listEntry, tempsub) {
+ UA_Session_deleteSubscription(sm->server, &sentry->session, sub->subscriptionId);
+ }
+
+ UA_PublishResponseEntry *entry;
+ while((entry = UA_Session_dequeuePublishReq(&sentry->session))) {
+ UA_PublishResponse_deleteMembers(&entry->response);
+ UA_free(entry);
+ }
+#endif
+
/* Detach the Session from the SecureChannel */
UA_Session_detachFromSecureChannel(&sentry->session);
/* Deactivate the session */
sentry->session.activated = false;
/* Detach the session from the session manager and make the capacity
* available */
LIST_REMOVE(sentry, pointers);
UA_atomic_subUInt32(&sm->currentSessionCount, 1);
/* Add a delayed callback to remove the session when the currently
* scheduled jobs have completed */
sentry->cleanupCallback.callback = (UA_ApplicationCallback)removeSessionCallback;
sentry->cleanupCallback.application = sm->server;
sentry->cleanupCallback.data = sentry;
UA_WorkQueue_enqueueDelayed(&sm->server->workQueue, &sentry->cleanupCallback);
}
+void UA_SessionManager_deleteMembers(UA_SessionManager *sm) {
+ session_list_entry *current, *temp;
+ LIST_FOREACH_SAFE(current, &sm->sessions, pointers, temp) {
+ removeSession(sm, current);
+ }
+}
+
void
UA_SessionManager_cleanupTimedOut(UA_SessionManager *sm,
UA_DateTime nowMonotonic) {