<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15364] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15364">15364</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-11-04 22:21:08 -0600 (Wed, 04 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>make subscriptions time out discarding hack to make them last forever</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15363 => 15364)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-11-05 02:10:10 UTC (rev 15363)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2009-11-05 04:21:08 UTC (rev 15364)
</span><span class="lines">@@ -1133,6 +1133,7 @@
</span><span class="cx">                 nua_set_params(node->nua,
</span><span class="cx">                                          NUTAG_APPL_METHOD("OPTIONS"),
</span><span class="cx">                                          NUTAG_APPL_METHOD("REFER"),
</span><ins>+                                         NUTAG_APPL_METHOD("SUBSCRIBE"),
</ins><span class="cx">                                          NUTAG_AUTOANSWER(0),
</span><span class="cx">                                          NUTAG_AUTOACK(0),
</span><span class="cx">                                          NUTAG_AUTOALERT(0),
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15363 => 15364)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-11-05 02:10:10 UTC (rev 15363)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2009-11-05 04:21:08 UTC (rev 15364)
</span><span class="lines">@@ -3848,7 +3848,7 @@
</span><span class="cx">                 switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip!='-1'", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip!='-1' and network_port!='-1'", mod_sofia_globals.hostname);
</ins><span class="cx">                 switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="lines">@@ -4006,6 +4006,8 @@
</span><span class="cx">         } else if (profile->odbc_dsn) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
</span><span class="cx">         } else {
</span><ins>+                char *errmsg;
+
</ins><span class="cx">                 if (master) {
</span><span class="cx">                         db = profile->master_db;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -4014,8 +4016,13 @@
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                switch_core_db_persistant_execute(db, sql, 1);
</del><span class="cx">
</span><ins>+                switch_core_db_exec(db, sql, NULL, NULL, &errmsg);
+                if (errmsg) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n%s\n", errmsg, sql);
+                        switch_core_db_free(errmsg);
+                }
+
</ins><span class="cx">                 if (!master) {
</span><span class="cx">                         switch_core_db_close(db);
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (15363 => 15364)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-11-05 02:10:10 UTC (rev 15363)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2009-11-05 04:21:08 UTC (rev 15364)
</span><span class="lines">@@ -1041,7 +1041,7 @@
</span><span class="cx">         if (expires) {
</span><span class="cx">                 long tmp = atol(expires);
</span><span class="cx">                 if (tmp > 0) {
</span><del>-                        exptime = tmp - switch_epoch_time_now(NULL) - SUB_OVERLAP;
</del><ins>+                        exptime = tmp - switch_epoch_time_now(NULL);// - SUB_OVERLAP;
</ins><span class="cx">                 } else {
</span><span class="cx">                         exptime = tmp;
</span><span class="cx">                 }
</span><span class="lines">@@ -1628,7 +1628,7 @@
</span><span class="cx">                 switch_snprintf(exp_delta_str, sizeof(exp_delta_str), "%ld", exp_delta);
</span><span class="cx">                 
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
</span><del>-                        sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
</del><ins>+                        sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' or (contact='%q' and and event='%q')", call_id, contact_str, event);
</ins><span class="cx">                 } else {
</span><span class="cx">                         sql = switch_mprintf("delete from sip_subscriptions where "
</span><span class="cx">                                                                  "proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q'",
</span><span class="lines">@@ -1662,14 +1662,14 @@
</span><span class="cx">
</span><span class="cx">                         sql = switch_mprintf("insert into sip_subscriptions "
</span><span class="cx">                                                                  "(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
</span><del>-                                                                 "full_via,expires,user_agent,accept,profile_name,hostname,network_ip) "
-                                                                 "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%q')",
</del><ins>+                                                                 "full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) "
+                                                                 "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')",
</ins><span class="cx">                                                                  proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
</span><span class="cx">                                                                  event, contact_str, call_id, full_from, full_via,
</span><del>-                                                                 exp_delta * -1,
-                                                                 full_agent, accept, profile->name,mod_sofia_globals.hostname, network_ip);
</del><ins>+                                                                 //sofia_test_pflag(profile, PFLAG_MULTIREG) ? switch_epoch_time_now(NULL) + exp_delta : exp_delta * -1,
+                                                                 switch_epoch_time_now(NULL) + exp_delta,
+                                                                 full_agent, accept, profile->name,mod_sofia_globals.hostname, network_port, network_ip);
</ins><span class="cx">                                                                 
</span><del>-                        
</del><span class="cx">                         if (mod_sofia_globals.debug_presence > 0) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n", profile->name, from_user, from_host, to_user, to_host);
</span><span class="cx">                         }
</span><span class="lines">@@ -1723,7 +1723,8 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (nh && nh->nh_ds && nh->nh_ds->ds_usage) {
</span><del>-                                nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP);
</del><ins>+                                //nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta + SUB_OVERLAP, exp_delta + SUB_OVERLAP);
+                                nua_dialog_usage_set_refresh_range(nh->nh_ds->ds_usage, exp_delta, exp_delta);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         nua_respond(nh, SIP_202_ACCEPTED,
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (15363 => 15364)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-11-05 02:10:10 UTC (rev 15363)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2009-11-05 04:21:08 UTC (rev 15364)
</span><span class="lines">@@ -1569,25 +1569,6 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static unsigned long get_nc(const char *nc, sip_t const *sip)
-{
-        unsigned long x;
-        const char *ua = NULL;
-
-        if (sip->sip_user_agent) {
-                ua = sip->sip_user_agent->g_string;
-        }
-
-        /* sigh, polycom sends nc in base-10 rather than spec which says base-16*/
-        if (ua && switch_stristr("polycom", ua)) {
-                x = strtoul(nc, 0, 10);
-        } else {
-                x = strtoul(nc, 0, 16);
-        }
-
-        return x;
-}
-
</del><span class="cx"> auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
</span><span class="cx">                                                                 sip_authorization_t const *authorization,
</span><span class="cx">                                                                 sip_t const *sip,
</span><span class="lines">@@ -1680,10 +1661,7 @@
</span><span class="cx">         if (zstr(np)) {
</span><span class="cx">                 first = 1;
</span><span class="cx">                 if (nc) {
</span><del>-                        unsigned long x;
-
-                        x = get_nc(nc, sip);
-                        sql = switch_mprintf("select nonce from sip_authentication where nonce='%q' and last_nc + 1 >= %lu", nonce, x);
</del><ins>+                        sql = switch_mprintf("select nonce from sip_authentication where nonce='%q' and last_nc < %lu", nonce, strtoul(nc, 0, 16));
</ins><span class="cx">                 } else {
</span><span class="cx">                         sql = switch_mprintf("select nonce from sip_authentication where nonce='%q'", nonce);
</span><span class="cx">                 }
</span><span class="lines">@@ -2079,17 +2057,15 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (nc && cnonce && qop) {
</span><del>-                unsigned long x;
</del><span class="cx">                 char *sql;
</span><span class="cx">
</span><del>-                x = get_nc(nc, sip);
</del><span class="cx"> #if defined(_WIN32) && !defined(_WIN64)
</span><span class="cx"> #define        LL_FMT "ll"
</span><span class="cx"> #else
</span><span class="cx"> #define        LL_FMT "l"
</span><span class="cx"> #endif
</span><span class="cx">                 sql = switch_mprintf("update sip_authentication set expires='%"LL_FMT"u',last_nc=%lu where nonce='%s'",
</span><del>-                                                         switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), x, nonce);
</del><ins>+                                                         switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), strtoul(nc, 0, 16), nonce);
</ins><span class="cx">
</span><span class="cx">                 switch_assert(sql != NULL);
</span><span class="cx">                 sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>