switch_snprintf(buf, sizeof(buf), "%d", i);
token = (valet_token_t *) switch_core_hash_find(lot->hash, buf);
- if ((in && !token) || (!in && token && !token->timeout)) {
+ if ((!in && token && !token->timeout)) {
+ goto end;
+ }
+
+ if (in && !token) {
r = i;
break;
}
switch_core_hash_insert(lot->hash, buf, token);
}
+ end:
+
switch_mutex_unlock(globals.mutex);
return token;
switch_input_args_t args = { 0 };
char dbuf[10];
char *dest;
+ int in = -1;
lot = valet_find_lot(lot_name);
switch_assert(lot);
const char *io = argv[2];
const char *min = argv[3];
const char *max = argv[4];
- int min_i, max_i, in = -1;
+ int min_i, max_i;
if (argc < 5) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", VALET_APP_SYNTAX);
if (in < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", VALET_APP_SYNTAX);
- switch_mutex_unlock(lot->mutex);
return;
}
if (!(token = next_id(session, lot, min_i, max_i, in))) {
switch_ivr_phrase_macro(session, in ? "valet_lot_full" : "valet_lot_empty", "", NULL, NULL);
- switch_mutex_unlock(lot->mutex);
return;
}
switch_snprintf(dtmf_buf, sizeof(dtmf_buf), "%s", token->ext);
ext = dtmf_buf;
+
} else if (!strcasecmp(ext, "ask")) {
const char *prompt = "ivr/ivr-enter_ext_pound.wav";
int min = 1;
}
}
- if (!token) {
+ if (!token || !in) {
-
- switch_mutex_lock(lot->mutex);
- if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, ext))) {
+ if (!token) {
+ switch_mutex_lock(lot->mutex);
+ token = (valet_token_t *) switch_core_hash_find(lot->hash, ext);
+ switch_mutex_unlock(lot->mutex);
+ }
+
+ if (token) {
switch_core_session_t *b_session;
if (token->timeout) {
token->bridged = 1;
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), token->uuid);
- switch_mutex_unlock(lot->mutex);
return;
}
}
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
}
switch_ivr_session_transfer(b_session, dest, "inline", NULL);
- switch_mutex_unlock(lot->mutex);
switch_core_session_rwunlock(b_session);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
goto end;
args.buf = dbuf;
args.buflen = sizeof(dbuf);
- switch_mutex_unlock(lot->mutex);
while(switch_channel_ready(channel)) {