[asterisk-commits] russell: branch russell/ast_channel_refcount r80527 - in /team/russell/ast_ch...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 23 12:35:15 CDT 2007
Author: russell
Date: Thu Aug 23 12:35:14 2007
New Revision: 80527
URL: http://svn.digium.com/view/asterisk?view=rev&rev=80527
Log:
sync
Modified:
team/russell/ast_channel_refcount/ (props changed)
team/russell/ast_channel_refcount/channels/chan_iax2.c
team/russell/ast_channel_refcount/channels/chan_zap.c
team/russell/ast_channel_refcount/include/asterisk/astobj2.h
team/russell/ast_channel_refcount/main/astobj2.c
team/russell/ast_channel_refcount/res/res_agi.c
Propchange: team/russell/ast_channel_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Aug 23 12:35:14 2007
@@ -1,1 +1,1 @@
-/branches/1.4:1-80418
+/branches/1.4:1-80525
Modified: team/russell/ast_channel_refcount/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/channels/chan_iax2.c?view=diff&rev=80527&r1=80526&r2=80527
==============================================================================
--- team/russell/ast_channel_refcount/channels/chan_iax2.c (original)
+++ team/russell/ast_channel_refcount/channels/chan_iax2.c Thu Aug 23 12:35:14 2007
@@ -5432,10 +5432,12 @@
/* No specified host, or this is our host */
) {
res = authenticate(p->challenge, peer->secret, peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
- peer_unref(peer);
- if (!res)
- break;
+ if (!res) {
+ peer_unref(peer);
+ break;
+ }
}
+ peer_unref(peer);
}
if (!peer) {
/* We checked our list and didn't find one. It's unlikely, but possible,
@@ -9735,14 +9737,14 @@
/* Start with general parameters, then specific parameters, user and peer */
user = build_user(cat, gen, ast_variable_browse(ucfg, cat), 0);
if (user) {
- ao2_link(users, user);
+ __ao2_link(users, user, (MAX_PEER_BUCKETS == 1) ? 1 : 0);
user = NULL;
}
peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
if (peer) {
if (ast_test_flag(peer, IAX_DYNAMIC))
reg_source_db(peer);
- ao2_link(peers, peer);
+ __ao2_link(peers, peer, (MAX_PEER_BUCKETS == 1) ? 1 : 0);
peer = NULL;
}
}
@@ -9779,7 +9781,7 @@
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat), NULL, 0);
if (user) {
- ao2_link(users, user);
+ __ao2_link(users, user, (MAX_PEER_BUCKETS == 1) ? 1 : 0);
user = NULL;
}
}
@@ -9788,7 +9790,7 @@
if (peer) {
if (ast_test_flag(peer, IAX_DYNAMIC))
reg_source_db(peer);
- ao2_link(peers, peer);
+ __ao2_link(peers, peer, (MAX_PEER_BUCKETS == 1) ? 1 : 0);
peer = NULL;
}
} else if (strcasecmp(utype, "user")) {
Modified: team/russell/ast_channel_refcount/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/channels/chan_zap.c?view=diff&rev=80527&r1=80526&r2=80527
==============================================================================
--- team/russell/ast_channel_refcount/channels/chan_zap.c (original)
+++ team/russell/ast_channel_refcount/channels/chan_zap.c Thu Aug 23 12:35:14 2007
@@ -10304,8 +10304,9 @@
static int __unload_module(void)
{
- int x = 0;
+ int x;
struct zt_pvt *p, *pl;
+
#ifdef HAVE_PRI
int i;
for (i = 0; i < NUM_SPANS; i++) {
@@ -10354,7 +10355,7 @@
zt_close(p->subs[SUB_REAL].zfd);
pl = p;
p = p->next;
- x++;
+ x = pl->channel;
/* Free associated memory */
if (pl)
destroy_zt_pvt(&pl);
Modified: team/russell/ast_channel_refcount/include/asterisk/astobj2.h
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/include/asterisk/astobj2.h?view=diff&rev=80527&r1=80526&r2=80527
==============================================================================
--- team/russell/ast_channel_refcount/include/asterisk/astobj2.h (original)
+++ team/russell/ast_channel_refcount/include/asterisk/astobj2.h Thu Aug 23 12:35:14 2007
@@ -368,8 +368,15 @@
* This function insert an object in a container according its key.
*
* \note Remember to set the key before calling this function.
- */
-void *ao2_link(ao2_container *c, void *newobj);
+ *
+ * For Asterisk 1.4 only, there is a dirty hack here to ensure that chan_iax2
+ * can have objects linked in to the container at the head instead of tail
+ * when it is just a linked list. This is to maintain some existing behavior
+ * where the order must be maintained as it was before this conversion so that
+ * matching behavior doesn't change.
+ */
+#define ao2_link(c, o) __ao2_link(c, o, 0)
+void *__ao2_link(ao2_container *c, void *newobj, int iax2_hack);
void *ao2_unlink(ao2_container *c, void *newobj);
/*! \struct Used as return value if the flag OBJ_MULTIPLE is set */
@@ -433,39 +440,51 @@
/*!
*
-
-When we need to walk through a container, we use
-ao2_iterator to keep track of the current position.
-
-Because the navigation is typically done without holding the
-lock on the container across the loop,
-objects can be inserted or deleted or moved
-while we work. As a consequence, there is no guarantee that
-the we manage to touch all the elements on the list, or it
-is possible that we touch the same object multiple times.
-
-An iterator must be first initialized with ao2_iterator_init(),
-then we can use o = ao2_iterator_next() to move from one
-element to the next. Remember that the object returned by
-ao2_iterator_next() has its refcount incremented,
-and the reference must be explicitly released when done with it.
-Example:
-
- \code
-
- ao2_container *c = ... // the container we want to iterate on
- ao2_iterator i;
- struct my_obj *o;
-
- i = ao2_iterator_init(c, flags);
-
- while ( (o = ao2_iterator_next(&i)) ) {
- ... do something on o ...
- ao2_ref(o, -1);
- }
-
- \endcode
-
+ *
+ * When we need to walk through a container, we use
+ * ao2_iterator to keep track of the current position.
+ *
+ * Because the navigation is typically done without holding the
+ * lock on the container across the loop,
+ * objects can be inserted or deleted or moved
+ * while we work. As a consequence, there is no guarantee that
+ * the we manage to touch all the elements on the list, or it
+ * is possible that we touch the same object multiple times.
+ * However, within the current hash table container, the following is true:
+ * - It is not possible to miss an object in the container while iterating
+ * unless it gets added after the iteration begins and is added to a bucket
+ * that is before the one the current object is in. In this case, even if
+ * you locked the container around the entire iteration loop, you still would
+ * not see this object, because it would still be waiting on the container
+ * lock so that it can be added.
+ * - It would be extremely rare to see an object twice. The only way this can
+ * happen is if an object got unlinked from the container and added again
+ * during the same iteration. Furthermore, when the object gets added back,
+ * it has to be in the current or later bucket for it to be seen again.
+ *
+ * An iterator must be first initialized with ao2_iterator_init(),
+ * then we can use o = ao2_iterator_next() to move from one
+ * element to the next. Remember that the object returned by
+ * ao2_iterator_next() has its refcount incremented,
+ * and the reference must be explicitly released when done with it.
+ *
+ * Example:
+ *
+ * \code
+ *
+ * ao2_container *c = ... // the container we want to iterate on
+ * ao2_iterator i;
+ * struct my_obj *o;
+ *
+ * i = ao2_iterator_init(c, flags);
+ *
+ * while ( (o = ao2_iterator_next(&i)) ) {
+ * ... do something on o ...
+ * ao2_ref(o, -1);
+ * }
+ *
+ * \endcode
+ *
*/
/*!
Modified: team/russell/ast_channel_refcount/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/main/astobj2.c?view=diff&rev=80527&r1=80526&r2=80527
==============================================================================
--- team/russell/ast_channel_refcount/main/astobj2.c (original)
+++ team/russell/ast_channel_refcount/main/astobj2.c Thu Aug 23 12:35:14 2007
@@ -316,7 +316,7 @@
/*
* link an object to a container
*/
-void *ao2_link(ao2_container *c, void *user_data)
+void *__ao2_link(ao2_container *c, void *user_data, int iax2_hack)
{
int i;
/* create a new list entry */
@@ -339,7 +339,10 @@
i %= c->n_buckets;
p->astobj = obj;
p->version = ast_atomic_fetchadd_int(&c->version, 1);
- AST_LIST_INSERT_HEAD(&c->buckets[i], p, entry);
+ if (iax2_hack)
+ AST_LIST_INSERT_HEAD(&c->buckets[i], p, entry);
+ else
+ AST_LIST_INSERT_TAIL(&c->buckets[i], p, entry);
ast_atomic_fetchadd_int(&c->elements, 1);
ao2_unlock(c);
Modified: team/russell/ast_channel_refcount/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/russell/ast_channel_refcount/res/res_agi.c?view=diff&rev=80527&r1=80526&r2=80527
==============================================================================
--- team/russell/ast_channel_refcount/res/res_agi.c (original)
+++ team/russell/ast_channel_refcount/res/res_agi.c Thu Aug 23 12:35:14 2007
@@ -1866,14 +1866,9 @@
ast_frfree(f);
}
} else if (outfd > -1) {
- size_t len;
retry = RETRY;
buf[0] = '\0';
-retry_fgets:
- len = strlen(buf);
- if (!fgets(buf + len, sizeof(buf) - len, readf)) {
- if (!feof(readf) && (errno == EINTR || errno == EAGAIN))
- goto retry_fgets;
+ if (!fgets(buf, sizeof(buf), readf)) {
/* Program terminated */
if (returnstatus)
returnstatus = -1;
@@ -1885,8 +1880,6 @@
pid = -1;
break;
}
- if (errno == EINTR || errno == EAGAIN)
- goto retry_fgets;
/* get rid of trailing newline, if any */
if (*buf && buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
More information about the asterisk-commits
mailing list