diff options
| author | Michael Paquier | 2024-05-12 09:53:06 +0000 |
|---|---|---|
| committer | Michael Paquier | 2024-05-12 09:53:06 +0000 |
| commit | 33181b48fd0ee62bc0a9e39291d5a5c4f8540354 (patch) | |
| tree | 2ec2237750bb1efd1051641a4560b93d55d952ba /src/include | |
| parent | 407e0b023cdb449dde65fd370c6cc48f5b8a5579 (diff) | |
Introduce private data area for injection points
This commit extends the backend-side infrastructure of injection points
so as it becomes possible to register some input data when attaching a
point. This private data can be registered with the function name and
the library name of the callback when attaching a point, then it is
given as input argument to the callback. This gives the possibility for
modules to pass down custom data at runtime when attaching a point
without managing that internally, in a manner consistent with the
callback entry retrieved from the hash shmem table storing the injection
point data.
InjectionPointAttach() gains two arguments, to be able to define the
private data contents and its size.
A follow-up commit will rely on this infrastructure to close a race
condition with the injection point detach in the module
injection_points.
While on it, this changes InjectionPointDetach() to return a boolean,
returning false if a point cannot be detached. This has been mentioned
by Noah as useful when it comes to implement more complex tests with
concurrent point detach, solid with the automatic detach done for local
points in the test module.
Documentation is adjusted in consequence.
Per discussion with Noah Misch.
Reviewed-by: Noah Misch
Discussion: https://postgr.es/m/20240509031553.47@rfd.leadboat.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/utils/injection_point.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/include/utils/injection_point.h b/src/include/utils/injection_point.h index 55524b568ff..a61d5d44391 100644 --- a/src/include/utils/injection_point.h +++ b/src/include/utils/injection_point.h @@ -23,15 +23,18 @@ /* * Typedef for callback function launched by an injection point. */ -typedef void (*InjectionPointCallback) (const char *name); +typedef void (*InjectionPointCallback) (const char *name, + const void *private_data); extern Size InjectionPointShmemSize(void); extern void InjectionPointShmemInit(void); extern void InjectionPointAttach(const char *name, const char *library, - const char *function); + const char *function, + const void *private_data, + int private_data_size); extern void InjectionPointRun(const char *name); -extern void InjectionPointDetach(const char *name); +extern bool InjectionPointDetach(const char *name); #endif /* INJECTION_POINT_H */ |
