Browse code

modules/sca: AoR should not be treated as SCA if there are no subscribers.

Andrew Mortensen authored on 20/08/2013 19:54:17
Showing 3 changed files
... ...
@@ -386,6 +386,24 @@ done:
386 386
     return( rc );
387 387
 }
388 388
 
389
+    int
390
+sca_appearance_unregister( sca_mod *scam, str *aor )
391
+{
392
+    int			rc = 0;
393
+
394
+    assert( scam != NULL );
395
+    assert( aor != NULL );
396
+
397
+    if ( sca_uri_is_shared_appearance( scam, aor )) {
398
+	if (( rc = sca_hash_table_kv_delete( scam->appearances, aor )) == 0 ) {
399
+	    rc = 1;
400
+	    LM_INFO( "unregistered SCA AoR %.*s", STR_FMT( aor ));
401
+	}
402
+    }
403
+
404
+    return( rc );
405
+}
406
+
389 407
     sca_appearance *
390 408
 sca_appearance_seize_index_unsafe( sca_mod *scam, str *aor, str *owner_uri,
391 409
 	int app_idx, int slot_idx, int *seize_error )
... ...
@@ -155,6 +155,7 @@ sca_appearance	*sca_appearance_for_tags_unsafe( sca_mod *, str *,
155 155
 						str *, str *, str *, int );
156 156
 
157 157
 int	sca_appearance_register( sca_mod *, str * );
158
+int	sca_appearance_unregister( sca_mod *, str * );
158 159
 void	sca_appearance_list_insert_appearance( sca_appearance_list *,
159 160
 						sca_appearance * );
160 161
 sca_appearance	*sca_appearance_list_unlink_index( sca_appearance_list *, int );
... ...
@@ -1979,12 +1979,14 @@ sca_call_info_update( sip_msg_t *msg, char *p1, char *p2 )
1979 1979
 	    if ( !sca_subscription_aor_has_subscribers(
1980 1980
 				SCA_EVENT_TYPE_CALL_INFO, &from_aor )) {
1981 1981
 		call_info.ua_shared &= ~SCA_CALL_INFO_SHARED_CALLER;
1982
+		sca_appearance_unregister( sca, &from_aor );
1982 1983
 	    }
1983 1984
 	} else if ( SCA_CALL_INFO_IS_SHARED_CALLEE( &call_info ) &&
1984 1985
 		msg->first_line.type == SIP_REPLY ) {
1985 1986
 	    if ( !sca_subscription_aor_has_subscribers(
1986 1987
 				SCA_EVENT_TYPE_CALL_INFO, &to_aor )) {
1987 1988
 		call_info.ua_shared &= ~SCA_CALL_INFO_SHARED_CALLEE;
1989
+		sca_appearance_unregister( sca, &to_aor );
1988 1990
 	    }
1989 1991
 	}
1990 1992
     }