stasis-aries-wal/src/stasis/compensations.c

38 lines
740 B
C
Raw Normal View History

#include <stasis/compensations.h>
int ___compensation_count___ = 0;
#include <assert.h>
#include <stdio.h>
static pthread_key_t error_key;
void compensations_init () {
int ret = pthread_key_create(&error_key, NULL);
assert(!ret);
pthread_setspecific(error_key, NULL);
}
void compensations_deinit() {
int ret = pthread_key_delete(error_key);
assert(!ret);
}
2006-03-20 23:11:46 +00:00
long compensation_error() {
long error = (long) pthread_getspecific(error_key);
return error;
}
void compensation_clear_error() {
compensation_set_error(0);
}
2006-03-20 23:11:46 +00:00
void compensation_set_error(long error) {
int ret = pthread_setspecific(error_key, (void *)error);
if(ret) {
printf("Unhandled error: %s\n", strerror(ret));
abort();
}
assert(!ret);
}