#include "espp_service_priv.h"
#include <esplusplayer_capi.h>
-typedef void (*func_handler) (espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result);
+typedef void (*func_handler) (handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result);
-static void __handle_init_event(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+typedef struct {
+ int fd;
+ int event_fd;
+ esplusplayer_handle espp;
+} tb_data_s;
+
+static void __handle_init_event(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
- ASSERT(svc);
- ASSERT(fd >= 0);
+ int ret;
+
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
- LOG_DEBUG("event initialization requested");
+ result->ret = -1;
+
+ ret = espp_service_msg_parse_params(data->params, data->request, &hdata->client.handle_addr);
+ if (ret != 0)
+ return;
+
+ LOG_INFO("fd[%d], client[pid:%u, handle:0x%x]", hdata->fd, hdata->client.pid, hdata->client.handle_addr);
result->ret = 0;
}
-static void __handle_create(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_create(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
+ int ret;
esplusplayer_handle espp;
+ tb_data_s *tbs;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
+ ret = espp_service_msg_parse_params(data->params, data->request, &hdata->client.handle_addr);
+ if (ret != 0)
+ return;
+
espp = esplusplayer_create();
ASSERT(espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_create() success", fd, espp);
+ hdata->espp = espp;
+ hdata->key = g_strdup_printf("%u_%x", hdata->client.pid, hdata->client.handle_addr);
+
+ LOG_INFO("fd[%d], client[pid:%u, handle:0x%x], ESPP[%p]: esplusplayer_create() success",
+ hdata->fd, hdata->client.pid, hdata->client.handle_addr, espp);
+
+ tbs = g_new0(tb_data_s, 1);
+ tbs->fd = hdata->fd;
+ tbs->espp = hdata->espp;
- if (!g_hash_table_insert(svc->espp_handles, GINT_TO_POINTER(fd), (gpointer)espp)) {
- LOG_ERROR("should not be reached here, fd[%d] already exist, ESPP[%p] will be removed", fd, espp);
- g_hash_table_remove(svc->espp_handles, GINT_TO_POINTER(fd));
+ if (!g_hash_table_insert(hdata->svc->fd_table, hdata->key, (gpointer)tbs)) {
+ LOG_ERROR("should not be reached here, key[%s] already exist", hdata->key);
+ g_hash_table_remove(hdata->svc->fd_table, hdata->key);
esplusplayer_destroy(espp);
return;
}
result->ret = 0;
}
-static void __handle_destroy(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_destroy(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
- esplusplayer_handle espp;
-
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "could not find ESPP by fd[%d]", fd);
- RET_IF(esplusplayer_destroy(espp) != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_destroy()");
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_destroy() success", fd, espp);
+ RET_IF(esplusplayer_destroy((esplusplayer_handle)hdata->espp) != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_destroy()");
- ASSERT(g_hash_table_steal(svc->espp_handles, GINT_TO_POINTER(fd)));
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_destroy() success", hdata->fd, hdata->espp);
+
+ ASSERT(g_hash_table_steal(hdata->svc->fd_table, hdata->key));
result->ret = 0;
}
-static void __handle_open(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_open(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- ret = esplusplayer_open(espp);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_open(), ESPP[%p]", espp);
+ ret = esplusplayer_open((esplusplayer_handle)hdata->espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_open(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_open() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_open() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_close(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_close(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- ret = esplusplayer_close(espp);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_close(), ESPP[%p]", espp);
+ ret = esplusplayer_close((esplusplayer_handle)hdata->espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_close(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_close() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_close() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_start(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_start(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- ret = esplusplayer_start(espp);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_start(), ESPP[%p]", espp);
+ ret = esplusplayer_start((esplusplayer_handle)hdata->espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_start(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_start() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_start() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_stop(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_stop(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- ret = esplusplayer_stop(espp);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_stop(), ESPP[%p]", espp);
+ ret = esplusplayer_stop((esplusplayer_handle)hdata->espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_stop(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_stop() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_stop() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_prepare_async(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_prepare_async(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
- ret = esplusplayer_prepare_async(espp);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_prepare_async(), ESPP[%p]", espp);
+ ret = esplusplayer_prepare_async((esplusplayer_handle)hdata->espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_prepare_async(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_prepare_async() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_prepare_async() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_set_audio_stream_info(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_set_audio_stream_info(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
esplusplayer_audio_stream_info info;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
ret = espp_service_msg_parse_params(data->params, data->request,
&info.codec_data, &info.codec_data_length, &info.mime_type,
if (ret != 0)
return;
- ret = esplusplayer_set_audio_stream_info(espp, &info);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_audio_stream_info(), ESPP[%p]", espp);
+ ret = esplusplayer_set_audio_stream_info((esplusplayer_handle)hdata->espp, &info);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_audio_stream_info(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_audio_stream_info() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_audio_stream_info() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_set_video_stream_info(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_set_video_stream_info(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
esplusplayer_video_stream_info info;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
ret = espp_service_msg_parse_params(data->params, data->request,
&info.codec_data, &info.codec_data_length, &info.mime_type,
if (ret != 0)
return;
- ret = esplusplayer_set_video_stream_info(espp, &info);
- RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_video_stream_info(), ESPP[%p]", espp);
+ ret = esplusplayer_set_video_stream_info((esplusplayer_handle)hdata->espp, &info);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_video_stream_info(), ESPP[%p]", hdata->espp);
- LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_video_stream_info() success", fd, espp);
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_video_stream_info() success", hdata->fd, hdata->espp);
result->ret = 0;
}
-static void __handle_set_callback(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+static void __handle_set_callback(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
- esplusplayer_handle espp;
espp_service_cb_type_e cb_type;
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
ASSERT(data);
ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
result->ret = -1;
- RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
ret = espp_service_msg_parse_params(data->params, data->request, &cb_type);
if (ret != 0)
return;
- LOG_INFO("fd[%d], ESPP[%p]: cb_type[%d]", fd, espp, cb_type);
+ LOG_INFO("fd[%d], ESPP[%p]: cb_type[%d]", hdata->fd, hdata->espp, cb_type);
result->ret = 0;
}
[ESPP_SERVICE_REQUEST_SET_CALLBACK] = __handle_set_callback,
};
-int espp_service_func_handler(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+int espp_service_func_handler(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
- ASSERT(svc);
- ASSERT(fd >= 0);
+ ASSERT(hdata);
+ ASSERT(hdata->fd >= 0);
+ ASSERT(hdata->svc);
ASSERT(data);
ASSERT(result);
- LOG_WARNING("fd[%d] data[%p, request:%s]", fd, data, requests[data->request].str);
+ LOG_WARNING("fd[%d] data[%p, request:%s]", hdata->fd, data, requests[data->request].str);
- handlers[data->request](svc, fd, data, result);
+ handlers[data->request](hdata, data, result);
return 0;
}
void espp_service_handle_destroy_cb(gpointer data)
{
- esplusplayer_handle espp = (esplusplayer_handle)data;
+ tb_data_s *tbs = (tb_data_s *)data;
- ASSERT(data);
+ ASSERT(tbs);
+
+ LOG_INFO("destroy tbs[%p, fd:%d, event_fd:%d, ESPP:%p]",
+ tbs, tbs->fd, tbs->event_fd, tbs->espp);
- LOG_INFO("destroy ESPP[%p]", espp);
+ if (esplusplayer_stop(tbs->espp) != ESPLUSPLAYER_ERROR_TYPE_NONE)
+ LOG_ERROR("failed to esplusplayer_stop()");
+ if (esplusplayer_close(tbs->espp) != ESPLUSPLAYER_ERROR_TYPE_NONE)
+ LOG_ERROR("failed to esplusplayer_close()");
+ if (esplusplayer_destroy(tbs->espp) != ESPLUSPLAYER_ERROR_TYPE_NONE)
+ LOG_ERROR("failed to esplusplayer_destroy()");
- RET_IF(esplusplayer_destroy(espp) != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_destroy()");
-}
\ No newline at end of file
+ g_free(tbs);
+}
} \
} while (0)
-typedef struct {
- espp_service_s *svc;
- int fd;
- unsigned int pid;
-} work_thread_userdata_s;
-
-static int __event_ret_msg_handling(int fd, espp_service_s *svc)
+static int __event_ret_msg_handling(handler_userdata_s *hdata)
{
int ret;
+ int fd;
char str_error[MAX_ERROR_LEN] = {'\0',};
espp_service_data_from_client_s rx_data;
- ASSERT(fd >= 0);
- ASSERT(svc);
+ ASSERT(hdata);
+ ASSERT(hdata->fd >= 0);
+ ASSERT(hdata->svc);
+
+ fd = hdata->fd;
memset(&rx_data, 0x00, sizeof(espp_service_data_from_client_s));
if ((ret = read(fd, &rx_data, sizeof(espp_service_data_from_client_s))) < 0) {
return -1;
}
-static int __request_msg_handling(int fd, espp_service_s *svc, bool *event_mode)
+static int __request_msg_handling(handler_userdata_s *hdata, bool *event_mode)
{
int ret;
+ int fd;
char str_error[MAX_ERROR_LEN] = {'\0',};
espp_service_data_from_client_s rx_data;
espp_service_data_from_server_s tx_data;
- ASSERT(fd >= 0);
- ASSERT(svc);
+ ASSERT(hdata);
+ ASSERT(hdata->fd >= 0);
+ ASSERT(hdata->svc);
ASSERT(event_mode);
+ fd = hdata->fd;
+
memset(&rx_data, 0x00, sizeof(espp_service_data_from_client_s));
if ((ret = read(fd, &rx_data, sizeof(espp_service_data_from_client_s))) < 0) {
strerror_r(errno, str_error, sizeof(str_error));
LOG_DEBUG("<<<<< from fd[%d]: request[%s]", fd, requests[rx_data.request].str);
memset(&tx_data, 0x00, sizeof(espp_service_data_from_server_s));
- if (espp_service_func_handler(svc, fd, &rx_data, &tx_data) != 0)
+ if (espp_service_func_handler(hdata, &rx_data, &tx_data) != 0)
LOG_ERROR("failed to espp_service_func_handler()");
LOG_DEBUG(">>>>>> to fd[%d]: ret[%d]", fd, tx_data.ret);
static void *__work_thread_func(void *data)
{
- int fd;
bool event_mode = false;
- work_thread_userdata_s *userdata = (work_thread_userdata_s *)data;
- espp_service_s *svc;
-
- ASSERT(userdata);
- ASSERT(userdata->fd != -1);
+ handler_userdata_s *hdata = (handler_userdata_s *)data;
- fd = userdata->fd;
- svc = userdata->svc;
+ ASSERT(hdata);
+ ASSERT(hdata->fd != -1);
- LOG_WARNING("entrance, fd[%d]", fd);
+ LOG_WARNING("entrance, fd[%d]", hdata->fd);
do {
if (!event_mode) {
- if (__request_msg_handling(fd, svc, &event_mode) == -1)
+ if (__request_msg_handling(hdata, &event_mode) == -1)
goto exit;
} else {
- if (__event_ret_msg_handling(fd, svc) == -1)
+ if (__event_ret_msg_handling(hdata) == -1)
goto exit;
}
} while (1);
exit:
- LOG_WARNING("exit, fd[%d]", fd);
- g_free(userdata);
- close(fd);
+ LOG_WARNING("exit, fd[%d]", hdata->fd);
+ close(hdata->fd);
+ g_free(hdata);
pthread_exit(NULL);
}
int client_fd = -1;
pthread_attr_t attr;
char str_error[MAX_ERROR_LEN] = {'\0',};
- work_thread_userdata_s *userdata;
+ handler_userdata_s *userdata = NULL;
pthread_t work_thread_id;
ASSERT(svc);
LOG_ERROR("failed to accept(), err: %s", str_error);
goto exit;
}
- LOG_DEBUG("client_fd[%d]", client_fd);
- userdata = g_new0(work_thread_userdata_s, 1);
+ userdata = g_new0(handler_userdata_s, 1);
userdata->svc = svc;
userdata->fd = client_fd;
- userdata->pid = get_pid_from_fd(client_fd);
+ userdata->client.pid = get_pid_from_fd(client_fd);
+
+ LOG_DEBUG("client[fd:%d, pid:%u]", client_fd, userdata->client.pid);
if (pthread_create(&work_thread_id, &attr, (void *)__work_thread_func, (void *)userdata)) {
LOG_ERROR("failed to pthread_create(), client_fd[%d]", client_fd);
- g_free(userdata);
goto exit;
}
if (client_fd >= 0)
close(client_fd);
+ if (userdata)
+ g_free(userdata);
+
LOG_DEBUG("pthread_exit()");
pthread_attr_destroy(&attr);
pthread_exit(NULL);
LOG_DEBUG("pthread_join() done");
svc->thread_id = 0;
}
-}
\ No newline at end of file
+}