#include <unistd.h>
#include <glib.h>
#include <pims-ipc-data.h>
+#include <pthread.h>
#include "ctsvc_client_ipc.h"
#include "ctsvc_client_utils.h"
GList *list_handle;
};
+static pthread_mutex_t _ctsvc_mutex_disconnected = PTHREAD_MUTEX_INITIALIZER;
static GHashTable *_ctsvc_ipc_table = NULL;
static bool _ctsvc_ipc_disconnected = false;
if (NULL == ipc_data)
return;
- if (ipc_data->ipc)
+ if (ipc_data->ipc) {
+ ctsvc_ipc_unset_disconnected_cb(ipc_data->ipc);
pims_ipc_destroy(ipc_data->ipc);
+ }
g_list_free(ipc_data->list_handle);
void ctsvc_ipc_set_disconnected(bool is_disconnected)
{
+ pthread_mutex_lock(&_ctsvc_mutex_disconnected);
_ctsvc_ipc_disconnected = is_disconnected;
+ pthread_mutex_unlock(&_ctsvc_mutex_disconnected);
}
int ctsvc_ipc_get_disconnected()
{
+ pthread_mutex_lock(&_ctsvc_mutex_disconnected);
CTS_DBG("_ctsvc_ipc_disconnected=%d", _ctsvc_ipc_disconnected);
+ pthread_mutex_unlock(&_ctsvc_mutex_disconnected);
return _ctsvc_ipc_disconnected;
}
GList *c;
struct ctsvc_ipc_s *ipc_data = value;
+ ctsvc_ipc_unset_disconnected_cb(ipc_data->ipc);
int ret = _ctsvc_ipc_create(&(ipc_data->ipc));
RETM_IF(CONTACTS_ERROR_NONE != ret, "_ctsvc_ipc_create() Fail(%d)", ret);
ctsvc_ipc_set_disconnected_cb(ipc_data->ipc, _ctsvc_ipc_disconnected_cb, NULL);
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_NONE;
}
- if (__ipc)
- ctsvc_ipc_unset_disconnected_cb(__ipc);
__ipc = pims_ipc_create_for_subscribe(CTSVC_IPC_SOCKET_PATH_FOR_CHANGE_SUBSCRIPTION);
if (!__ipc) {
CTS_ERR("pims_ipc_create_for_subscribe error\n");
ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
if (1 == __ipc_pubsub_ref) {
- ctsvc_ipc_unset_disconnected_cb(__ipc);
pims_ipc_destroy_for_subscribe(__ipc);
__ipc = NULL;
}