\doxysection{Osmocom msgb write queues}
\label{group__write__queue}\index{Osmocom msgb write queues@{Osmocom msgb write queues}}


Write queue for writing \doxyref{Message buffers}{p.}{group__msgb} to sockets/fds.  


\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ write\+\_\+queue.\+h}
\begin{DoxyCompactList}\small\item\em Generic write queue implementation. \end{DoxyCompactList}\item 
file \textbf{ write\+\_\+queue.\+c}
\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+wqueue}
\begin{DoxyCompactList}\small\item\em write queue instance \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ osmo\+\_\+wqueue\+\_\+init} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue, int max\+\_\+length)
\begin{DoxyCompactList}\small\item\em Initialize a \doxyref{osmo\+\_\+wqueue}{p.}{structosmo__wqueue} structure. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+wqueue\+\_\+clear} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue)
\begin{DoxyCompactList}\small\item\em Clear a \doxyref{osmo\+\_\+wqueue}{p.}{structosmo__wqueue}. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+wqueue\+\_\+enqueue} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue, struct \textbf{ msgb} $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Enqueue a new \doxyref{Message buffers}{p.}{group__msgb} into a write queue. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+wqueue\+\_\+enqueue\+\_\+quiet} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue, struct \textbf{ msgb} $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Enqueue a new \doxyref{Message buffers}{p.}{group__msgb} into a write queue (without logging full queue events) \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ osmo\+\_\+wqueue\+\_\+set\+\_\+maxlen} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue, unsigned int \textbf{ len})
\begin{DoxyCompactList}\small\item\em Update write queue length \& drop excess messages. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+wqueue\+\_\+bfd\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$fd, unsigned int what)
\begin{DoxyCompactList}\small\item\em Select loop function for write queue handling. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Write queue for writing \doxyref{Message buffers}{p.}{group__msgb} to sockets/fds. 



\doxysubsection{Function Documentation}
\mbox{\label{group__write__queue_ga56bb1b9d13a946be09fdbf400545d7ad}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_bfd\_cb@{osmo\_wqueue\_bfd\_cb}}
\index{osmo\_wqueue\_bfd\_cb@{osmo\_wqueue\_bfd\_cb}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_bfd\_cb()}
{\footnotesize\ttfamily int osmo\+\_\+wqueue\+\_\+bfd\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{fd,  }\item[{unsigned int}]{what }\end{DoxyParamCaption})}



Select loop function for write queue handling. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em fd} & osmocom file descriptor \\
\hline
\mbox{\texttt{ in}}  & {\em what} & bit-\/mask of events that have happened \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error
\end{DoxyReturn}
This function is provided so that it can be registered with the select loop abstraction code (\doxyref{osmo\+\_\+fd\+::cb}{p.}{structosmo__fd_a7a7294408590a34be4396ae14be5604d}). 

References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ container\+\_\+of}, \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ osmo\+\_\+wqueue\+::except\+\_\+cb}, \textbf{ llist\+\_\+add()}, \textbf{ llist\+\_\+empty()}, \textbf{ msg}, \textbf{ osmo\+\_\+wqueue\+::msg\+\_\+queue}, \textbf{ msgb\+\_\+dequeue\+\_\+count()}, \textbf{ msgb\+\_\+free()}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+EXCEPT}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+WRITE}, \textbf{ osmo\+\_\+wqueue\+::read\+\_\+cb}, \textbf{ osmo\+\_\+fd\+::when}, and \textbf{ osmo\+\_\+wqueue\+::write\+\_\+cb}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+alloc()}, and \textbf{ osmo\+\_\+wqueue\+\_\+init()}.

\mbox{\label{group__write__queue_ga833b4f5244c00c775260a83e9918073c}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_clear@{osmo\_wqueue\_clear}}
\index{osmo\_wqueue\_clear@{osmo\_wqueue\_clear}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_clear()}
{\footnotesize\ttfamily void osmo\+\_\+wqueue\+\_\+clear (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue }\end{DoxyParamCaption})}



Clear a \doxyref{osmo\+\_\+wqueue}{p.}{structosmo__wqueue}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em queue} & Write queue to be cleared\\
\hline
\end{DoxyParams}
This function will clear (remove/release) all messages in it. 

References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ llist\+\_\+empty()}, \textbf{ msg}, \textbf{ osmo\+\_\+wqueue\+::msg\+\_\+queue}, \textbf{ msgb\+\_\+dequeue()}, \textbf{ msgb\+\_\+free()}, and \textbf{ osmo\+\_\+fd\+::when}.



Referenced by \textbf{ log\+\_\+target\+\_\+destroy()}, \textbf{ osmo\+\_\+tundev\+\_\+close()}, and \textbf{ tundev\+\_\+ifupdown\+\_\+ind\+\_\+cb()}.

\mbox{\label{group__write__queue_ga9855de966a4f01d6df3a747422b02824}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_enqueue@{osmo\_wqueue\_enqueue}}
\index{osmo\_wqueue\_enqueue@{osmo\_wqueue\_enqueue}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_enqueue()}
{\footnotesize\ttfamily int osmo\+\_\+wqueue\+\_\+enqueue (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue,  }\item[{struct \textbf{ msgb} $\ast$}]{data }\end{DoxyParamCaption})}



