pthread_mutex_t data_queue_mutex;
GList *data_queue;
+
+ pthread_mutex_t call_mutex; /* not to be interrupted while sending and receiving */
} pims_ipc_s;
static unsigned int ref_cnt;
if (0 < handle->disconnected_source)
g_source_remove(handle->disconnected_source);
+ pthread_mutex_destroy(&handle->call_mutex);
pthread_mutex_destroy(&handle->call_status_mutex);
g_free(handle);
handle->call_status = PIMS_IPC_CALL_STATUS_READY;
pthread_mutex_unlock(&handle->call_status_mutex);
+ pthread_mutex_init(&handle->call_mutex, 0);
+
bzero(&server_addr, sizeof(server_addr));
server_addr.sun_family = AF_UNIX;
snprintf(server_addr.sun_path, sizeof(server_addr.sun_path), "%s", handle->service);
}
pthread_mutex_unlock(&handle->call_status_mutex);
- if (__pims_ipc_send(handle, module, function, data_in) != 0)
- return -1;
+ int ret = 0;
+ pthread_mutex_lock(&handle->call_mutex);
+ do {
+ ret = __pims_ipc_send(handle, module, function, data_in);
+ if (0 != ret)
+ break;
- if (__pims_ipc_receive(handle, data_out) != 0)
- return -1;
+ ret = __pims_ipc_receive(handle, data_out);
+ if (0 != ret)
+ break;
+ } while (0);
+ pthread_mutex_unlock(&handle->call_mutex);
- return 0;
+ return ret;
}
static gboolean __call_async_idler_cb(gpointer data)