---
name: "cpg_dispatch"
section: "3"
platform: "linux"
package: "libcpg-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cpg_dispatch"
---

# cpg\_dispatch(3)

Dispatches callbacks from the CPG service

## 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

The **cpg\_dispatch** function is used to dispatch configuration changes or messages from the closed process groups API.

Each application may have several connections to the CPG API.  Each application uses the *handle* argument to uniquely identify the connection.

The *dispatch\_types* argument is used to identify the type of dispatch to execute.  The possible types are defined by the structure:

-

  ```
  typedef enum {
          CS_DISPATCH_ONE,
          CS_DISPATCH_ALL,
          CS_DISPATCH_BLOCKING
  } cpg_dispatch_t;
  ```

-

  The dispatch values have the following meanings:

- **CS\_DISPATCH\_ONE**

  Dispatch atleast one callback, blocking until the callback is dispatched.

- **CS\_DISPATCH\_ALL**

  Dispatch all waiting callbacks without blocking to wait for any callbacks.

- **CS\_DISPATCH\_BLOCKING**

  Dispatch all callbacks, blocking indefinitely.  This is used in a threaded program where a thread is created, and then cpg\_dispatch() is called immediately from the created thread to execute callbacks.

- **CS\_DISPATCH\_ONE\_NONBLOCKING**

  Dispatch at most one callback. If there is no pending callback, CS\_ERR\_TRY\_AGAIN is returned.

## RETURN VALUE

This call returns the CS\_OK value if successful, otherwise an error is returned.

## ERRORS

The errors are undocumented.

## SEE ALSO

[**cpg\_overview**(3)](/cpg_overview/3.md), [**cpg\_initialize**(3)](/cpg_initialize/3.md), [**cpg\_finalize**(3)](/cpg_finalize/3.md), [**cpg\_fd\_get**(3)](/cpg_fd_get/3.md), [**cpg\_dispatch**(3)](/cpg_dispatch/3.md), [**cpg\_join**(3)](/cpg_join/3.md), [**cpg\_leave**(3)](/cpg_leave/3.md), [**cpg\_mcast\_joined**(3)](/cpg_mcast_joined/3.md), [**cpg\_membership\_get**(3)](/cpg_membership_get/3.md) [**cpg\_zcb\_alloc**(3)](/cpg_zcb_alloc/3.md) [**cpg\_zcb\_free**(3)](/cpg_zcb_free/3.md) [**cpg\_zcb\_mcast\_joined**(3)](/cpg_zcb_mcast_joined/3.md) [**cpg\_context\_get**(3)](/cpg_context_get/3.md) [**cpg\_context\_set**(3)](/cpg_context_set/3.md) [**cpg\_local\_get**(3)](/cpg_local_get/3.md)

**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
