CPG_ZCB_ALLOC(3)

✨ CPG_ZCB_ALLOC(3) ✨

okay bestie, sit down, we're learning about cpg_zcb_alloc β€” the zero copy buffer allocator from the Corosync Cluster Engine Programmer's Manual. πŸŽ€ This one is lowkey iconic because it does zero copying, and the way it does that is by asking the operating system to hand over memory in a way the IPC layer can just... point at. No copying. Obsessed. πŸ’…


🌸 NAME 🌸

cpg_zcb_alloc β€” Allocates a zero copy buffer ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <corosync/cpg.h>

int cpg_zcb_alloc(cpg_handle_t handle, size_t size, void **buffer);

πŸ’– DESCRIPTION πŸ’–

So here's the tea. The cpg_zcb_alloc function allocates a zero copy buffer for use with the cpg_zcb_mcast_joined(3) function. That's its whole job and it does it gorgeously. ✨

⚠️ bestie please read this one β€” this buffer should not be used in another thread while a cpg_zcb_mcast_joined operation is taking place on the buffer. Like, one thread at a time, okay? Sharing is caring but not here. 😭

The buffer is allocated via operating system mechanisms to avoid copying in the IPC layer. no copy, no drama, no cap. 🧚

Now the arguments, one by one, because we don't skip:

  • The argument handle describes the handle on which the buffer will be allocated. 🫢
  • The argument size requests a buffer of size be allocated. πŸ“
  • The buffer argument is set to the buffer address that is allocated by this operation. πŸ‘‘

⭐ RETURN VALUE ⭐

This call returns the CS_OK value if successful, otherwise an error is returned. simple, clean, no notes. πŸ’š


πŸ’€ ERRORS πŸ’€

The errors are undocumented.

(yes really. that's the whole section. we move.) πŸ™ˆ


🌈 SEE ALSO 🌈

Go read the whole friend group, they're all linked up:

And the error codes, served in the exact order they came in, no edits:

  • 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

and that's the whole page, bestie, you ate that. πŸ’…βœ¨

this lil masterpiece came out of the corosync Man Page on 2009-04-15 β€” yes she's vintage, yes she still slays, we stan an ageless queen. πŸ‘‘πŸ’–

πŸ“¦ where this page comes from