[asterisk-commits] rizzo: branch rizzo/astobj2 r47920 -
/team/rizzo/astobj2/channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 22 03:31:44 MST 2006
Author: rizzo
Date: Wed Nov 22 04:31:43 2006
New Revision: 47920
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47920
Log:
no functional changes, but add comments around the register
handling functions
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47920&r1=47919&r2=47920
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 04:31:43 2006
@@ -7381,7 +7381,12 @@
return 0;
}
-/*! \brief Registration timeout, register again */
+/*! \brief Registration timeout, register again.
+ * Registered as a timeout handler during transmit_register(), but not always
+ * (e.g. not on the auth case).
+ * This is called by the scheduler so the event is not pending anymore when
+ * we are called, and
+ */
static int sip_reg_timeout(void *data)
{
@@ -7390,11 +7395,16 @@
struct sip_pvt *p;
int res;
- /* if we couldn't get a reference to the registry object, punt */
- if (!r)
+ if (!r) {
+ ast_log(LOG_WARNING, "very strange, sip_reg_timeout called without a sip_registry. Should not happen\n");
return 0;
+ }
ast_log(LOG_NOTICE, " -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts);
+ /* if the initial tranmission failed, we may not have an existing dialog,
+ * so it is possible that r->register_pvt == NULL.
+ * In any case we have a timeout so we don't want it.
+ */
if (r->register_pvt) {
/* Unlink us, destroy old call. Locking is not relevant here because all this happens
in the single SIP manager thread. */
@@ -7424,7 +7434,9 @@
return 0;
}
-/*! \brief Transmit register to SIP proxy or UA */
+/*! \brief Transmit register to SIP proxy or UA
+ * auth = NULL on the initial registration (from sip_reregister())
+ */
static int transmit_register(struct sip_registry *r, const char *auth, const char *authheader)
{
struct sip_request req;
@@ -7456,7 +7468,7 @@
build_callid_registry(r, __ourip, default_fromdomain);
r->callid_valid = TRUE;
}
- /* Allocate SIP packet for registration */
+ /* Allocate SIP dialog for registration */
if (!(p = sip_alloc( r->callid, NULL, 0, SIP_REGISTER))) {
ast_log(LOG_WARNING, "Unable to allocate registration transaction (memory or socket error)\n");
return 0;
@@ -7485,8 +7497,8 @@
else /* Set registry port to the port set from the peer definition/srv or default */
r->portno = ntohs(p->sa.sin_port);
ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Registration is outgoing call */
- r->register_pvt = pvt_ref(p); /* Save pointer to SIP packet */
- p->registry = ASTOBJ_REF(r); /* Add pointer to registry in packet */
+ r->register_pvt = pvt_ref(p); /* Save pointer to SIP dialog */
+ p->registry = ASTOBJ_REF(r); /* Add pointer to registry in dialog */
if (!ast_strlen_zero(r->secret)) /* Secret (password) */
ast_string_field_set(p, peersecret, r->secret);
if (!ast_strlen_zero(r->md5secret))
More information about the asterisk-commits
mailing list