提交 730d2f88 authored 作者: Chris Rienzo's avatar Chris Rienzo

mod_rayo: rename reference counting functions to something more sensible

上级 9aa51021
......@@ -142,8 +142,8 @@ extern iks *rayo_message_remove_payload(struct rayo_message *msg);
extern struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line);
extern struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int line);
extern int rayo_actor_seq_next(struct rayo_actor *actor);
extern void rayo_actor_rdlock(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_unlock(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_retain(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_release(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
#define RAYO_LOCATE(jid) rayo_actor_locate(jid, __FILE__, __LINE__)
......@@ -153,8 +153,8 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
#define RAYO_JID(x) RAYO_ACTOR(x)->jid
#define RAYO_ID(x) RAYO_ACTOR(x)->id
#define RAYO_POOL(x) RAYO_ACTOR(x)->pool
#define RAYO_RDLOCK(x) rayo_actor_rdlock(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_UNLOCK(x) rayo_actor_unlock(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_RETAIN(x) rayo_actor_retain(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_RELEASE(x) rayo_actor_release(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x))
......
......@@ -43,7 +43,7 @@ struct rayo_component *rayo_component_locate(const char *id, const char *file, i
if (actor && is_component_actor(actor)) {
return RAYO_COMPONENT(actor);
} else if (actor) {
RAYO_UNLOCK(actor);
RAYO_RELEASE(actor);
}
return NULL;
}
......@@ -114,7 +114,7 @@ void rayo_component_send_complete_event(struct rayo_component *component, iks *r
{
component->complete = 1;
RAYO_SEND_REPLY(component, iks_find_attrib(response, "to"), response);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
}
......
......@@ -236,7 +236,7 @@ static void rayo_cpa_detector_event(const char *jid, void *user_data)
} else {
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_COMPONENT(component)->parent->id), SWITCH_LOG_DEBUG, "Skipping CPA event\n");
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
......@@ -257,7 +257,7 @@ static void rayo_cpa_component_hangup(const char *jid, void *user_data)
if (component) {
stop_cpa_detectors(CPA_COMPONENT(component));
rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_HANGUP);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
......@@ -303,7 +303,7 @@ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg,
if (zstr(url)) {
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing grammar URL");
}
......@@ -318,7 +318,7 @@ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg,
if (switch_core_hash_find(component->signals, url)) {
free(url_dup);
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Duplicate URL");
}
......@@ -334,7 +334,7 @@ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg,
} else {
free(url_dup);
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, error_str);
}
......@@ -345,7 +345,7 @@ iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg,
if (!have_grammar) {
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "No grammar defined");
}
......
......@@ -217,7 +217,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
switch_event_destroy(&execute_event);
}
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(sendfax_component);
RAYO_RELEASE(sendfax_component);
} else {
/* component starting... */
rayo_component_send_start(RAYO_COMPONENT(sendfax_component), iq);
......@@ -225,7 +225,7 @@ static iks *start_sendfax_component(struct rayo_actor *call, struct rayo_message
} else {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create txfax event");
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(sendfax_component);
RAYO_RELEASE(sendfax_component);
}
return response;
......@@ -320,7 +320,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
switch_event_destroy(&execute_event);
}
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
RAYO_RELEASE(receivefax_component);
} else {
/* component starting... */
rayo_component_send_start(RAYO_COMPONENT(receivefax_component), iq);
......@@ -328,7 +328,7 @@ static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_mess
} else {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event");
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
RAYO_RELEASE(receivefax_component);
}
return response;
......@@ -463,7 +463,7 @@ static void on_execute_complete_event(switch_event_t *event)
rayo_component_send_complete_event(RAYO_COMPONENT(component), result);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
}
......
......@@ -551,7 +551,7 @@ static iks *start_call_voice_input(struct input_component *component, switch_cor
if (component->speech_mode && handler->voice_component) {
/* don't allow multi voice input */
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_CONFLICT, "Multiple voice input is not allowed");
}
......@@ -565,7 +565,7 @@ static iks *start_call_voice_input(struct input_component *component, switch_cor
/* if recognition engine is different, we can't handle this request */
if (!zstr(handler->last_recognizer) && strcmp(component->recognizer, handler->last_recognizer)) {
handler->voice_component = NULL;
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Must use the same recognizer for the entire call");
} else if (zstr(handler->last_recognizer)) {
......@@ -582,7 +582,7 @@ static iks *start_call_voice_input(struct input_component *component, switch_cor
if (!grammar) {
handler->voice_component = NULL;
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, stanza_error, error_detail);
}
......@@ -614,7 +614,7 @@ static iks *start_call_dtmf_input(struct input_component *component, switch_core
/* parse the grammar */
if (!(component->grammar = srgs_parse(globals.parser, iks_find_cdata(input, "grammar")))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to parse grammar body\n");
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Failed to parse grammar body");
}
......@@ -654,7 +654,7 @@ static iks *start_call_input(struct input_component *component, switch_core_sess
/* fire up media bug to monitor lifecycle */
if (switch_core_media_bug_add(session, "rayo_input_component", NULL, input_handler_bug_callback, handler, 0, SMBF_READ_REPLACE, &handler->bug) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failed to create input handler media bug\n");
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create input handler media bug");
}
......@@ -666,7 +666,7 @@ static iks *start_call_input(struct input_component *component, switch_core_sess
/* handler bug was destroyed */
switch_mutex_unlock(handler->mutex);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Input handler media bug is closed\n");
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Input handler media bug is closed\n");
}
......@@ -767,7 +767,9 @@ static iks *stop_call_input_component(struct rayo_actor *component, struct rayo_
switch_mutex_lock(input_component->handler->mutex);
input_component->stop = 1;
if (input_component->speech_mode) {
switch_mutex_unlock(input_component->handler->mutex);
switch_ivr_stop_detect_speech(session);
switch_mutex_lock(input_component->handler->mutex);
rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP);
}
switch_mutex_unlock(input_component->handler->mutex);
......@@ -789,7 +791,9 @@ static iks *start_timers_call_input_component(struct rayo_actor *component, stru
if (session) {
switch_mutex_lock(input_component->handler->mutex);
if (input_component->speech_mode) {
switch_mutex_unlock(input_component->handler->mutex);
switch_ivr_detect_speech_start_input_timers(session);
switch_mutex_lock(input_component->handler->mutex);
} else {
input_component->last_digit_time = switch_micro_time_now();
input_component->start_timers = 1;
......@@ -861,7 +865,7 @@ static void on_detected_speech_event(switch_event_t *event)
rayo_component_send_complete(component, INPUT_NOMATCH);
}
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
} else if (!strcasecmp("begin-speaking", speech_type)) {
char *component_id = switch_mprintf("%s-input-voice", uuid);
......@@ -870,7 +874,7 @@ static void on_detected_speech_event(switch_event_t *event)
if (component && INPUT_COMPONENT(component)->barge_event) {
send_barge_event(component);
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
} else if (!strcasecmp("closed", speech_type)) {
char *component_id = switch_mprintf("%s-input-voice", uuid);
struct rayo_component *component = RAYO_COMPONENT_LOCATE(component_id);
......@@ -887,7 +891,7 @@ static void on_detected_speech_event(switch_event_t *event)
/* shouldn't get here... */
rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR);
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
switch_safe_free(event_str);
......
......@@ -112,11 +112,11 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component));
if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) {
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
} else {
if (component->complete) {
/* component is already destroyed */
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
} else {
/* need to destroy component */
if (OUTPUT_COMPONENT(component)->document) {
......@@ -210,7 +210,7 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m
rayo_component_api_execute_async(component, "conference", stream.data);
switch_safe_free(stream.data);
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
return NULL;
}
......@@ -512,7 +512,7 @@ static switch_status_t rayo_file_open(switch_file_handle_t *handle, const char *
if (status != SWITCH_STATUS_SUCCESS && context->component) {
/* complete error event will be sent by calling thread */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Status = %i\n", status);
RAYO_UNLOCK(context->component);
RAYO_RELEASE(context->component);
}
return status;
......
......@@ -288,7 +288,7 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struc
/* done */
iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_RELEASE(prompt);
RAYO_DESTROY(prompt);
break;
......@@ -357,7 +357,7 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *prompt, stru
/* done */
iks_delete(PROMPT_COMPONENT(prompt)->iq);
RAYO_UNLOCK(prompt);
RAYO_RELEASE(prompt);
RAYO_DESTROY(prompt);
break;
......
......@@ -141,7 +141,7 @@ static void on_call_record_stop_event(switch_event_t *event)
/* TODO assume final timeout, for now */
complete_record(component, RECORD_COMPLETE_FINAL_TIMEOUT);
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
......@@ -282,7 +282,7 @@ static iks *start_call_record_component(struct rayo_actor *call, struct rayo_mes
if (start_call_record(session, component)) {
rayo_component_send_start(component, iq);
} else {
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR);
}
......@@ -369,7 +369,7 @@ static void on_mixer_record_event(switch_event_t *event)
complete_record(component, RECORD_COMPLETE_FINAL_TIMEOUT);
}
}
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
}
}
......@@ -412,7 +412,7 @@ static iks *start_mixer_record_component(struct rayo_actor *mixer, struct rayo_m
/* mixer doesn't allow "send" */
if (!strcmp("send", iks_find_attrib_soft(record, "direction"))) {
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
}
......@@ -420,7 +420,7 @@ static iks *start_mixer_record_component(struct rayo_actor *mixer, struct rayo_m
if (start_mixer_record(component)) {
rayo_component_send_start(component, iq);
} else {
RAYO_UNLOCK(component);
RAYO_RELEASE(component);
RAYO_DESTROY(component);
return iks_new_error(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论