Loading...
Searching...
No Matches
Osmocom msgb write queues

Write queue for writing Message buffers to sockets/fds. More...

## Files

file | write_queue.h
| Generic write queue implementation.
file | write_queue.c

## Data Structures

struct | osmo_wqueue
| write queue instance More...

## Functions

void | osmo_wqueue_init (struct osmo_wqueue *queue, int max_length)
| Initialize a osmo_wqueue structure.
void | osmo_wqueue_clear (struct osmo_wqueue *queue)
| Clear a osmo_wqueue.
int | osmo_wqueue_enqueue (struct osmo_wqueue *queue, struct msgb *data)
| Enqueue a new Message buffers into a write queue.
int | osmo_wqueue_enqueue_quiet (struct osmo_wqueue *queue, struct msgb *data)
| Enqueue a new Message buffers into a write queue (without logging full queue events).
size_t | osmo_wqueue_set_maxlen (struct osmo_wqueue *queue, unsigned int len)
| Update write queue length & drop excess messages.
int | osmo_wqueue_bfd_cb (struct osmo_fd *fd, unsigned int what)
| Select loop function for write queue handling.

## Detailed Description

Write queue for writing Message buffers to sockets/fds.

## Function Documentation

## osmo_wqueue_bfd_cb()

int osmo_wqueue_bfd_cb | ( | struct osmo_fd * | fd,
|  | unsigned int | what )

Select loop function for write queue handling.

Parameters

  [in] | fd | osmocom file descriptor
  [in] | what | bit-mask of events that have happened

Returns
  0 on success; negative on error

This function is provided so that it can be registered with the select loop abstraction code (osmo_fd::cb).

References osmo_wqueue::bfd, container_of, osmo_wqueue::current_length, osmo_wqueue::except_cb, llist_add(), llist_empty(), osmo_wqueue::msg_queue, msgb_dequeue_count(), msgb_free(), OSMO_FD_EXCEPT, OSMO_FD_READ, OSMO_FD_WRITE, osmo_wqueue::read_cb, osmo_fd::when, and osmo_wqueue::write_cb.

Referenced by osmo_tundev_alloc(), and osmo_wqueue_init().

## osmo_wqueue_clear()

void osmo_wqueue_clear | ( | struct osmo_wqueue * | queue | ) |

Clear a osmo_wqueue.

Parameters

  [in] | queue | Write queue to be cleared

This function will clear (remove/release) all messages in it.

References osmo_wqueue::bfd, osmo_wqueue::current_length, llist_empty(), osmo_wqueue::msg_queue, msgb_dequeue(), msgb_free(), OSMO_FD_WRITE, and osmo_fd::when.

Referenced by osmo_tundev_close(), and tundev_ifupdown_ind_cb().

## osmo_wqueue_enqueue()

int osmo_wqueue_enqueue | ( | struct osmo_wqueue * | queue,
|  | struct msgb * | data )

Enqueue a new Message buffers into a write queue.

Parameters

  [in] | queue | Write queue to be used
  [in] | data | to-be-enqueued message buffer

Returns
  0 on success; negative on error (MESSAGE NOT FREED IN CASE OF ERROR).

References osmo_wqueue::current_length, DLGLOBAL, LOGL_ERROR, LOGP, osmo_wqueue::max_length, and osmo_wqueue_enqueue_quiet().

Referenced by osmo_tundev_send().

## osmo_wqueue_enqueue_quiet()

int osmo_wqueue_enqueue_quiet | ( | struct osmo_wqueue * | queue,
|  | struct msgb * | data )

Enqueue a new Message buffers into a write queue (without logging full queue events).

Parameters

  [in] | queue | Write queue to be used
  [in] | data | to-be-enqueued message buffer

Returns
  0 on success; negative on error (MESSAGE NOT FREED IN CASE OF ERROR).

References osmo_wqueue::bfd, osmo_wqueue::current_length, osmo_wqueue::max_length, osmo_wqueue::msg_queue, msgb_enqueue_count(), OSMO_FD_WRITE, and osmo_fd::when.

Referenced by osmo_wqueue_enqueue().

## osmo_wqueue_init()

void osmo_wqueue_init | ( | struct osmo_wqueue * | queue,
|  | int | max_length )

Initialize a osmo_wqueue structure.

Parameters

  [in] | queue | Write queue to operate on
  [in] | max_length | Maximum length of write queue

References osmo_wqueue::bfd, osmo_fd::cb, osmo_wqueue::current_length, osmo_wqueue::except_cb, INIT_LLIST_HEAD, osmo_wqueue::max_length, osmo_wqueue::msg_queue, osmo_wqueue_bfd_cb(), osmo_wqueue::read_cb, and osmo_wqueue::write_cb.

Referenced by _log_target_file_setup_iofd(), and osmo_tundev_alloc().

## osmo_wqueue_set_maxlen()

size_t osmo_wqueue_set_maxlen | ( | struct osmo_wqueue * | queue,
|  | unsigned int | len )

Update write queue length & drop excess messages.

Parameters

  [in] | queue | linked list header of message queue
  [in] | len | new max. wqueue length

Returns
  Number of messages dropped.

Messages beyond the new maximum message queue size will be dropped.

References osmo_wqueue::current_length, osmo_wqueue::max_length, osmo_wqueue::msg_queue, msgb_dequeue_count(), and msgb_free().