Merged revisions 341580 via svnmerge from
authorGregory Nietsky <gregory@distrotech.co.za>
Thu, 20 Oct 2011 17:34:54 +0000 (17:34 +0000)
committerGregory Nietsky <gregory@distrotech.co.za>
Thu, 20 Oct 2011 17:34:54 +0000 (17:34 +0000)
https://origsvn.digium.com/svn/asterisk/branches/10

........
  r341580 | irroot | 2011-10-20 19:13:23 +0200 (Thu, 20 Oct 2011) | 15 lines

  Add option to check state when state is unknown

  r341486 reverts r325483 this is a rework of the patch.
  optimize to minimize load.

  add option check_state_unknown to control whether a member with unknown
  device state is checked there is a small % chance that calls will be sent
  to the member when they on a call.

  app_queue will see a device with unknown state as available and does not
  try verify the state without this option enabled.

  Review: https://reviewboard.asterisk.org/r/1535/
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@341583 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_queue.c

diff --git a/CHANGES b/CHANGES
index ea49471..49e5843 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -254,6 +254,8 @@ Queue changes
  * Added member option ignorebusy this when set and ringinuse is not
    will allow per member control of multiple calls as ringinuse does for
    the Queue.
+ * Added global option check_state_unknown to enforce checking of device state
+   when the device state is unknown app_queue will see unknown as available.
 
 Applications
 ------------
index 3e75d39..94372a5 100644 (file)
@@ -957,6 +957,9 @@ static int negative_penalty_invalid = 0;
 /*! \brief queues.conf [general] option */
 static int log_membername_as_agent = 0;
 
+/*! \brief queues.conf [general] option */
+static int check_state_unknown = 0;
+
 enum queue_result {
        QUEUE_UNKNOWN = 0,
        QUEUE_TIMEOUT = 1,
@@ -3076,6 +3079,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        char tech[256];
        char *location;
        const char *macrocontext, *macroexten;
+       enum ast_device_state newstate;
 
        /* on entry here, we know that tmp->chan == NULL */
        if (tmp->member->paused) {
@@ -3100,6 +3104,14 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        }
 
        if (!qe->parent->ringinuse || !tmp->member->ignorebusy) {
+               if (check_state_unknown && (tmp->member->status == AST_DEVICE_UNKNOWN)) {
+                       newstate = ast_device_state(tmp->member->interface);
+                       if (newstate != tmp->member->status) {
+                               ast_log(LOG_WARNING, "Found a channel matching iterface %s while status was %s changed to %s\n",
+                                       tmp->member->interface, ast_devstate2str(tmp->member->status), ast_devstate2str(newstate));
+                               ast_devstate_changed_literal(newstate, tmp->member->interface);
+                       }
+               }
                if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
                        ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
                        if (qe->chan->cdr) {
@@ -6721,25 +6733,34 @@ static void queue_set_global_params(struct ast_config *cfg)
                queue_persistent_members = ast_true(general_val);
        }
        autofill_default = 0;
-       if ((general_val = ast_variable_retrieve(cfg, "general", "autofill")))
+       if ((general_val = ast_variable_retrieve(cfg, "general", "autofill"))) {
                autofill_default = ast_true(general_val);
+       }
        montype_default = 0;
        if ((general_val = ast_variable_retrieve(cfg, "general", "monitor-type"))) {
                if (!strcasecmp(general_val, "mixmonitor"))
                        montype_default = 1;
        }
        update_cdr = 0;
-       if ((general_val = ast_variable_retrieve(cfg, "general", "updatecdr")))
+       if ((general_val = ast_variable_retrieve(cfg, "general", "updatecdr"))) {
                update_cdr = ast_true(general_val);
+       }
        shared_lastcall = 0;
-       if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall")))
+       if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall"))) {
                shared_lastcall = ast_true(general_val);
+       }
        negative_penalty_invalid = 0;
-       if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid")))
+       if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid"))) {
                negative_penalty_invalid = ast_true(general_val);
+       }
        log_membername_as_agent = 0;
-       if ((general_val = ast_variable_retrieve(cfg, "general", "log_membername_as_agent")))
+       if ((general_val = ast_variable_retrieve(cfg, "general", "log_membername_as_agent"))) {
                log_membername_as_agent = ast_true(general_val);
+       }
+       check_state_unknown = 0;
+       if ((general_val = ast_variable_retrieve(cfg, "general", "check_state_unknown"))) {
+               check_state_unknown = ast_true(general_val);
+       }
 }
 
 /*! \brief reload information pertaining to a single member