Enqueue a new \doxyref{Message buffers}{p.}{group__msgb} into a write queue. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em queue} & Write queue to be used \\
\hline
\mbox{\texttt{ in}}  & {\em data} & to-\/be-\/enqueued message buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error (MESSAGE NOT FREED IN CASE OF ERROR). 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ data}, \textbf{ DLGLOBAL}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ osmo\+\_\+wqueue\+::max\+\_\+length}, and \textbf{ osmo\+\_\+wqueue\+\_\+enqueue\+\_\+quiet()}.



Referenced by \textbf{ osmo\+\_\+tundev\+\_\+send()}.

\mbox{\label{group__write__queue_ga7d4207497c2a2852f98ecf805424a504}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_enqueue\_quiet@{osmo\_wqueue\_enqueue\_quiet}}
\index{osmo\_wqueue\_enqueue\_quiet@{osmo\_wqueue\_enqueue\_quiet}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_enqueue\_quiet()}
{\footnotesize\ttfamily int osmo\+\_\+wqueue\+\_\+enqueue\+\_\+quiet (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue,  }\item[{struct \textbf{ msgb} $\ast$}]{data }\end{DoxyParamCaption})}



Enqueue a new \doxyref{Message buffers}{p.}{group__msgb} into a write queue (without logging full queue events) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em queue} & Write queue to be used \\
\hline
\mbox{\texttt{ in}}  & {\em data} & to-\/be-\/enqueued message buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error (MESSAGE NOT FREED IN CASE OF ERROR). 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ data}, \textbf{ osmo\+\_\+wqueue\+::max\+\_\+length}, \textbf{ osmo\+\_\+wqueue\+::msg\+\_\+queue}, \textbf{ msgb\+\_\+enqueue\+\_\+count()}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+WRITE}, and \textbf{ osmo\+\_\+fd\+::when}.



Referenced by \textbf{ \+\_\+file\+\_\+raw\+\_\+output()}, and \textbf{ osmo\+\_\+wqueue\+\_\+enqueue()}.

\mbox{\label{group__write__queue_gacca6343dd66b8cac8a5055b2a16eb990}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_init@{osmo\_wqueue\_init}}
\index{osmo\_wqueue\_init@{osmo\_wqueue\_init}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_init()}
{\footnotesize\ttfamily void osmo\+\_\+wqueue\+\_\+init (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue,  }\item[{int}]{max\+\_\+length }\end{DoxyParamCaption})}



Initialize a \doxyref{osmo\+\_\+wqueue}{p.}{structosmo__wqueue} structure. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em queue} & Write queue to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+length} & Maximum length of write queue \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ osmo\+\_\+fd\+::cb}, \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ osmo\+\_\+wqueue\+::except\+\_\+cb}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, \textbf{ osmo\+\_\+wqueue\+::max\+\_\+length}, \textbf{ osmo\+\_\+wqueue\+::msg\+\_\+queue}, \textbf{ osmo\+\_\+wqueue\+\_\+bfd\+\_\+cb()}, \textbf{ osmo\+\_\+wqueue\+::read\+\_\+cb}, and \textbf{ osmo\+\_\+wqueue\+::write\+\_\+cb}.



Referenced by \textbf{ log\+\_\+target\+\_\+create\+\_\+file()}, \textbf{ log\+\_\+target\+\_\+file\+\_\+switch\+\_\+to\+\_\+wqueue()}, and \textbf{ osmo\+\_\+tundev\+\_\+alloc()}.

\mbox{\label{group__write__queue_ga662e3311b8f57f2cbc0fbe741462dbca}} 
\index{Osmocom msgb write queues@{Osmocom msgb write queues}!osmo\_wqueue\_set\_maxlen@{osmo\_wqueue\_set\_maxlen}}
\index{osmo\_wqueue\_set\_maxlen@{osmo\_wqueue\_set\_maxlen}!Osmocom msgb write queues@{Osmocom msgb write queues}}
\doxysubsubsection{osmo\_wqueue\_set\_maxlen()}
{\footnotesize\ttfamily size\+\_\+t osmo\+\_\+wqueue\+\_\+set\+\_\+maxlen (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue,  }\item[{unsigned int}]{len }\end{DoxyParamCaption})}



Update write queue length \& drop excess messages. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em queue} & linked list header of message queue \\
\hline
\mbox{\texttt{ in}}  & {\em len} & new max. wqueue length \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Number of messages dropped.
\end{DoxyReturn}
Messages beyond the new maximum message queue size will be dropped. 

References \textbf{ osmo\+\_\+wqueue\+::current\+\_\+length}, \textbf{ len()}, \textbf{ osmo\+\_\+wqueue\+::max\+\_\+length}, \textbf{ msg}, \textbf{ osmo\+\_\+wqueue\+::msg\+\_\+queue}, \textbf{ msgb\+\_\+dequeue\+\_\+count()}, and \textbf{ msgb\+\_\+free()}.

