[Asterisk-cvs] asterisk/channels chan_sip.c,1.299,1.300
malcolmd at lists.digium.com
malcolmd at lists.digium.com
Tue Feb 24 15:00:11 CST 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv28549/channels
Modified Files:
chan_sip.c
Log Message:
Fix Bug # 935 and Bug # 1052
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.299
retrieving revision 1.300
diff -u -d -r1.299 -r1.300
--- chan_sip.c 20 Feb 2004 15:39:43 -0000 1.299
+++ chan_sip.c 24 Feb 2004 19:48:46 -0000 1.300
@@ -687,7 +687,7 @@
#ifdef MYSQL_FRIENDS
-static void mysql_update_peer(char *peer, struct sockaddr_in *sin, char *username)
+static void mysql_update_peer(char *peer, struct sockaddr_in *sin, char *username, int expiry)
{
if (mysql && (strlen(peer) < 128)) {
char query[512];
@@ -700,7 +700,7 @@
mysql_real_escape_string(mysql, name, peer, strlen(peer));
mysql_real_escape_string(mysql, uname, username, strlen(username));
snprintf(query, sizeof(query), "UPDATE sipfriends SET ipaddr=\"%s\", port=\"%d\", regseconds=\"%ld\", username=\"%s\" WHERE name=\"%s\"",
- inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), nowtime, uname, name);
+ inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), nowtime + expiry, uname, name);
ast_mutex_lock(&mysqllock);
if (mysql_real_query(mysql, query, strlen(query)))
ast_log(LOG_WARNING, "Unable to update database\n");
@@ -763,7 +763,7 @@
}
}
time(&nowtime);
- if ((nowtime - regseconds) > default_expiry)
+ if (nowtime > regseconds)
memset(&p->addr, 0, sizeof(p->addr));
}
mysql_free_result(result);
@@ -3503,10 +3503,6 @@
if (!p->temponly)
p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
pvt->expiry = expiry;
-#ifdef MYSQL_FRIENDS
- if (p->temponly)
- mysql_update_peer(p->name, &p->addr, p->username);
-#endif
snprintf(data, sizeof(data), "%s:%d:%d:%s", inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username);
ast_db_put("SIP/Registry", p->name, data);
if (inaddrcmp(&p->addr, &oldsin)) {
@@ -3819,6 +3815,10 @@
if (parse_contact(p, peer, req)) {
ast_log(LOG_WARNING, "Failed to parse contact info\n");
} else {
+#ifdef MYSQL_FRIENDS
+ if (peer->temponly)
+ mysql_update_peer(peer->name, &peer->addr, peer->username, p->expiry);
+#endif
/* Say OK and ask subsystem to retransmit msg counter */
transmit_response_with_date(p, "200 OK", req);
peer->lastmsgssent = -1;
More information about the svn-commits
mailing list