Exemple #1
0
void backtrace_log(int retval, const char *fn,
		   const char *file, int lineno)
{
	struct backtrace_data *btd;
	struct error_frame *ef;
	int state;

	btd = pthread_getspecific(btkey);
	if (btd == NULL)
		btd = &main_btd;

	pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &state);

	ef = malloc(sizeof(*ef));
	if (ef == NULL)
		goto out;

	ef->retval = retval;
	ef->lineno = lineno;
	ef->fn = fn;
	ef->file = file;

	write_lock(&btd->lock);

	if (btd->inner == NULL)
		/* Fire the hook for the inner trace. */
		error_hook(ef);

	ef->next = btd->inner;
	btd->inner = ef;

	write_unlock(&btd->lock);
out:
	pthread_setcanceltype(state, NULL);
}
Exemple #2
0
void backtrace_log(int retval, const char *fn,
		   const char *file, int lineno)
{
	struct backtrace_data *btd;
	struct error_frame *ef;

	btd = pthread_getspecific(btkey);
	if (btd == NULL)
		btd = &main_btd;

	ef = xnmalloc(sizeof(*ef));
	if (ef == NULL)
		return;

	ef->retval = retval;
	ef->lineno = lineno;
	ef->fn = fn;
	ef->file = file;

	write_lock(&btd->lock);

	if (btd->inner == NULL)
		/* Fire the hook for the inner trace. */
		error_hook(ef);

	ef->next = btd->inner;
	btd->inner = ef;

	write_unlock(&btd->lock);
}