Browse code

modules/ims_qos: improve reliability of active media sessions stat

Richard Good authored on 18/06/2015 06:56:20
Showing 2 changed files
... ...
@@ -262,8 +262,11 @@ void cdp_cb_event_process() {
262 262
 		    }
263 263
                 } else {
264 264
                     LM_DBG("This is a media bearer session session");
265
+		    if(p_session_data->session_has_been_opened) {
266
+			LM_DBG("Session was opened so decrementing active_media_rx_sessions\n");
267
+			counter_add(ims_qos_cnts_h.active_media_rx_sessions, -1);
268
+		    }
265 269
 		    
266
-		    counter_add(ims_qos_cnts_h.active_media_rx_sessions, -1);
267 270
                     //we only terminate the dialog if this was triggered from the transport plane or timeout - i.e. if must_terminate_dialog is set
268 271
                     //if this was triggered from the signalling plane (i.e. someone hanging up) then we don'y need to terminate the dialog
269 272
                     if (p_session_data->must_terminate_dialog) {
... ...
@@ -98,6 +98,8 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps
98 98
     struct cell *t = 0;
99 99
     unsigned int cdp_result;
100 100
     int result = CSCF_RETURN_ERROR;
101
+    AAASession *auth = 0;
102
+    rx_authsessiondata_t* p_session_data = 0;
101 103
     
102 104
     LM_DBG("Received AAR callback\n");
103 105
     saved_transaction_t* data = (saved_transaction_t*) param;
... ...
@@ -145,8 +147,29 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps
145 145
 	LM_DBG("Auth session ID [%.*s]", aaa->sessionId->data.len, aaa->sessionId->data.s);
146 146
 
147 147
 	if(!data->aar_update) {
148
-	    LM_DBG("This is an AAA response to an initial AAR");
148
+	    LM_DBG("This is an AAA response to an initial AAR - active_media_rx_sessions");
149
+	    
150
+	    //need to set Rx auth data to say this session has been successfully opened
151
+	    //This is used elsewhere to prevent acting on termination events when the session has not been opened
152
+	    //getting auth session
153
+	    auth = cdpb.AAAGetAuthSession(aaa->sessionId->data);
154
+	    if (!auth) {
155
+		LM_DBG("Could not get Auth Session for session id: [%.*s]\n", aaa->sessionId->data.len, aaa->sessionId->data.s);
156
+		goto error;
157
+	    }
158
+	    //getting session data
159
+	    p_session_data = (rx_authsessiondata_t*) auth->u.auth.generic_data;
160
+	    if (!p_session_data) {
161
+		LM_DBG("Could not get session data on Auth Session for session id: [%.*s]\n", aaa->sessionId->data.len, aaa->sessionId->data.s);
162
+		if (auth) cdpb.AAASessionsUnlock(auth->hash);
163
+		goto error;
164
+	    }
165
+	    
166
+	    LM_DBG("Setting session_has_been_opened and incrementing active_media_rx_sessions\n");
167
+	    p_session_data->session_has_been_opened = 1;
149 168
 	    counter_inc(ims_qos_cnts_h.active_media_rx_sessions);
169
+
170
+	    if (auth) cdpb.AAASessionsUnlock(auth->hash);
150 171
 	    
151 172
 	    str * passed_rx_session_id = shm_malloc(sizeof (struct _str));
152 173
 	    passed_rx_session_id->s = 0;
... ...
@@ -252,7 +275,7 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e
252 252
 
253 253
     if (cdp_result >= 2000 && cdp_result < 3000) {
254 254
         counter_inc(ims_qos_cnts_h.successful_registration_aars);
255
-	if (is_rereg) {
255
+        if (is_rereg) {
256 256
             LM_DBG("this is a re-registration, therefore we don't need to do anything except know that the the subscription was successful\n");
257 257
             result = CSCF_RETURN_TRUE;
258 258
             create_return_code(result);
... ...
@@ -273,7 +296,7 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e
273 273
 	    if (auth) cdpb.AAASessionsUnlock(auth->hash);
274 274
 	    goto error;
275 275
 	}
276
-	p_session_data->session_has_been_opened = 1;
276
+	    p_session_data->session_has_been_opened = 1;
277 277
 	counter_inc(ims_qos_cnts_h.active_registration_rx_sessions);
278 278
 	
279 279
 	if (auth) cdpb.AAASessionsUnlock(auth->hash);