[Freeswitch-svn] [commit] r11835 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/soa
FreeSWITCH SVN
mikej at freeswitch.org
Wed Feb 11 09:07:59 PST 2009
Author: mikej
Date: Wed Feb 11 11:07:59 2009
New Revision: 11835
Log:
Fri Jan 16 13:27:39 CST 2009 Pekka Pessi <first.last at nokia.com>
* soa: fixed restoring state after failed offer
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Wed Feb 11 11:07:59 2009
@@ -1 +1 @@
-Wed Feb 11 11:06:56 CST 2009
+Wed Feb 11 11:07:52 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa.c Wed Feb 11 11:07:59 2009
@@ -938,7 +938,7 @@
*
* <i>User SDP</i> is used as basis for SDP Offer/Answer negotiation. It can
* be very minimal template, consisting just m= line containing media name,
- * transport protocol port number and list of supported codecs.
+ * transport protocol, port number and list of supported codecs.
*
* The SDP used as an offer or answer (generated by soa_generate_answer() or
* soa_generate_offer()) is known as <i>local SDP</i> and it is available
@@ -1703,13 +1703,10 @@
(void)completed;
- if (!l_sdp)
- return -1;
-
- soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session);
-
ss->ss_offer_sent = 0;
+ soa_set_activity(ss, l_sdp ? l_sdp->sdp_media : NULL, soa_activity_session);
+
return 0;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c Wed Feb 11 11:07:59 2009
@@ -84,6 +84,11 @@
/** Mapping from session SDP m= lines to user SDP m= lines */
int *sss_s2u;
+ /** State kept from SDP before current offer */
+ struct {
+ int *u2s, *s2u;
+ } sss_previous;
+
/** Our latest offer or answer */
sdp_session_t *sss_latest;
}
@@ -886,6 +891,7 @@
return 0;
}
+static
int *u2s_alloc(su_home_t *home, int const *u2s)
{
if (u2s) {
@@ -1318,6 +1324,8 @@
}
soa_description_free(ss, ss->ss_previous);
+ su_free(ss->ss_home, sss->sss_previous.u2s), sss->sss_previous.u2s = NULL;
+ su_free(ss->ss_home, sss->sss_previous.s2u), sss->sss_previous.s2u = NULL;
if (u2s) {
u2s = u2s_alloc(ss->ss_home, u2s);
@@ -1358,10 +1366,18 @@
if (action == generate_offer) {
/* Keep a copy of previous session state */
+ int *previous_u2s = u2s_alloc(ss->ss_home, sss->sss_u2s);
+ int *previous_s2u = u2s_alloc(ss->ss_home, sss->sss_s2u);
+
+ if ((sss->sss_u2s && !previous_u2s) || (sss->sss_s2u && !previous_s2u))
+ goto internal_error;
+
*ss->ss_previous = *ss->ss_local;
memset(ss->ss_local, 0, (sizeof *ss->ss_local));
ss->ss_previous_user_version = ss->ss_local_user_version;
ss->ss_previous_remote_version = ss->ss_local_remote_version;
+ sss->sss_previous.u2s = previous_u2s;
+ sss->sss_previous.s2u = previous_s2u;
}
SU_DEBUG_7(("soa_static(%p, %s): %s\n", (void *)ss, by,
@@ -1374,6 +1390,8 @@
memset(ss->ss_previous, 0, (sizeof *ss->ss_previous));
ss->ss_previous_user_version = 0;
ss->ss_previous_remote_version = 0;
+ su_free(ss->ss_home, sss->sss_previous.u2s), sss->sss_previous.u2s = NULL;
+ su_free(ss->ss_home, sss->sss_previous.s2u), sss->sss_previous.s2u = NULL;
}
su_free(ss->ss_home, u2s), su_free(ss->ss_home, s2u);
@@ -1467,21 +1485,26 @@
static int soa_static_process_reject(soa_session_t *ss,
soa_callback_f *completed)
{
+ soa_static_session_t *sss = (soa_static_session_t *)ss;
struct soa_description d[1];
- if (ss->ss_previous_user_version) {
- *d = *ss->ss_local;
- *ss->ss_local = *ss->ss_previous;
- ss->ss_local_user_version = ss->ss_previous_user_version;
- ss->ss_local_remote_version = ss->ss_previous_remote_version;
-
- memset(ss->ss_previous, 0, (sizeof *ss->ss_previous));
- soa_description_free(ss, d);
- ss->ss_previous_user_version = 0;
- ss->ss_previous_remote_version = 0;
- }
+ soa_base_process_reject(ss, NULL);
+
+ *d = *ss->ss_local;
+ *ss->ss_local = *ss->ss_previous;
+ ss->ss_local_user_version = ss->ss_previous_user_version;
+ ss->ss_local_remote_version = ss->ss_previous_remote_version;
+
+ memset(ss->ss_previous, 0, (sizeof *ss->ss_previous));
+ soa_description_free(ss, d);
+ su_free(ss->ss_home, sss->sss_previous.u2s), sss->sss_previous.u2s = NULL;
+ su_free(ss->ss_home, sss->sss_previous.s2u), sss->sss_previous.s2u = NULL;
+ ss->ss_previous_user_version = 0;
+ ss->ss_previous_remote_version = 0;
- return soa_base_process_reject(ss, NULL);
+ su_free(ss->ss_home, sss->sss_latest), sss->sss_latest = NULL;
+
+ return 0;
}
static int soa_static_activate(soa_session_t *ss, char const *option)
@@ -1496,6 +1519,19 @@
static void soa_static_terminate(soa_session_t *ss, char const *option)
{
- soa_description_free(ss, ss->ss_user);
+ soa_static_session_t *sss = (soa_static_session_t *)ss;
+
+ soa_description_free(ss, ss->ss_local);
+ su_free(ss->ss_home, sss->sss_u2s), sss->sss_u2s = NULL;
+ su_free(ss->ss_home, sss->sss_s2u), sss->sss_s2u = NULL;
+
+ soa_description_free(ss, ss->ss_previous);
+ ss->ss_previous_user_version = 0;
+ ss->ss_previous_remote_version = 0;
+ su_free(ss->ss_home, sss->sss_previous.u2s), sss->sss_previous.u2s = NULL;
+ su_free(ss->ss_home, sss->sss_previous.s2u), sss->sss_previous.s2u = NULL;
+
+ su_free(ss->ss_home, sss->sss_latest), sss->sss_latest = NULL;
+
soa_base_terminate(ss, option);
}
More information about the Freeswitch-svn
mailing list