Esempio n. 1
0
static void
send_build_stats(struct build_peer *peer)
{
	struct build_stat st;
	uint32_t tmp;

	build_stats(&st);

	peer->buf = xmalloc(7 * 4);

	tmp = htonl(st.open_jobs);
	(void)memcpy(peer->buf, &tmp, 4);

	tmp = htonl(st.in_processing);
	(void)memcpy(peer->buf + 4, &tmp, 4);

	tmp = htonl(st.failed);
	(void)memcpy(peer->buf + 8, &tmp, 4);

	tmp = htonl(st.prefailed);
	(void)memcpy(peer->buf + 12, &tmp, 4);

	tmp = htonl(st.indirect_failed);
	(void)memcpy(peer->buf + 16, &tmp, 4);

	tmp = htonl(st.indirect_prefailed);
	(void)memcpy(peer->buf + 20, &tmp, 4);

	tmp = htonl(st.done);
	(void)memcpy(peer->buf + 24, &tmp, 4);

	deferred_write(peer->fd, peer->buf, 7 * 4, peer, sent_build_stats, kill_peer);
}
Esempio n. 2
0
t_item		*new_link(char const *name, t_item *parent, t_args *args)
{
	t_item	*link;

	link = NULL;
	if ((link = (t_item *)malloc(sizeof(t_item))))
	{
		set_new_link(link);
		link->name = ft_strdup(name);
		link->parent = (t_item *)parent;
		if (link->parent)
			link->path = get_path(link);
		else
			link->path = link->name;
		if (build_stats(link, args) != 0)
			return (NULL);
		if (parent == NULL && ((args->options->l == 1 &&
				is_symbolic_link(link) == 0) || (args->options->l == 0)))
			create_children(link, args);
	}
	else
		not_enough_memory(args);
	return (link);
}