Exemplo n.º 1
0
void dump_state()
{
	disable_progress_bar();

	printf("Queue and cache status dump\n");
	printf("===========================\n");

	printf("file buffer read queue (main thread -> reader thread)\n");
	dump_queue(to_reader);

	printf("file buffer decompress queue (reader thread -> inflate"
							" thread(s))\n");
	dump_queue(to_inflate);

	printf("file buffer write queue (main thread -> writer thread)\n");
	dump_queue(to_writer);

	printf("\nbuffer cache (uncompressed blocks and compressed blocks "
							"'in flight')\n");
	dump_cache(data_cache);

	printf("fragment buffer cache (uncompressed frags and compressed"
						" frags 'in flight')\n");
	dump_cache(fragment_cache);

	enable_progress_bar();
}
Exemplo n.º 2
0
void *restore_thrd(void *arg)
{
	sigset_t sigmask, old_mask;
	int sig;

	sigemptyset(&sigmask);
	sigaddset(&sigmask, SIGINT);
	sigaddset(&sigmask, SIGTERM);
	sigaddset(&sigmask, SIGUSR1);
	pthread_sigmask(SIG_BLOCK, &sigmask, &old_mask);

	while(1) {
		sigwait(&sigmask, &sig);

		if(sig == SIGINT || sig == SIGTERM) {
			interrupted ++;

			if(interrupted == 1) {
				ERROR("Interrupting will restore original "
					"filesystem!\n");
                		ERROR("Interrupt again to quit\n");
			}
		}

		if(interrupted == 2 || sig == SIGUSR1) {
			disable_progress_bar();
			disable_info();
			pthread_cancel(main_thread);
			pthread_join(main_thread, NULL);

			restorefs();
		}
	}
}