CMAP_TRACK_ADD(3)
π CMAP_TRACK_ADD β bestie edition π
okay so this is cmap_track_add from the Corosync Cluster Engine Programmer's Manual, section 3 (that's the library-functions girlies, iykyk). no cap, this one's lowkey important. let's get into it π¦
β¨ NAME β¨
cmap_track_add β the function that sets a tracking function for values in CMAP. yes queen, you're literally spying on your own config keys (affectionately). π
πΈ SYNOPSIS πΈ
#include <corosync/cmap.h>
cs_error_t cmap_track_add (cmap_handle_t handle, const char *key_name,
int32_t track_type, cmap_notify_fn_t notify_fn, void *user_data,
cmap_track_handle_t *cmap_track_handle);
π DESCRIPTION π
so cmap_track_add sets up a function that tracks changes in CMAP. and bestie, she's generous β one single CMAP connection can track multiple keys, and you can even track the same key multiple times. iconic behaviour honestly. π
handleβ your connection to the CMAP database, obtained by callingcmap_initialize(3). this is your portal, your main character entrance. β¨key_nameβ either the exact key name or a prefix of a key name you want to track changes on.track_typeβ a bitfield, which may consist of the following values:
π the track_type bitfield π
CMAP_TRACK_ADDβ tracks the addition of a new key (or a key added in a callback). new key just dropped πCMAP_TRACK_DELETEβ tracks the deletion of a key (or a key deleted in a callback). rip bestie πCMAP_TRACK_MODIFYβ tracks the modification of a key (or a key modified in a callback). glow-up detected πCMAP_TRACK_PREFIXβ the whole prefix is tracked instead of just the key alone, so tracking"totem."means it applies to"totem.nodeid","totem.version", and so on. (heads up: this value is never returned in the callback β it's a setup-only vibe π«Ά)
π the other args π
notify_fnβ pointer to the function that gets called when a value changes. her definition and the meaning of her parameters are discussed below, keep reading bestie.user_dataβ passed directly tonotify_fnwith zero changes. no notes, no edits, straight through. β¨cmap_track_handleβ used for removing the tracking when you no longer need it, by callingcmap_track_delete(3). it's giving "we're done here" energy.
π§ the callback function π§
the callback function is defined as:
typedef void (*cmap_notify_fn_t) (
cmap_handle_t cmap_handle,
cmap_track_handle_t cmap_track_handle,
int32_t event,
const char *key_name,
struct cmap_notify_value new_value,
struct cmap_notify_value old_value,
void *user_data);
breaking it down, one param at a time, because she deserves it:
cmap_handleβ the handle used when registering the track function.cmap_track_handleβ the handle returned by thecmap_track_addfunction.eventβ one ofCMAP_TRACK_ADD,CMAP_TRACK_DELETEorCMAP_TRACK_MODIFY.key_nameβ the name of the changed key.new_valueβ the new value of the key, or unset if the event isCMAP_TRACK_DELETE.old_valueβ the previous value of the key, or unset if the event isCMAP_TRACK_ADD, or for some special keys set directly by Corosync due to speed optimizations. (yes, speed. she's fast. πββοΈ)user_dataβ your little gift, delivered untouched.
both new_value and old_value are structures defined as:
struct cmap_notify_value {
cmap_value_types_t type;
size_t len;
const void *data;
};
so: if the value is unset, all fields are set to 0. otherwise type is one of the cmap types (as described in the cmap_get(3) function), len is the length of the value in cmap, and data is a pointer to the value of the item. π«Ά
β οΈ data storage is dynamically allocated by the caller, and the notify function must not try to free it. do not free her. she is not yours to free. π
β RETURN VALUE β
this call returns the CS_OK value if successful. slay. β¨
it can also return CS_ERR_INVALID_PARAM if notify_fn is NULL or if track_type is an invalid value. (so like, don't do that π
)
π¦ NOTES π¦
- modification tracking of individual keys is supported in the stats map, but not prefixes. so keys? yes. prefixes? no bestie. π
- add/delete operations are supported on prefixes though, so you can track for new ipc connections or knet interfaces. that's the loophole and it's valid. π₯
- in the icmap map, prefix tracking is fully supported. she's the overachiever of the family π
π SEE ALSO π
and the error codes, in all their glory:
CS_ERR_TRY_AGAINβ Resource temporarily unavailableCS_ERR_INVALID_PARAMβ Invalid argumentCS_ERR_ACCESSβ Permission deniedCS_ERR_LIBRARYβ The connection failedCS_ERR_INTERRUPTβ System call interrupted by a signalCS_ERR_NOT_SUPPORTEDβ The requested protocol/functionality not supportedCS_ERR_MESSAGE_ERRORβ Incorrect auth message receivedCS_ERR_NO_MEMORYβ Not enough memory to complete the requested task
okay that's the whole page, no skips, no crumbs left behind ππ this one's from the corosync Man Page, dated 06/02/2012 β vintage but still serving, fr fr. go track some keys, bestie, you've got this. periodt. πβ¨π
π¦ where this page comes from
- debian bookworm: libcmap-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libcmap-dev 3.1.9-2+deb13u1 Β· BSD-3-Clause
- epel 9: corosynclib-devel 3.1.10-0.2.el9.1 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- nixos 26.05: corosync 3.1.9
- nixpkgs unstable: corosync 3.1.9
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libcmap-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libcmap-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1
- ubuntu questing: libcmap-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libcmap-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libcmap-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2012 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms