mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 07:45:26 +00:00
cleanup and fix disconnect race
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11078 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
dace6b6bb9
commit
bbac44c53a
@ -618,6 +618,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -570,24 +570,32 @@ ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, es
|
||||
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user