SAM_H...ISTER(3)
π SAM_HC_CALLBACK_REGISTER β the Corosync Cluster Engine Programmer's Manual's own little icon π
okay bestie so we're doing a page from the Corosync Cluster Engine Programmer's Manual and it's sam_hc_callback_register(3) β section 3, library call, very demure, very mindful, very health-check. let's get into it π«Ά
β¨ NAME β¨
sam_hc_callback_register β register a health check callback π©Ίπ
β¨ SYNOPSIS β¨
#include <corosync/sam.h>
cs_error_t sam_hc_callback_register (sam_hc_callback_t cb);
like, that's the whole vibe. one function, one argument, so clean β¨
β¨ DESCRIPTION β¨
so sam_hc_callback_register is literally just here to let you hand over a healthcheck callback that you wrote yourself. you register it, and boom β after you call this function, SAM switches from application driven healthchecking over to event driven healthchecking. new era unlocked π«
and here's the slay part: once you're in that mode, you do not need to run sam_hc_send(3) anymore. not once. it's giving self-sufficient. π
the parameter cb is a callback function of type sam_hc_callback_t, and it's defined like this:
typedef int (*sam_hc_callback_t)(void);
this function gets called regularly (she's consistent, we love that π) and it has to return 0 if the process is functioning normally, or -1 if the process is executing abnormally. and when -1 comes back? the SAM server executes the registered recovery policy. so like, don't return -1 unless you mean it fr fr π
you can also pass a value of NULL into this function to switch back into application driven healthchecking. cb to NULL. just like that. π¦
β¨ RETURN VALUE β¨
this call returns the CS_OK value if it's successful β otherwise an error is returned. (the original says "and error is returned", which is honestly so real of it, we're keeping it as-is π)
β¨ ERRORS β¨
CS_ERR_BAD_HANDLEβ SAM was not initialized and registered, or health checking is in running state. so like... she's not ready, or she's already mid-glow-up. either way, no πCS_ERR_LIBRARYβ an internal library call failed. this can happen duringfork()orpipe()system calls, and you can read theerrnovariable to retrieve more information. bestie go check yourerrno, she's holding the tea π«
β¨ SEE ALSO β¨
and then there's this whole other list of error codes hanging out down here, which is iconic of the original and we're keeping every single one π
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
lowkey important: if you're getting CS_ERR_BAD_HANDLE, check that SAM is actually initialized and registered and that health checking isn't already in a running state. that's the whole checklist, no cap π§
and that's the page!! π this one's from the corosync Man Page, dated 12/01/2009 β yes she's an elder icon and she still ate. go register your callback, bestie, you got this ππΈ
π¦ where this page comes from
- debian bookworm: libsam-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libsam-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: libsam-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libsam-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libsam-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libsam-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2009 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms