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
handledescribes the handle on which the buffer will be allocated. π«Ά - The argument
sizerequests a buffer ofsizebe allocated. π - The
bufferargument 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:
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, served in the exact order they came in, no edits:
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
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
- debian bookworm: libcpg-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libcpg-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: libcpg-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libcpg-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libcpg-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libcpg-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libcpg-dev 3.1.9-2ubuntu1
- ubuntu questing: libcpg-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libcpg-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libcpg-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