CPG_DISPATCH(3)

πŸ’– CPG_DISPATCH(3) πŸ’–

okay bestie, gather round, because we're about to talk about cpg_dispatch from the Corosync Cluster Engine Programmer's Manual. yes THE Corosync. the cluster engine. she's iconic, she's from 2004, and she's still serving.


✨ NAME ✨

cpg_dispatch β€” dispatches callbacks from the CPG service 🫢


✨ SYNOPSIS ✨

#include <corosync/cpg.h>

int cpg_dispatch(cpg_handle_t handle, cpg_dispatch_t *dispatch_types);

✨ DESCRIPTION ✨

so like, the cpg_dispatch function is literally the girl who goes and fetches your configuration changes or your messages from the closed process groups API. she's the messenger. the main character. the one who shows up with the tea. πŸ’…

okay so one thing β€” each application can have several connections to the CPG API at the same time. no, she's not confused, she's just popular. each application uses the handle argument to uniquely identify which connection is which. it's giving "which group chat am I in rn". πŸ’€

then there's the dispatch_types argument, which tells her what kind of dispatch to run. the possible types are defined by this structure right here:

typedef enum {
        CS_DISPATCH_ONE,
        CS_DISPATCH_ALL,
        CS_DISPATCH_BLOCKING
} cpg_dispatch_t;

and the dispatch values mean the following, bestie, listen up:

  • CS_DISPATCH_ONE β€” dispatches atleast one callback, and she'll block until that callback is dispatched. one (or more!) callback, and she waits. periodt. πŸŽ€
  • CS_DISPATCH_ALL β€” dispatches all the waiting callbacks, and she does not block waiting for any callbacks. she's busy, she's efficient, she's got places to be. ✨
  • CS_DISPATCH_BLOCKING β€” dispatches all callbacks, blocking indefinitely. the way this one works: it's used in a threaded program where you create a thread, and then cpg_dispatch() is called immediately from the created thread to execute callbacks. she will wait forever and she is at peace with that. πŸ§˜β™€οΈ
  • CS_DISPATCH_ONE_NONBLOCKING β€” dispatches at most one callback. and if there's no pending callback? you get CS_ERR_TRY_AGAIN back. not me getting a "try again later" text 😭

✨ RETURN VALUE ✨

if everything goes slay, this call returns the CS_OK value. otherwise, an error gets returned. that's it, that's the whole vibe check. πŸ¦‹


✨ ERRORS ✨

the errors are undocumented. πŸ’€

like… genuinely. that's all the manual says. the lore is lost. we simply do not know. no cap.


✨ SEE ALSO ✨

here's the whole bestie list, every single one, no gatekeeping:

cpg_overview(3), cpg_initialize(3), cpg_finalize(3), cpg_fd_get(3),
cpg_dispatch(3), cpg_join(3), cpg_leave(3), cpg_mcast_joined(3),
cpg_membership_get(3) cpg_zcb_alloc(3) cpg_zcb_free(3)
cpg_zcb_mcast_joined(3) cpg_context_get(3) cpg_context_set(3)
cpg_local_get(3)

and the error codes, in their full glory 🌈:

  • CS_ERR_TRY_AGAIN β€” Resource temporarily unavailable
  • CS_ERR_INVALID_PARAM β€” Invalid argument
  • CS_ERR_ACCESS β€” Permission denied
  • CS_ERR_LIBRARY β€” The connection failed
  • CS_ERR_INTERRUPT β€” System call interrupted by a signal
  • CS_ERR_NOT_SUPPORTED β€” The requested protocol/functionality not supported
  • CS_ERR_MESSAGE_ERROR β€” Incorrect auth message received
  • CS_ERR_NO_MEMORY β€” Not enough memory to complete the requested task

okay that's the whole page, you ate that, go forth and dispatch your callbacks responsibly πŸ’œ

this was brought to you by the corosync Man Page, dated 2004-08-31 β€” a vintage queen. CPG_DISPATCH(3) out. πŸŽ€βœ¨

πŸ“¦ where this page comes from