[asterisk-commits] russell: branch russell/sla_rewrite r53495 -
/team/russell/sla_rewrite/apps/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Feb 7 15:56:40 MST 2007
Author: russell
Date: Wed Feb 7 16:56:39 2007
New Revision: 53495
URL: http://svn.digium.com/view/asterisk?view=rev&rev=53495
Log:
If there is a failure trying to dial a station, remember that it happened, and
don't try to dial that station again for at least a minute.
Modified:
team/russell/sla_rewrite/apps/app_meetme.c
Modified: team/russell/sla_rewrite/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/sla_rewrite/apps/app_meetme.c?view=diff&rev=53495&r1=53494&r2=53495
==============================================================================
--- team/russell/sla_rewrite/apps/app_meetme.c (original)
+++ team/russell/sla_rewrite/apps/app_meetme.c Wed Feb 7 16:56:39 2007
@@ -3012,10 +3012,17 @@
static void *sla_thread(void *data)
{
AST_LIST_HEAD_NOLOCK_STATIC(ringing_stations, sla_station_ref);
+ struct sla_failed_station {
+ struct sla_station *station;
+ struct timeval last_try;
+ AST_LIST_ENTRY(sla_failed_station) entry;
+ };
+ AST_LIST_HEAD_NOLOCK_STATIC(failed_stations, sla_failed_station);
+ struct sla_station_ref *station_ref;
+ struct sla_failed_station *failed_station;
for (; !sla.stop;) {
struct sla_trunk_ref *trunk_ref = NULL;
- struct sla_station_ref *station_ref;
struct sla_event *event;
enum ast_dial_result dial_res = AST_DIAL_RESULT_TRYING;
@@ -3059,6 +3066,22 @@
char *tech, *tech_data;
struct ast_dial *dial;
struct sla_station_ref *ringing_ref;
+ struct sla_failed_station *failed_station;
+ /* Did we fail to dial this station earlier? If so, has it been
+ * a minute since we tried? */
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&failed_stations, failed_station, entry) {
+ if (station_ref->station != failed_station->station)
+ continue;
+ if (ast_tvdiff_ms(ast_tvnow(), failed_station->last_try) > 1000) {
+ AST_LIST_REMOVE_CURRENT(&failed_stations, entry);
+ free(failed_station);
+ failed_station = NULL;
+ }
+ break;
+ }
+ if (failed_station)
+ continue;
+ AST_LIST_TRAVERSE_SAFE_END
AST_LIST_TRAVERSE(&ringing_stations, ringing_ref, entry) {
if (station_ref->station == ringing_ref->station)
break;
@@ -3075,6 +3098,11 @@
}
if (ast_dial_run(dial, NULL, 1) != AST_DIAL_RESULT_TRYING) {
ast_dial_destroy(dial);
+ if (!(failed_station = ast_calloc(1, sizeof(*failed_station))))
+ continue;
+ failed_station->station = station_ref->station;
+ failed_station->last_try = ast_tvnow();
+ AST_LIST_INSERT_HEAD(&failed_stations, failed_station, entry);
continue;
}
if (!(ringing_ref = create_station_ref(station_ref->station))) {
@@ -3195,6 +3223,12 @@
AST_LIST_TRAVERSE_SAFE_END
}
+ while ((station_ref = AST_LIST_REMOVE_HEAD(&ringing_stations, entry)))
+ free(station_ref);
+
+ while ((failed_station = AST_LIST_REMOVE_HEAD(&failed_stations, entry)))
+ free(failed_station);
+
return NULL;
}
More information about the asterisk-commits
mailing list