[Freeswitch-svn] [commit] r11078 - in freeswitch/trunk/libs/esl: . src
FreeSWITCH SVN
anthm at freeswitch.org
Mon Jan 5 16:18:57 PST 2009
Author: anthm
Date: Mon Jan 5 18:18:57 2009
New Revision: 11078
Log:
cleanup and fix disconnect race
Modified:
freeswitch/trunk/libs/esl/fs_cli.c
freeswitch/trunk/libs/esl/src/esl.c
Modified: freeswitch/trunk/libs/esl/fs_cli.c
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.c (original)
+++ freeswitch/trunk/libs/esl/fs_cli.c Mon Jan 5 18:18:57 2009
@@ -618,6 +618,7 @@
}
if (esl_connect(&handle, profile->host, profile->port, profile->pass)) {
+ esl_global_set_default_logger(3);
esl_log(ESL_LOG_ERROR, "Error Connecting [%s]\n", handle.err);
return -1;
}
Modified: freeswitch/trunk/libs/esl/src/esl.c
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl.c (original)
+++ freeswitch/trunk/libs/esl/src/esl.c Mon Jan 5 18:18:57 2009
@@ -570,24 +570,32 @@
ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
{
+ esl_mutex_t *mutex = handle->mutex;
+ esl_status_t status = ESL_SUCCESS;
+
+ if (mutex) {
+ esl_mutex_lock(mutex);
+ }
+
esl_event_safe_destroy(&handle->last_event);
esl_event_safe_destroy(&handle->last_sr_event);
esl_event_safe_destroy(&handle->last_ievent);
esl_event_safe_destroy(&handle->info_event);
- if (handle->mutex) {
- esl_mutex_destroy(&handle->mutex);
- }
-
if (handle->sock != ESL_SOCK_INVALID) {
closesocket(handle->sock);
handle->sock = ESL_SOCK_INVALID;
- return ESL_SUCCESS;
}
handle->connected = 0;
- return ESL_FAIL;
+ if (mutex) {
+ esl_mutex_unlock(mutex);
+ esl_mutex_destroy(&mutex);
+ }
+
+
+ return status;
}
ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, esl_event_t **save_event)
More information about the Freeswitch-svn
mailing list