switch_mutex_lock(globals.mutex);
for (i = min; (i < max || max == 0); i++) {
switch_snprintf(buf, sizeof(buf), "%d", i);
+ switch_mutex_lock(lot->mutex);
token = (valet_token_t *) switch_core_hash_find(lot->hash, buf);
-
+ switch_mutex_unlock(lot->mutex);
+
if ((!in && token && !token->timeout)) {
goto end;
}
switch_zmalloc(token, sizeof(*token));
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
switch_set_string(token->ext, buf);
+ switch_mutex_lock(lot->mutex);
switch_core_hash_insert(lot->hash, buf, token);
+ switch_mutex_unlock(lot->mutex);
}
end:
if (!token) {
switch_mutex_lock(lot->mutex);
token = (valet_token_t *) switch_core_hash_find(lot->hash, ext);
- if (token->bridged) {
- token = NULL;
- }
switch_mutex_unlock(lot->mutex);
}
- if (token) {
+ if (token && !token->bridged) {
switch_core_session_t *b_session;
if (token->timeout) {
}
}
- token = NULL;
-
- switch_zmalloc(token, sizeof(*token));
+ if (token) {
+ switch_mutex_lock(lot->mutex);
+ switch_core_hash_delete(lot->hash, token->ext);
+ switch_mutex_unlock(lot->mutex);
+ memset(token, 0, sizeof(*token));
+ } else {
+ switch_zmalloc(token, sizeof(*token));
+ }
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
switch_set_string(token->ext, ext);
+ switch_mutex_lock(lot->mutex);
switch_core_hash_insert(lot->hash, ext, token);
+ switch_mutex_unlock(lot->mutex);
}
if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
stream->write_function(stream, " <lot name=\"%s\">\n", name);
+ switch_mutex_lock(lot->mutex);
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
valet_token_t *token;
stream->write_function(stream, " <extension uuid=\"%s\">%s</extension>\n", token->uuid, i_ext);
}
}
+ switch_mutex_unlock(lot->mutex);
+
stream->write_function(stream, " </lot>\n");
}