{
struct buxton_client *cli = data;
GList *f;
+ buxton_status_callback callback = NULL;
+ void * user_data;
assert(cli);
close(cli->fd);
cli->fd = -1;
+
+ if (cli->st_callback) {
+ callback = cli->st_callback;
+ user_data = cli->st_data;
+ }
pthread_mutex_unlock(&clients_lock);
- if (cli->st_callback)
- cli->st_callback(BUXTON_STATUS_CONNECTION_CLOSED, cli->st_data);
+
+ if (callback)
+ callback(BUXTON_STATUS_CONNECTION_CLOSED, user_data);
return G_SOURCE_REMOVE;
}
if (!f) {
bxt_dbg("recv %d: cli %p removed\n", fd, cli);
pthread_mutex_unlock(&clients_lock);
- return G_SOURCE_CONTINUE;
+ return G_SOURCE_REMOVE;
}
bxt_dbg("recv %d: cond %x", fd, cond);
return -1;
}
+ pthread_mutex_lock(&clients_lock);
cli = calloc(1, sizeof(*cli));
if (!cli)
return -1;
pthread_mutex_unlock(&cli->lock);
free_client(cli);
errno = ENOMEM;
+ pthread_mutex_unlock(&clients_lock);
return -1;
}
cli->noti_cbs = g_hash_table_new_full(g_str_hash, g_str_equal,
pthread_mutex_unlock(&cli->lock);
free_client(cli);
errno = ENOMEM;
+ pthread_mutex_unlock(&clients_lock);
return -1;
}
pthread_mutex_unlock(&cli->lock);
cli->fd = connect_server(SOCKPATH);
if (cli->fd == -1) {
free_client(cli);
+ pthread_mutex_unlock(&clients_lock);
return -1;
}
else
cli->fd_id = 0;
- pthread_mutex_lock(&clients_lock);
clients = g_list_append(clients, cli);
- pthread_mutex_unlock(&clients_lock);
*client = cli;
+ pthread_mutex_unlock(&clients_lock);
if (callback)
callback(BUXTON_STATUS_CONNECTED, user_data);