aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 23:07:50 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-14 23:07:50 +0000
commit19c90377b0739f40b66083b8125ef86330727678 (patch)
treef5e02eb3c087a0156c1804cf1f1e0bf9d6feddfe
parent925d4efe528bd334d26ac11cd0685ca41c3ae441 (diff)
Merged revisions 276571 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r276571 | jpeeler | 2010-07-14 17:58:24 -0500 (Wed, 14 Jul 2010) | 21 lines Fix MWI notification transmission problems over SIP. MWI updates were not being sent if no messages were found in the event cache. This was corrected since a phone may need to clear its MWI status configured previously from another mailbox. Upon module or sip reload, MWI updates could not be sent due to the sipsock socket not being set early enough in reload_config. The code handling the descriptor assignment and such has simply been moved before the call to build_peer. Issuing a sip reload cleared the IP address of the peer, but skipped checking the database for registration information. The database is now checked both for sip reload and actually reloading the module. If a transmission occurs before the do_monitor thread has started, do not attempt to send a signal to it. (closes issue #17398) Reported by: ip-rob ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@276572 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c99
1 files changed, 49 insertions, 50 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7f6d1ccb4..2d565b4b6 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -22395,14 +22395,12 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *e
if (event) {
newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
oldmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS);
- } else if (!get_cached_mwi(peer, &newmsgs, &oldmsgs)) {
- /* got it! Don't keep looking. */
- } else if (cache_only) {
- return 0;
- } else { /* Fall back to manually checking the mailbox */
+ } else if (!cache_only) { /* Fall back to manually checking the mailbox */
struct ast_str *mailbox_str = ast_str_alloca(512);
peer_mailboxes_to_str(&mailbox_str, peer);
ast_app_inboxcount(mailbox_str->str, &newmsgs, &oldmsgs);
+ } else {
+ get_cached_mwi(peer, &newmsgs, &oldmsgs);
}
if (peer->mwipvt) {
@@ -24362,7 +24360,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
sip_cfg.allowsubscribe = TRUE; /* No global ban any more */
}
- if (!found && peer->host_dynamic && !peer->is_realtime) {
+ if (peer->host_dynamic && !peer->is_realtime) {
reg_source_db(peer);
}
@@ -25086,7 +25084,51 @@ static int reload_config(enum channelreloadreason reason)
if (!strcasecmp(v->name, "auth"))
authl = add_realm_authentication(authl, v->value, v->lineno);
}
-
+
+ ast_mutex_lock(&netlock);
+ if ((sipsock > -1) && (memcmp(&old_bindaddr, &bindaddr, sizeof(struct sockaddr_in)))) {
+ close(sipsock);
+ sipsock = -1;
+ }
+ if (sipsock < 0) {
+ sipsock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sipsock < 0) {
+ ast_log(LOG_WARNING, "Unable to create SIP socket: %s\n", strerror(errno));
+ ast_config_destroy(cfg);
+ return -1;
+ } else {
+ /* Allow SIP clients on the same host to access us: */
+ const int reuseFlag = 1;
+
+ setsockopt(sipsock, SOL_SOCKET, SO_REUSEADDR,
+ (const char*)&reuseFlag,
+ sizeof reuseFlag);
+
+ ast_enable_packet_fragmentation(sipsock);
+
+ if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
+ ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
+ strerror(errno));
+ close(sipsock);
+ sipsock = -1;
+ } else {
+ ast_verb(2, "SIP Listening on %s:%d\n",
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip, "SIP");
+ }
+ }
+ }
+ if (stunaddr.sin_addr.s_addr != 0) {
+ ast_debug(1, "stun to %s:%d\n",
+ ast_inet_ntoa(stunaddr.sin_addr) , ntohs(stunaddr.sin_port));
+ ast_stun_request(sipsock, &stunaddr,
+ NULL, &externip);
+ ast_debug(1, "STUN sees us at %s:%d\n",
+ ast_inet_ntoa(externip.sin_addr) , ntohs(externip.sin_port));
+ }
+ ast_mutex_unlock(&netlock);
+
if (ucfg) {
struct ast_variable *gen;
int genhassip, genregistersip;
@@ -25193,49 +25235,6 @@ static int reload_config(enum channelreloadreason reason)
ast_config_destroy(cfg);
return 0;
}
- ast_mutex_lock(&netlock);
- if ((sipsock > -1) && (memcmp(&old_bindaddr, &bindaddr, sizeof(struct sockaddr_in)))) {
- close(sipsock);
- sipsock = -1;
- }
- if (sipsock < 0) {
- sipsock = socket(AF_INET, SOCK_DGRAM, 0);
- if (sipsock < 0) {
- ast_log(LOG_WARNING, "Unable to create SIP socket: %s\n", strerror(errno));
- ast_config_destroy(cfg);
- return -1;
- } else {
- /* Allow SIP clients on the same host to access us: */
- const int reuseFlag = 1;
-
- setsockopt(sipsock, SOL_SOCKET, SO_REUSEADDR,
- (const char*)&reuseFlag,
- sizeof reuseFlag);
-
- ast_enable_packet_fragmentation(sipsock);
-
- if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
- ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
- ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
- strerror(errno));
- close(sipsock);
- sipsock = -1;
- } else {
- ast_verb(2, "SIP Listening on %s:%d\n",
- ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
- ast_netsock_set_qos(sipsock, global_tos_sip, global_cos_sip, "SIP");
- }
- }
- }
- if (stunaddr.sin_addr.s_addr != 0) {
- ast_debug(1, "stun to %s:%d\n",
- ast_inet_ntoa(stunaddr.sin_addr) , ntohs(stunaddr.sin_port));
- ast_stun_request(sipsock, &stunaddr,
- NULL, &externip);
- ast_debug(1, "STUN sees us at %s:%d\n",
- ast_inet_ntoa(externip.sin_addr) , ntohs(externip.sin_port));
- }
- ast_mutex_unlock(&netlock);
/* Start TCP server */
ast_tcptls_server_start(&sip_tcp_desc);