Пример #1
0
/*
 * clean up and exit, if the flag 'exit_ok' is not 1, upon call,
 * this indicates an error occured or kill signal was caught
 */
void
hgd_exit_nicely()
{
	if (!exit_ok)
		DPRINTF(HGD_D_ERROR, "hgd-netd was interrupted or crashed");

	if (svr_fd >= 0) {
		if (shutdown(svr_fd, SHUT_RDWR) == -1)
			DPRINTF(HGD_D_WARN,
			    "Can't shutdown socket: %s", SERROR);
		close(svr_fd);
	}
	if (db_path)
		free(db_path);
	if (filestore_path)
		free(filestore_path);
	if (state_path)
		free(state_path);
	if (db)
		sqlite3_close(db);

	hgd_cleanup_ssl(&ctx);

	if (restarting)
		hgd_restart_myself();

	/* after restart, so that we can report a SIGHUP */
	HGD_CLOSE_SYSLOG();

	_exit (!exit_ok);
}
Пример #2
0
/*
 * clean up, exit. if exit_ok = 0, an error (signal/error)
 */
void
hgd_exit_nicely()
{
	if (!exit_ok)
		DPRINTF(HGD_D_ERROR, "hgd-playd was interrupted or crashed\n");

	if (mplayer_fifo_path)
		free(mplayer_fifo_path);
	if (db)
		sqlite3_close(db);
	if (state_path)
		free(state_path);
	if (db_path)
		free (db_path);
	if (filestore_path)
		free(filestore_path);

#ifdef HAVE_PYTHON
	hgd_free_py();
#endif

	/* before syslog goes down */
	if (restarting)
		hgd_restart_myself();

	HGD_CLOSE_SYSLOG();

	exit (!exit_ok);
}