static void _mc_table_new(void);
static gpointer _mc_get_fd_ptr(int sock_fd);
+static int _muse_client_new(muse_channel_e channel);
+
#ifdef MUSE_USE_CLIENT_SIGHANDLER
static gboolean _mc_table_remove_func(gpointer key, gpointer value, gpointer user_data)
{
LOGI("Enter");
muse_return_val_if_fail(channel < MUSE_CHANNEL_MAX, MM_ERROR_INVALID_ARGUMENT);
- muse_return_val_if_fail(muse_server_is_ready(), MM_ERROR_UNKNOWN);
/* create socket */
sock_fd = socket(AF_UNIX, SOCK_STREAM, 0);
static void _mc_table_new(void)
{
- muse_return_if_fail(muse_server_is_ready());
-
g_mutex_lock(&mc_mutex);
if (!mc_table) {
return g_hash_table_lookup(mc_table, GINT_TO_POINTER(sock_fd));
}
+static int _muse_client_new(muse_channel_e channel)
+{
+ if (!muse_server_is_ready()) {
+ LOGE("muse server is not ready");
+ return MM_ERROR_UNKNOWN;
+ }
+
+ if (channel == MUSE_CHANNEL_MSG)
+ _mc_table_new();
+
+ return _mc_new(channel);
+}
+
int muse_client_new(void)
{
- _mc_table_new();
- return _mc_new(MUSE_CHANNEL_MSG);
+ return _muse_client_new(MUSE_CHANNEL_MSG);
}
int muse_client_new_data_ch(void)
{
- return _mc_new(MUSE_CHANNEL_DATA);
+ return _muse_client_new(MUSE_CHANNEL_DATA);
}
int muse_client_close(int sock_fd)
bool muse_server_is_ready(void)
{
- return access(MUSE_DEFAULT_PIDFILE, F_OK) == 0;
+ return access(MUSE_SERVER_READY, F_OK) == 0;
}
int muse_core_connection_close(int sock_fd)
#else
if (remove(MUSE_SERVER_READY) == -1)
LOGE("remove %s failed [errno : %d]", MUSE_SERVER_READY, errno);
+
+ if (remove(MUSE_DEFAULT_PIDFILE) == -1)
+ LOGE("remove %s failed [errno : %d]", MUSE_DEFAULT_PIDFILE, errno);
#endif
}