34 #define INJ_MAX_WAIT 8
35 #define INJ_NAME_MAXLEN 64
36 #define INJ_MAX_CONDITION 4
92 memset(
state->wait_counts, 0,
sizeof(
state->wait_counts));
94 memset(
state->conditions, 0,
sizeof(
state->conditions));
136 if (strcmp(condition->
name,
name) == 0)
171 if (condition->
name[0] ==
'\0')
179 condition->
name[0] =
'\0';
208 uint32 old_wait_counts = 0;
210 uint32 injection_wait_event = 0;
242 elog(
ERROR,
"could not find free slot for wait of injection point %s ",
255 if (old_wait_counts != new_wait_counts)
278 if (strcmp(
action,
"error") == 0)
279 function =
"injection_error";
280 else if (strcmp(
action,
"notice") == 0)
281 function =
"injection_notice";
282 else if (strcmp(
action,
"wait") == 0)
283 function =
"injection_wait";
285 elog(
ERROR,
"incorrect action \"%s\" for injection point creation",
action);
302 if (condition->
name[0] ==
'\0')
314 "could not find free slot for condition of injection point %s",
361 elog(
ERROR,
"could not find injection point %s to wake up",
name);
417 if (strcmp(condition->
name,
name) == 0)
420 condition->
name[0] =
'\0';
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void * GetNamedDSMSegment(const char *name, size_t size, void(*init_callback)(void *ptr), bool *found)
#define PG_GETARG_TEXT_PP(n)
void InjectionPointDetach(const char *name)
void InjectionPointAttach(const char *name, const char *library, const char *function)
#define INJECTION_POINT(name)
Datum injection_points_detach(PG_FUNCTION_ARGS)
static bool injection_point_local
PGDLLEXPORT void injection_error(const char *name)
PGDLLEXPORT void injection_notice(const char *name)
PG_FUNCTION_INFO_V1(injection_points_attach)
static void injection_init_shmem(void)
Datum injection_points_attach(PG_FUNCTION_ARGS)
struct InjectionPointCondition InjectionPointCondition
Datum injection_points_run(PG_FUNCTION_ARGS)
Datum injection_points_set_local(PG_FUNCTION_ARGS)
static bool injection_point_allowed(const char *name)
static void injection_points_cleanup(int code, Datum arg)
#define INJ_MAX_CONDITION
struct InjectionPointSharedState InjectionPointSharedState
Datum injection_points_wakeup(PG_FUNCTION_ARGS)
PGDLLEXPORT void injection_wait(const char *name)
static void injection_point_init_state(void *ptr)
static InjectionPointSharedState * inj_state
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
char name[INJ_NAME_MAXLEN]
uint32 wait_counts[INJ_MAX_WAIT]
InjectionPointCondition conditions[INJ_MAX_CONDITION]
char name[INJ_MAX_WAIT][INJ_NAME_MAXLEN]
ConditionVariable wait_point
char * text_to_cstring(const text *t)
uint32 WaitEventExtensionNew(const char *wait_event_name)