예제 #1
0
파일: health.c 프로젝트: aguedes/bluez
static void mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
{
	struct health_channel *channel = data;
	int fd;

	if (!channel->mdl)
		channel->mdl = mcap_mdl_ref(mdl);

	DBG("Data channel connected: mdl %p channel %p", mdl, channel);

	fd = mcap_mdl_get_fd(channel->mdl);
	if (fd < 0) {
		error("health: error retrieving fd");
		goto fail;
	}

	if (channel->mdep_id == MDEP_ECHO) {
		GIOChannel *io;

		io = g_io_channel_unix_new(fd);
		g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_IN,
							serve_echo, channel);
		g_io_channel_unref(io);

		return;
	}

	send_channel_state_notify(channel, HAL_HEALTH_CHANNEL_CONNECTED, fd);

	return;
fail:
	/* TODO: mcap_mdl_abort */
	destroy_channel(channel);
}
예제 #2
0
파일: mcaptest.c 프로젝트: ghent360/bluez
static void mdl_close(struct mcap_mdl *mdl)
{
	int fd = -1;

	printf("%s\n", __func__);

	if (mdl_disconnect_timeout >= 0)
		sleep(mdl_disconnect_timeout);

	fd = mcap_mdl_get_fd(mdl);

	if (fd > 0)
		close(fd);
}
예제 #3
0
파일: health.c 프로젝트: ghent360/bluez
static void free_health_channel(void *data)
{
	struct health_channel *channel = data;
	int fd;

	DBG("channel %p", channel);

	if (!channel)
		return;

	fd = mcap_mdl_get_fd(channel->mdl);
	if (fd >= 0)
		shutdown(fd, SHUT_RDWR);

	unref_mdl(channel);
	free(channel);
}