Beispiel #1
0
static void
toggle_row (GtkTreeModel *model, GtkTreeIter *iter)
{
	GValue value = { 0, };
	GtkTreeIter parent, cur;
	gboolean enabled = get_row_state (model, iter);

	g_value_init (&value, G_TYPE_BOOLEAN);
	g_value_set_boolean (&value, !enabled);
	gtk_tree_store_set_value (GTK_TREE_STORE (model),
				  iter, FILTER_COLUMN_ENABLED, &value);

	/* re-write parents all the way up */
	cur = *iter;
	while (gtk_tree_model_iter_parent (model, &parent, &cur)) {
		gboolean inconsistent = !check_children (model, &parent, !enabled);
		g_value_set_boolean (&value, inconsistent);
		gtk_tree_store_set_value (GTK_TREE_STORE (model),
					  &parent, FILTER_COLUMN_INCONSISTENT, &value);
		if (!inconsistent) {
			g_value_set_boolean (&value, !enabled);
			gtk_tree_store_set_value (GTK_TREE_STORE (model),
						  &parent, FILTER_COLUMN_ENABLED, &value);
		}

		cur = parent;
	}
}
Beispiel #2
0
int main(void)
{
	CCAN_LIST_HEAD(h);

	children(&h);
	first_child(&h);
	last_child(&h);
	check_children(&h);
	print_children(&h);
	return 0;
}
Beispiel #3
0
static gboolean
check_children (GtkTreeModel *model, GtkTreeIter *iter,
		gboolean      enabled)
{
	GtkTreeIter child;

	if (gtk_tree_model_iter_children (model, &child, iter)) {
		do {
			if (!check_children (model, &child, enabled))
				return FALSE;
		} while (gtk_tree_model_iter_next (model, &child));

	} else if (get_row_state (model, iter) != enabled)
		return FALSE;

	return TRUE;
}
Beispiel #4
0
static void watchdog(void)
{
	static const char watchdogname[17]="trinity-watchdog";
	static unsigned long lastcount = 0;
	bool watchdog_exit = FALSE;
	int ret = 0;

	while (shm->ready == FALSE) {
		sleep(1);
		if (shm->exit_reason != STILL_RUNNING)
			return;
	}

	output(0, "Watchdog is alive. (pid:%d)\n", watchdog_pid);

	prctl(PR_SET_NAME, (unsigned long) &watchdogname);
	(void)signal(SIGSEGV, SIG_DFL);

	while (watchdog_exit == FALSE) {

		if (check_shm_sanity() == SHM_CORRUPT)
			goto corrupt;

		if (check_main_alive() == FALSE)
			goto main_dead;

		if (shm->regenerating == FALSE) {
			unsigned int i;

			reap_dead_kids();

			check_children();

			if (syscalls_todo && (shm->total_syscalls_done >= syscalls_todo)) {
				output(0, "Reached limit %d. Telling children to exit.\n", syscalls_todo);
				shm->exit_reason = EXIT_REACHED_COUNT;
			}

			// Periodic log syncing. FIXME: This is kinda ugly, and mostly unnecessary.
			if (shm->total_syscalls_done % 1000 == 0)
				synclogs();

			for_each_pidslot(i) {
				if (shm->child_syscall_count[i] > hiscore)
					hiscore = shm->child_syscall_count[i];
			}

			if (shm->total_syscalls_done > 1) {
				if (shm->total_syscalls_done - lastcount > 10000) {
					output(0, "%ld iterations. [F:%ld S:%ld HI:%ld]\n",
						shm->total_syscalls_done,
						shm->failures, shm->successes,
						hiscore);
					lastcount = shm->total_syscalls_done;
				}
			}

		}

		/* Only check taint if it mask allows it */
		if (kernel_taint_mask != 0) {
			ret = check_tainted();
			if (((ret & kernel_taint_mask) & (~kernel_taint_initial)) != 0) {
				gettimeofday(&shm->taint_tv, NULL);

				output(0, "kernel became tainted! (%d/%d) Last seed was %u\n", ret, kernel_taint_initial, shm->seed);
				shm->exit_reason = EXIT_KERNEL_TAINTED;
			}
		}

main_dead:
		/* Are we done ? */
		if (shm->exit_reason != STILL_RUNNING) {
			/* Give children a chance to exit. */
			sleep(1);

			/* Are there still children running ? */
			if (pidmap_empty() == TRUE)
				watchdog_exit = TRUE;
			else {
				output(0, "exit_reason=%d, but %d children still running.\n",
					shm->exit_reason, shm->running_childs);
				kill_all_kids();
			}
		}

		sleep(1);
	}