#include "common.h"
#include "pmsg.h"
#include "lib/zalloc.h"
#include "lib/walloc.h"
#include "lib/override.h"
Data Structures | |
| struct | pmsg_ext |
| An extended message block. More... | |
Defines | |
| #define | implies(a, b) (!(a) || (b)) |
| #define | valid_ptr(a) (((gulong) (a)) > 100L) |
| #define | EMBEDDED_OFFSET G_STRUCT_OFFSET(pdata_t, d_embedded) |
Typedefs | |
| typedef pmsg_ext | pmsg_ext_t |
| An extended message block. | |
Functions | |
| void | pmsg_ext_check_consistency (const pmsg_ext_t *const emb) |
| ALWAYS_INLINE pmsg_ext_t * | cast_to_pmsg_ext (pmsg_t *mb) |
| ALWAYS_INLINE pmsg_t * | cast_to_pmsg (pmsg_ext_t *emb) |
| void | pmsg_init (void) |
| Allocate internal variables. | |
| void | pmsg_close (void) |
| Free internal variables. | |
| int | pmsg_size (const pmsg_t *mb) |
| Compute message's size. | |
| pmsg_t * | pmsg_fill (pmsg_t *mb, pdata_t *db, gint prio, gconstpointer buf, gint len) |
| Fill newly created message block. | |
| pmsg_t * | pmsg_new (gint prio, gconstpointer buf, gint len) |
| Create new message from user provided data, which are copied into the allocated data block. | |
| pmsg_t * | pmsg_new_extend (gint prio, gconstpointer buf, gint len, pmsg_free_t free_cb, gpointer arg) |
| Like pmsg_new() but returns an extended form with a free routine callback. | |
| pmsg_t * | pmsg_alloc (gint prio, pdata_t *db, gint roff, gint woff) |
| Allocate new message using existing data block `db'. | |
| pmsg_t * | pmsg_clone_extend (pmsg_t *mb, pmsg_free_t free_cb, gpointer arg) |
| Extended cloning of message, adds a free routine callback. | |
| pmsg_free_t | pmsg_replace_ext (pmsg_t *mb, pmsg_free_t nfree, gpointer narg, gpointer *oarg) |
| Replace free routine from an extended message block. | |
| gpointer | pmsg_get_metadata (pmsg_t *mb) |
| Get the "meta data" from an extended message block (the argument passed to the embedded free routine). | |
| pmsg_check_t | pmsg_set_check (pmsg_t *mb, pmsg_check_t check) |
| Set the pre-send checking routine for the buffer. | |
| pmsg_t * | pmsg_clone_ext (pmsg_ext_t *mb) |
| Shallow cloning of extended message, result is referencing the same data. | |
| pmsg_t * | pmsg_clone (pmsg_t *mb) |
| Shallow cloning of message, result is referencing the same data. | |
| void | pmsg_free (pmsg_t *mb) |
| Free all message blocks, and decrease ref count on all data buffers. | |
| gint | pmsg_writable_length (const pmsg_t *mb) |
| gint | pmsg_write (pmsg_t *mb, gconstpointer data, gint len) |
| Write data at the end of the message. | |
| gint | pmsg_read (pmsg_t *mb, gpointer data, gint len) |
| Read data from the message, returning the amount of bytes transferred. | |
| gint | pmsg_discard (pmsg_t *mb, gint len) |
| Discard data from the message, returning the amount of bytes discarded. | |
| gint | pmsg_discard_trailing (pmsg_t *mb, gint len) |
| Discard trailing data from the message, returning the amount of bytes discarded. | |
| pdata_t * | pdata_new (int len) |
| Allocate a new data block of given size. | |
| pdata_t * | pdata_allocb (void *buf, gint len, pdata_free_t freecb, gpointer freearg) |
| Create an embedded data buffer out of existing arena. | |
| pdata_t * | pdata_allocb_ext (void *buf, gint len, pdata_free_t freecb, gpointer freearg) |
| Create an external (arena not embedded) data buffer out of existing arena. | |
| void | pdata_free_nop (gpointer unused_p, gpointer unused_arg) |
| This free routine can be used when there is nothing to be freed for the buffer, probably because it was made out of a static buffer. | |
| void | pdata_free (pdata_t *db) |
| Free data block when its reference count has reached 0. | |
| void | pdata_unref (pdata_t *db) |
| Decrease reference count on buffer, and free it when it reaches 0. | |
| iovec * | pmsg_slist_to_iovec (slist_t *slist, gint *iovcnt_ptr, size_t *size_ptr) |
| Creates an iovec from a singly-linked list of pmsg_t buffers. | |
| void | pmsg_slist_discard (slist_t *slist, size_t n_bytes) |
| Discard `n_bytes' from the pmsg_t buffer slist and free all completely discarded buffers. | |
| void | pmsg_slist_append (slist_t *slist, const void *data, size_t n_bytes) |
| Appends `n_bytes' to the pmsg_t buffer. | |
| void | pmsg_slist_free (slist_t **ptr) |
| Frees all pmsg_t buffers, the slist itself and nullifies the pointer. | |
Variables | |
| zone_t * | mb_zone = NULL |
|
|
|
|
|
|
|
|
|
|
|
An extended message block. An extended message block can be identified by its `m_prio' field having the PMSG_PF_EXT flag set. |
|
|
|
|
|
|
|
||||||||||||||||||||
|
Create an embedded data buffer out of existing arena. The optional `freecb' structure supplies the free routine callback to be used to free the arena, with freearg as additional argument. |
|
||||||||||||||||||||
|
Create an external (arena not embedded) data buffer out of existing arena. The optional `freecb' structure supplies the free routine callback to be used to free the arena, with freearg as additional argument. |
|
|
Free data block when its reference count has reached 0.
|
|
||||||||||||
|
This free routine can be used when there is nothing to be freed for the buffer, probably because it was made out of a static buffer.
|
|
|
Allocate a new data block of given size. The block header is at the start of the allocated block. |
|
|
Decrease reference count on buffer, and free it when it reaches 0.
|
|
||||||||||||||||||||
|
Allocate new message using existing data block `db'. The `roff' and `woff' are used to delimit the start and the end (first unwritten byte) of the message within the data buffer.
|
|
|
Shallow cloning of message, result is referencing the same data.
|
|
|
Shallow cloning of extended message, result is referencing the same data.
|
|
||||||||||||||||
|
Extended cloning of message, adds a free routine callback.
|
|
|
Free internal variables.
|
|
||||||||||||
|
Discard data from the message, returning the amount of bytes discarded.
|
|
||||||||||||
|
Discard trailing data from the message, returning the amount of bytes discarded.
|
|
|
|
|
||||||||||||||||||||||||
|
Fill newly created message block.
|
|
|
Free all message blocks, and decrease ref count on all data buffers.
|
|
|
Get the "meta data" from an extended message block (the argument passed to the embedded free routine).
|
|
|
Allocate internal variables.
|
|
||||||||||||||||
|
Create new message from user provided data, which are copied into the allocated data block. If no user buffer is provided, an empty message is created and the length is used to size the data block.
|
|
||||||||||||||||||||||||
|
Like pmsg_new() but returns an extended form with a free routine callback.
|
|
||||||||||||||||
|
Read data from the message, returning the amount of bytes transferred.
|
|
||||||||||||||||||||
|
Replace free routine from an extended message block. The original free routine and its argument are returned. This is used when wrapping an existing extended message and its metadata in another extension structure.
|
|
||||||||||||
|
Set the pre-send checking routine for the buffer. This routine, if it exists (non-NULL) is called just before enqueueing the message for sending. If it returns FALSE, the message is immediately dropped. The callback routine must not modify the message, as the buffer can be shared among multiple messages, unless its refcount is 1.
|
|
|
Compute message's size.
|
|
||||||||||||||||
|
Appends `n_bytes' to the pmsg_t buffer. If the last pmsg_t is writable it is filled with as much data as space is still available. Otherwise or if this space is not sufficient another pmsg_t is created and append to the list. |
|
||||||||||||
|
Discard `n_bytes' from the pmsg_t buffer slist and free all completely discarded buffers.
|
|
|
Frees all pmsg_t buffers, the slist itself and nullifies the pointer.
|
|
||||||||||||||||
|
Creates an iovec from a singly-linked list of pmsg_t buffers. NOTE: The iovec will hold no more than MAX_IOV_COUNT items. That means the iovec might not cover the whole buffered data. This limited is applied because writev() could fail with EINVAL otherwise which would simply add more unnecessary complexity. |
|
|
|
|
||||||||||||||||
|
Write data at the end of the message. The message must be the only reference to the underlying data.
|
|
|
|
1.3.9.1