Debian Codegraph @

lib/freeDiameter-1.2.1/libfdproto/fifo.c

raw symbols SCIP
1 /*********************************************************************************************************
2 * Software License Agreement (BSD License) *
3 * Author: Sebastien Decugis <[email protected]> *
4 * *
5 * Copyright (c) 2013, WIDE Project and NICT *
6 * All rights reserved. *
7 * *
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
9 * permitted provided that the following conditions are met: *
10 * *
11 * * Redistributions of source code must retain the above *
12 * copyright notice, this list of conditions and the *
13 * following disclaimer. *
14 * *
15 * * Redistributions in binary form must reproduce the above *
16 * copyright notice, this list of conditions and the *
17 * following disclaimer in the documentation and/or other *
18 * materials provided with the distribution. *
19 * *
20 * * Neither the name of the WIDE Project or NICT nor the *
21 * names of its contributors may be used to endorse or *
22 * promote products derived from this software without *
23 * specific prior written permission of WIDE Project and *
24 * NICT. *
25 * *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34 *********************************************************************************************************/
35
36 /* FIFO queues module.
37 *
38 * The threads that call these functions must be in the cancellation state PTHREAD_CANCEL_ENABLE and type PTHREAD_CANCEL_DEFERRED.
39 * This is the default state and type on thread creation.
40 *
41 * In order to destroy properly a queue, the application must:
42 * -> shutdown any process that can add into the queue first.
43 * -> pthread_cancel any thread that could be waiting on the queue.
44 * -> consume any element that is in the queue, using fd_qu_tryget_int.
45 * -> then destroy the queue using fd_mq_del.
46 */
47
48 #include "fdproto-internal.h"cxx . . $ `<file>/lib/freeDiameter-1.2.1/libfdproto/fdproto-internal.h`/
49
50 /* Definition of a FIFO queue object */
51 struct fifocxx . . $ fifo# {
52 int eyeccxx . . $ fifo#eyec.; /* An eye catcher, also used to check a queue is valid. FIFO_EYEC */
53
54 pthread_mutex_tcxx . . $ pthread_mutex_t# mtxcxx . . $ fifo#mtx.; /* Mutex protecting this queue */
55 pthread_cond_tcxx . . $ pthread_cond_t# cond_pullcxx . . $ fifo#cond_pull.; /* condition variable for pulling threads */
56 pthread_cond_tcxx . . $ pthread_cond_t# cond_pushcxx . . $ fifo#cond_push.; /* condition variable for pushing threads */
57
58 struct fd_listcxx . . $ fd_list# listcxx . . $ fifo#list.; /* sentinel for the list of elements */
59 int countcxx . . $ fifo#count.; /* number of objects in the list */
60 int thrscxx . . $ fifo#thrs.; /* number of threads waiting for a new element (when count is 0) */
61
62 int maxcxx . . $ fifo#max.; /* maximum number of items to accept if not 0 */
63 int thrs_pushcxx . . $ fifo#thrs_push.; /* number of threads waitnig to push an item */
64
65 uint16_tcxx . . $ uint16_t# highcxx . . $ fifo#high.; /* High level threshold (see libfreeDiameter.h for details) */
66 uint16_tcxx . . $ uint16_t# lowcxx . . $ fifo#low.; /* Low level threshhold */
67 void *datacxx . . $ fifo#data.; /* Opaque pointer for threshold callbacks */
68 void (*h_cbcxx . . $ fifo#h_cb.)(struct fifocxx . . $ fifo# *, void **); /* The callbacks */
69 void (*l_cbcxx . . $ fifo#l_cb.)(struct fifocxx . . $ fifo# *, void **);
70 int highestcxx . . $ fifo#highest.;/* The highest count value for which h_cb has been called */
71 int highest_evercxx . . $ fifo#highest_ever.; /* The max count value this queue has reached (for tweaking) */
72
73 long long total_itemscxx . . $ fifo#total_items.; /* Cumulated number of items that went through this fifo (excluding current count), always increasing. */
74 struct timespeccxx . . $ timespec# total_timecxx . . $ fifo#total_time.; /* Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring) */
75 struct timespeccxx . . $ timespec# blocking_timecxx . . $ fifo#blocking_time.; /* Cumulated time threads trying to post new items were blocked (queue full). */
76 struct timespeccxx . . $ timespec# last_timecxx . . $ fifo#last_time.; /* For the last element retrieved from the queue, how long it take between posting (including blocking) and poping */
77
78 };
79
80 struct fifo_itemcxx . . $ fifo_item# {
81 struct fd_listcxx . . $ fd_list# itemcxx . . $ fifo_item#item.;
82 struct timespeccxx . . $ timespec# posted_oncxx . . $ fifo_item#posted_on.;
83 };
84
85 /* The eye catcher value */
86 #define FIFO_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:86:9`! 0xe7ec1130
87
88 /* Macro to check a pointer */
89 #define CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( _queue ) (( (_queue) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && ( (_queue)->eyec == FIFO_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:86:9`!) )
90
91
92 /* Create a new queue, with max number of items -- use 0 for no max */
93 int fd_fifo_newcxx . . $ fd_fifo_new(7477a3c18aa90ca9). ( struct fifocxx . . $ fifo# ** queue, int max )
94 {
95 struct fifocxx . . $ fifo# * new;
96
97 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p", queue );
98
99 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( queue );
100
101 /* Create a new object */
102 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( new = malloc (sizeof (struct fifo) ) );
103
104 /* Initialize the content */
105 memsetcxx . . $ memset(d1de1e4fb215f1c6).(new, 0, sizeof(struct fifocxx . . $ fifo#));
106
107 new->eyeccxx . . $ fifo#eyec. = FIFO_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:86:9`!;
108 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_init(&new->mtx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
109 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_init(&new->cond_pull, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
110 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_init(&new->cond_push, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
111 new->maxcxx . . $ fifo#max. = max;
112
113 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&new->listcxx . . $ fifo#list., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
114
115 /* We're done */
116 *queue = new;
117 return 0;
118 }
119
120 /* Dump the content of a queue */
121 DECLARE_FD_DUMP_PROTOTYPEcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:241:9`!(fd_fifo_dump, char * name, struct fifo * queue, fd_fifo_dump_item_cb dump_item)
122 {
123 FD_DUMP_HANDLE_OFFSETcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:257:9`!();
124
125 if (name) {
126 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "'%s'(@%p): ", name, queue), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
127 } else {
128 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "{fifo}(@%p): ", queue), return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
129 }
130
131 if (!CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue )) {
132 return fd_dump_extendcxx . . $ fd_dump_extend(c968a74efae60792).(FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "INVALID/NULL");
133 }
134
135 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &queue->mtx ), /* continue */ );
136 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "items:%d,%d,%d threads:%d,%d stats:%lld/%ld.%06ld,%ld.%06ld,%ld.%06ld thresholds:%d,%d,%d,%p,%p,%p",
137 queue->count, queue->highest_ever, queue->max,
138 queue->thrs, queue->thrs_push,
139 queue->total_items,(long)queue->total_time.tv_sec,(long)(queue->total_time.tv_nsec/1000),(long)queue->blocking_time.tv_sec,(long)(queue->blocking_time.tv_nsec/1000),(long)queue->last_time.tv_sec,(long)(queue->last_time.tv_nsec/1000),
140 queue->high, queue->low, queue->highest, queue->h_cb, queue->l_cb, queue->data),
141 goto error);
142
143 if (dump_item) {
144 struct fd_listcxx . . $ fd_list# * li;
145 int i = 0;
146 for (li = queue->listcxx . . $ fifo#list..nextcxx . . $ fd_list#next.; li != &queue->listcxx . . $ fifo#list.; li = li->nextcxx . . $ fd_list#next.) {
147 struct fifo_itemcxx . . $ fifo_item# * fi = (struct fifo_itemcxx . . $ fifo_item# *)li;
148 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( fd_dump_extend( FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, "\n [#%i](@%p)@%ld.%06ld: ",
149 i++, fi->item.o, (long)fi->posted_on.tv_sec,(long)(fi->posted_on.tv_nsec/1000)),
150 goto error);
151 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( (*dump_item)(FD_DUMP_STD_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:256:9`!, fi->item.o), goto error);
152 }
153 }
154 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &queue->mtx ), /* continue */ );
155
156 return *buf;
157 error:
158 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &queue->mtx ), /* continue */ );
159 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
160 }
161
162 /* Delete a queue. It must be empty. */
163 int fd_fifo_delcxx . . $ fd_fifo_del(37f5c49482c5d21b). ( struct fifocxx . . $ fifo# ** queue )
164 {
165 struct fifocxx . . $ fifo# * q;
166 int loops = 0;
167
168 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p", queue );
169
170 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( queue && CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( *queue ) );
171
172 q = *queue;
173
174 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &q->mtx ) );
175
176 if ((q->countcxx . . $ fifo#count. != 0) || (q->datacxx . . $ fifo#data. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) {
177 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "The queue cannot be destroyed (%d, %p)", q->count, q->data);
178 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &q->mtx ), /* no fallback */ );
179 return EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
180 }
181
182 /* Ok, now invalidate the queue */
183 q->eyeccxx . . $ fifo#eyec. = 0xdead;
184
185 /* Have all waiting threads return an error */
186 while (q->thrscxx . . $ fifo#thrs.) {
187 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &q->mtx ));
188 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal(&q->cond_pull) );
189 usleepcxx . . $ usleep(4c679297bf94b9eb).(1000);
190
191 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &q->mtx ) );
192 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!( ++loops < 20 ); /* detect infinite loops */
193 }
194
195 /* sanity check */
196 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!(FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&q->list));
197
198 /* And destroy it */
199 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &q->mtx ) );
200
201 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_destroy( &q->cond_pull ), );
202
203 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_destroy( &q->cond_push ), );
204
205 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_destroy( &q->mtx ), );
206
207 freecxx . . $ free(5d22bdacc48458e8).(q);
208 *queue = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
209
210 return 0;
211 }
212
213 /* Move the content of old into new, and update loc_update atomically. We leave the old queue empty but valid */
214 int fd_fifo_movecxx . . $ fd_fifo_move(b00edebc4179e88b). ( struct fifocxx . . $ fifo# * old, struct fifocxx . . $ fifo# * new, struct fifocxx . . $ fifo# ** loc_update )
215 {
216 int loops = 0;
217
218 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p %p", old, new, loc_update);
219 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( old ) && CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( new ));
220
221 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( ! old->data );
222 if (new->highcxx . . $ fifo#high.) {
223 TODOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:388:10`!("Implement support for thresholds in fd_fifo_move...");
224 }
225
226 /* Update loc_update */
227 if (loc_update)
228 *loc_update = new;
229
230 /* Lock the queues */
231 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &old->mtx ) );
232
233 CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!( (! old->thrs_push), {
234 pthread_mutex_unlock( &old->mtx );
235 return EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
236 } );
237
238 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &new->mtx ) );
239
240 /* Any waiting thread on the old queue returns an error */
241 old->eyeccxx . . $ fifo#eyec. = 0xdead;
242 while (old->thrscxx . . $ fifo#thrs.) {
243 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &old->mtx ));
244 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal( &old->cond_pull ) );
245 usleepcxx . . $ usleep(4c679297bf94b9eb).(1000);
246
247 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &old->mtx ) );
248 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!( loops < 20 ); /* detect infinite loops */
249 }
250
251 /* Move all data from old to new */
252 fd_list_move_endcxx . . $ fd_list_move_end(3eafa2e8bb09a989).( &new->listcxx . . $ fifo#list., &old->listcxx . . $ fifo#list. );
253 if (old->countcxx . . $ fifo#count. && (!new->countcxx . . $ fifo#count.)) {
254 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal(&new->cond_pull) );
255 }
256 new->countcxx . . $ fifo#count. += old->countcxx . . $ fifo#count.;
257
258 /* Reset old */
259 old->countcxx . . $ fifo#count. = 0;
260 old->eyeccxx . . $ fifo#eyec. = FIFO_EYECcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:86:9`!;
261
262 /* Merge the stats in the new queue */
263 new->total_itemscxx . . $ fifo#total_items. += old->total_itemscxx . . $ fifo#total_items.;
264 old->total_itemscxx . . $ fifo#total_items. = 0;
265
266 new->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec. += old->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec.;
267 new->total_timecxx . . $ fifo#total_time..tv_seccxx . . $ timespec#tv_sec. += old->total_timecxx . . $ fifo#total_time..tv_seccxx . . $ timespec#tv_sec. + (new->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec. / 1000000000);
268 new->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec. %= 1000000000;
269 old->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec. = 0;
270 old->total_timecxx . . $ fifo#total_time..tv_seccxx . . $ timespec#tv_sec. = 0;
271
272 new->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec. += old->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec.;
273 new->blocking_timecxx . . $ fifo#blocking_time..tv_seccxx . . $ timespec#tv_sec. += old->blocking_timecxx . . $ fifo#blocking_time..tv_seccxx . . $ timespec#tv_sec. + (new->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec. / 1000000000);
274 new->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec. %= 1000000000;
275 old->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec. = 0;
276 old->blocking_timecxx . . $ fifo#blocking_time..tv_seccxx . . $ timespec#tv_sec. = 0;
277
278 /* Unlock, we're done */
279 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &new->mtx ) );
280 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &old->mtx ) );
281
282 return 0;
283 }
284
285 /* Get the information on the queue */
286 int fd_fifo_getstatscxx . . $ fd_fifo_getstats(146dadb03cf93f29).( struct fifocxx . . $ fifo# * queue, int * current_count, int * limit_count, int * highest_count, long long * total_count,
287 struct timespeccxx . . $ timespec# * total, struct timespeccxx . . $ timespec# * blocking, struct timespeccxx . . $ timespec# * last)
288 {
289 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p %p %p %p %p %p %p", queue, current_count, limit_count, highest_count, total_count, total, blocking, last);
290
291 /* Check the parameters */
292 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) );
293
294 /* lock the queue */
295 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
296
297 if (current_count)
298 *current_count = queue->countcxx . . $ fifo#count.;
299
300 if (limit_count)
301 *limit_count = queue->maxcxx . . $ fifo#max.;
302
303 if (highest_count)
304 *highest_count = queue->highest_evercxx . . $ fifo#highest_ever.;
305
306 if (total_count)
307 *total_count = queue->total_itemscxx . . $ fifo#total_items.;
308
309 if (total)
310 memcpycxx . . $ memcpy(cc817cb175f282d).(total, &queue->total_timecxx . . $ fifo#total_time., sizeof(struct timespeccxx . . $ timespec#));
311
312 if (blocking)
313 memcpycxx . . $ memcpy(cc817cb175f282d).(blocking, &queue->blocking_timecxx . . $ fifo#blocking_time., sizeof(struct timespeccxx . . $ timespec#));
314
315 if (last)
316 memcpycxx . . $ memcpy(cc817cb175f282d).(last, &queue->last_timecxx . . $ fifo#last_time., sizeof(struct timespeccxx . . $ timespec#));
317
318 /* Unlock */
319 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
320
321 /* Done */
322 return 0;
323 }
324
325
326 /* alternate version with no error checking */
327 int fd_fifo_lengthcxx . . $ fd_fifo_length(e2e117d5f7330520). ( struct fifocxx . . $ fifo# * queue )
328 {
329 if ( !CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) )
330 return 0;
331
332 return queue->countcxx . . $ fifo#count.; /* Let's hope it's read atomically, since we are not locking... */
333 }
334
335 /* Set the thresholds of the queue */
336 int fd_fifo_setthrhdcxx . . $ fd_fifo_setthrhd(123d1612aa2e335f). ( struct fifocxx . . $ fifo# * queue, void * data, uint16_tcxx . . $ uint16_t# high, void (*h_cb)(struct fifocxx . . $ fifo# *, void **), uint16_tcxx . . $ uint16_t# low, void (*l_cb)(struct fifocxx . . $ fifo# *, void **) )
337 {
338 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p %hu %p %hu %p", queue, data, high, h_cb, low, l_cb );
339
340 /* Check the parameters */
341 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) && (high > low) && (queue->data == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) );
342
343 /* lock the queue */
344 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
345
346 /* Save the values */
347 queue->highcxx . . $ fifo#high. = high;
348 queue->lowcxx . . $ fifo#low. = low;
349 queue->datacxx . . $ fifo#data. = data;
350 queue->h_cbcxx . . $ fifo#h_cb. = h_cb;
351 queue->l_cbcxx . . $ fifo#l_cb. = l_cb;
352
353 /* Unlock */
354 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
355
356 /* Done */
357 return 0;
358 }
359
360
361 /* This handler is called when a thread is blocked on a queue, and cancelled */
362 static void fifo_cleanup_pushcxx . . $ fifo_cleanup_push(5d22bdacc48458e8).(void * queue)
363 {
364 struct fifocxx . . $ fifo# * q = (struct fifocxx . . $ fifo# *)queue;
365 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p", queue );
366
367 /* The thread has been cancelled, therefore it does not wait on the queue anymore */
368 q->thrs_pushcxx . . $ fifo#thrs_push.--;
369
370 /* Now unlock the queue, and we're done */
371 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &q->mtx ), /* nothing */ );
372
373 /* End of cleanup handler */
374 return;
375 }
376
377
378 /* Post a new item in the queue */
379 int fd_fifo_post_internalcxx . . $ fd_fifo_post_internal(4007ec4b45e0b2ce). ( struct fifocxx . . $ fifo# * queue, void ** item, int skip_max )
380 {
381 struct fifo_itemcxx . . $ fifo_item# * new;
382 int call_cb = 0;
383 struct timespeccxx . . $ timespec# posted_on, queued_on;
384
385 /* Get the timing of this call */
386 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &posted_on) );
387
388 /* lock the queue */
389 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
390
391 if ((!skip_max) && (queue->maxcxx . . $ fifo#max.)) {
392 while (queue->countcxx . . $ fifo#count. >= queue->maxcxx . . $ fifo#max.) {
393 int ret = 0;
394
395 /* We have to wait for an item to be pulled */
396 queue->thrs_pushcxx . . $ fifo#thrs_push.++ ;
397 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fifo_cleanup_push, queue);
398 ret = pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).( &queue->cond_pushcxx . . $ fifo#cond_push., &queue->mtxcxx . . $ fifo#mtx. );
399 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
400 queue->thrs_pushcxx . . $ fifo#thrs_push.-- ;
401
402 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!( ret == 0 );
403 }
404 }
405
406 /* Create a new list item */
407 CHECK_MALLOC_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:561:10`!( new = malloc (sizeof (struct fifo_item)) , {
408 pthread_mutex_unlock( &queue->mtx );
409 return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
410 } );
411
412 fd_list_initcxx . . $ fd_list_init(a68d7934af8ecc50).(&new->itemcxx . . $ fifo_item#item., *item);
413 *item = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
414
415 /* Add the new item at the end */
416 fd_list_insert_beforecxx . . $ fd_list_insert_before(3eafa2e8bb09a989).( &queue->listcxx . . $ fifo#list., &new->itemcxx . . $ fifo_item#item.);
417 queue->countcxx . . $ fifo#count.++;
418 if (queue->highest_evercxx . . $ fifo#highest_ever. < queue->countcxx . . $ fifo#count.)
419 queue->highest_evercxx . . $ fifo#highest_ever. = queue->countcxx . . $ fifo#count.;
420 if (queue->highcxx . . $ fifo#high. && ((queue->countcxx . . $ fifo#count. % queue->highcxx . . $ fifo#high.) == 0)) {
421 call_cb = 1;
422 queue->highestcxx . . $ fifo#highest. = queue->countcxx . . $ fifo#count.;
423 }
424
425 /* store timing */
426 memcpycxx . . $ memcpy(cc817cb175f282d).(&new->posted_oncxx . . $ fifo_item#posted_on., &posted_on, sizeof(struct timespeccxx . . $ timespec#));
427
428 /* update queue timing info "blocking time" */
429 {
430 long long blocked_ns;
431 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &queued_on) );
432 blocked_ns = (queued_on.tv_seccxx . . $ timespec#tv_sec. - posted_on.tv_seccxx . . $ timespec#tv_sec.) * 1000000000;
433 blocked_ns += (queued_on.tv_nseccxx . . $ timespec#tv_nsec. - posted_on.tv_nseccxx . . $ timespec#tv_nsec.);
434 blocked_ns += queue->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec.;
435 queue->blocking_timecxx . . $ fifo#blocking_time..tv_seccxx . . $ timespec#tv_sec. += blocked_ns / 1000000000;
436 queue->blocking_timecxx . . $ fifo#blocking_time..tv_nseccxx . . $ timespec#tv_nsec. = blocked_ns % 1000000000;
437 }
438
439 /* Signal if threads are asleep */
440 if (queue->thrscxx . . $ fifo#thrs. > 0) {
441 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal(&queue->cond_pull) );
442 }
443 if (queue->thrs_pushcxx . . $ fifo#thrs_push. > 0) {
444 /* cascade */
445 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal(&queue->cond_push) );
446 }
447
448 /* Unlock */
449 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
450
451 /* Call high-watermark cb as needed */
452 if (call_cb && queue->h_cbcxx . . $ fifo#h_cb.)
453 (*queue->h_cbcxx . . $ fifo#h_cb.)(queue, &queue->datacxx . . $ fifo#data.);
454
455 /* Done */
456 return 0;
457 }
458
459 /* Post a new item in the queue */
460 int fd_fifo_post_intcxx . . $ fd_fifo_post_int(2d1b7efac5712f80). ( struct fifocxx . . $ fifo# * queue, void ** item )
461 {
462 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p", queue, item );
463
464 /* Check the parameters */
465 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) && item && *item );
466
467 return fd_fifo_post_internalcxx . . $ fd_fifo_post_internal(4007ec4b45e0b2ce). ( queue,item, 0 );
468
469 }
470
471 /* Post a new item in the queue, not blocking */
472 int fd_fifo_post_noblockcxx . . $ fd_fifo_post_noblock(2d1b7efac5712f80). ( struct fifocxx . . $ fifo# * queue, void ** item )
473 {
474 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p", queue, item );
475
476 /* Check the parameters */
477 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) && item && *item );
478
479 return fd_fifo_post_internalcxx . . $ fd_fifo_post_internal(4007ec4b45e0b2ce). ( queue,item, 1 );
480
481 }
482
483 /* Pop the first item from the queue */
484 static void * mq_popcxx . . $ mq_pop(dac7a3b4bc973d1e).(struct fifocxx . . $ fifo# * queue)
485 {
486 void * ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
487 struct fifo_itemcxx . . $ fifo_item# * fi;
488 struct timespeccxx . . $ timespec# now;
489
490 ASSERTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:267:9`!( ! FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(&queue->list) );
491
492 fi = (struct fifo_itemcxx . . $ fifo_item# *)(queue->listcxx . . $ fifo#list..nextcxx . . $ fd_list#next.);
493 ret = fi->itemcxx . . $ fifo_item#item..ocxx . . $ fd_list#o.;
494 fd_list_unlinkcxx . . $ fd_list_unlink(a0ae291b675747fa).(&fi->itemcxx . . $ fifo_item#item.);
495 queue->countcxx . . $ fifo#count.--;
496 queue->total_itemscxx . . $ fifo#total_items.++;
497
498 /* Update the timings */
499 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &now), goto skip_timing );
500 {
501 long long elapsed = (now.tv_seccxx . . $ timespec#tv_sec. - fi->posted_oncxx . . $ fifo_item#posted_on..tv_seccxx . . $ timespec#tv_sec.) * 1000000000;
502 elapsed += now.tv_nseccxx . . $ timespec#tv_nsec. - fi->posted_oncxx . . $ fifo_item#posted_on..tv_nseccxx . . $ timespec#tv_nsec.;
503
504 queue->last_timecxx . . $ fifo#last_time..tv_seccxx . . $ timespec#tv_sec. = elapsed / 1000000000;
505 queue->last_timecxx . . $ fifo#last_time..tv_nseccxx . . $ timespec#tv_nsec. = elapsed % 1000000000;
506
507 elapsed += queue->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec.;
508 queue->total_timecxx . . $ fifo#total_time..tv_seccxx . . $ timespec#tv_sec. += elapsed / 1000000000;
509 queue->total_timecxx . . $ fifo#total_time..tv_nseccxx . . $ timespec#tv_nsec. = elapsed % 1000000000;
510 }
511 skip_timing:
512 freecxx . . $ free(5d22bdacc48458e8).(fi);
513
514 if (queue->thrs_pushcxx . . $ fifo#thrs_push.) {
515 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_cond_signal( &queue->cond_push ), );
516 }
517
518 return ret;
519 }
520
521 /* Check if the low watermark callback must be called. */
522 static __inline__ int test_l_cbcxx . . $ test_l_cb(e2e117d5f7330520).(struct fifocxx . . $ fifo# * queue)
523 {
524 if ((queue->highcxx . . $ fifo#high. == 0) || (queue->lowcxx . . $ fifo#low. == 0) || (queue->l_cbcxx . . $ fifo#l_cb. == 0))
525 return 0;
526
527 if (((queue->countcxx . . $ fifo#count. % queue->highcxx . . $ fifo#high.) == queue->lowcxx . . $ fifo#low.) && (queue->highestcxx . . $ fifo#highest. > queue->countcxx . . $ fifo#count.)) {
528 queue->highestcxx . . $ fifo#highest. -= queue->highcxx . . $ fifo#high.;
529 return 1;
530 }
531
532 return 0;
533 }
534
535 /* Try poping an item */
536 int fd_fifo_tryget_intcxx . . $ fd_fifo_tryget_int(2d1b7efac5712f80). ( struct fifocxx . . $ fifo# * queue, void ** item )
537 {
538 int wouldblock = 0;
539 int call_cb = 0;
540
541 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p", queue, item );
542
543 /* Check the parameters */
544 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) && item );
545
546 /* lock the queue */
547 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
548
549 /* Check queue status */
550 if (queue->countcxx . . $ fifo#count. > 0) {
551 got_item:
552 /* There are elements in the queue, so pick the first one */
553 *item = mq_popcxx . . $ mq_pop(dac7a3b4bc973d1e).(queue);
554 call_cb = test_l_cbcxx . . $ test_l_cb(e2e117d5f7330520).(queue);
555 } else {
556 if (queue->thrs_pushcxx . . $ fifo#thrs_push. > 0) {
557 /* A thread is trying to push something, let's give it a chance */
558 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
559 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_cond_signal( &queue->cond_push ) );
560 usleepcxx . . $ usleep(4c679297bf94b9eb).(1000);
561 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
562 if (queue->countcxx . . $ fifo#count. > 0)
563 goto got_item;
564 }
565
566 wouldblock = 1;
567 *item = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
568 }
569
570 /* Unlock */
571 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
572
573 /* Call low watermark callback as needed */
574 if (call_cb)
575 (*queue->l_cbcxx . . $ fifo#l_cb.)(queue, &queue->datacxx . . $ fifo#data.);
576
577 /* Done */
578 return wouldblock ? EWOULDBLOCKcxx . . $ `<external>/17922322188510340118/errno.h:22:9`! : 0;
579 }
580
581 /* This handler is called when a thread is blocked on a queue, and cancelled */
582 static void fifo_cleanupcxx . . $ fifo_cleanup(5d22bdacc48458e8).(void * queue)
583 {
584 struct fifocxx . . $ fifo# * q = (struct fifocxx . . $ fifo# *)queue;
585 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p", queue );
586
587 /* The thread has been cancelled, therefore it does not wait on the queue anymore */
588 q->thrscxx . . $ fifo#thrs.--;
589
590 /* Now unlock the queue, and we're done */
591 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &q->mtx ), /* nothing */ );
592
593 /* End of cleanup handler */
594 return;
595 }
596
597 /* The internal function for fd_fifo_timedget and fd_fifo_get */
598 static int fifo_tgetcxx . . $ fifo_tget(1314049d1711a14e). ( struct fifocxx . . $ fifo# * queue, void ** item, int istimed, const struct timespeccxx . . $ timespec# *abstime)
599 {
600 int call_cb = 0;
601 int ret = 0;
602
603 /* Check the parameters */
604 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ) && item && (abstime || !istimed) );
605
606 /* Initialize the return value */
607 *item = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
608
609 /* lock the queue */
610 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_lock( &queue->mtx ) );
611
612 awaken:
613 /* Check queue status */
614 if (!CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue )) {
615 /* The queue is being destroyed */
616 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
617 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "The queue is being destroyed -> EPIPE");
618 return EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!;
619 }
620
621 if (queue->countcxx . . $ fifo#count. > 0) {
622 /* There are items in the queue, so pick the first one */
623 *item = mq_popcxx . . $ mq_pop(dac7a3b4bc973d1e).(queue);
624 call_cb = test_l_cbcxx . . $ test_l_cb(e2e117d5f7330520).(queue);
625 } else {
626 /* We have to wait for a new item */
627 queue->thrscxx . . $ fifo#thrs.++ ;
628 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fifo_cleanup, queue);
629 if (istimed) {
630 ret = pthread_cond_timedwaitcxx . . $ pthread_cond_timedwait(d8fcb9edac03ad51).( &queue->cond_pullcxx . . $ fifo#cond_pull., &queue->mtxcxx . . $ fifo#mtx., abstime );
631 } else {
632 ret = pthread_cond_waitcxx . . $ pthread_cond_wait(6145be15a5d9db5d).( &queue->cond_pullcxx . . $ fifo#cond_pull., &queue->mtxcxx . . $ fifo#mtx. );
633 }
634 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
635 queue->thrscxx . . $ fifo#thrs.-- ;
636 if (ret == 0)
637 goto awaken; /* test for spurious wake-ups */
638
639 /* otherwise (ETIMEDOUT / other error) just continue */
640 }
641
642 /* Unlock */
643 CHECK_POSIXcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:558:10`!( pthread_mutex_unlock( &queue->mtx ) );
644
645 /* Call low watermark callback as needed */
646 if (call_cb)
647 (*queue->l_cbcxx . . $ fifo#l_cb.)(queue, &queue->datacxx . . $ fifo#data.);
648
649 /* Done */
650 return ret;
651 }
652
653 /* Get the next available item, block until there is one */
654 int fd_fifo_get_intcxx . . $ fd_fifo_get_int(2d1b7efac5712f80). ( struct fifocxx . . $ fifo# * queue, void ** item )
655 {
656 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p", queue, item );
657 return fifo_tgetcxx . . $ fifo_tget(1314049d1711a14e).(queue, item, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
658 }
659
660 /* Get the next available item, block until there is one, or the timeout expires */
661 int fd_fifo_timedget_intcxx . . $ fd_fifo_timedget_int(429abc9a5ff3212). ( struct fifocxx . . $ fifo# * queue, void ** item, const struct timespeccxx . . $ timespec# *abstime )
662 {
663 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p %p", queue, item, abstime );
664 return fifo_tgetcxx . . $ fifo_tget(1314049d1711a14e).(queue, item, 1, abstime);
665 }
666
667 /* Test if data is available in the queue, without pulling it */
668 int fd_fifo_selectcxx . . $ fd_fifo_select(ef5f9dd177679545). ( struct fifocxx . . $ fifo# * queue, const struct timespeccxx . . $ timespec# *abstime )
669 {
670 int ret = 0;
671 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%p %p", queue, abstime );
672
673 CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!( CHECK_FIFOcxx . . $ `lib/freeDiameter-1.2.1/libfdproto/fifo.c:89:9`!( queue ), return -EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! );
674
675 /* lock the queue */
676 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_lock( &queue->mtx ), return -__ret__ );
677
678 awaken:
679 ret = (queue->countcxx . . $ fifo#count. > 0 ) ? queue->countcxx . . $ fifo#count. : 0;
680 if ((ret == 0) && (abstime != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) {
681 /* We have to wait for a new item */
682 queue->thrscxx . . $ fifo#thrs.++ ;
683 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( fifo_cleanup, queue);
684 ret = pthread_cond_timedwaitcxx . . $ pthread_cond_timedwait(d8fcb9edac03ad51).( &queue->cond_pullcxx . . $ fifo#cond_pull., &queue->mtxcxx . . $ fifo#mtx., abstime );
685 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
686 queue->thrscxx . . $ fifo#thrs.-- ;
687 if (ret == 0)
688 goto awaken; /* test for spurious wake-ups */
689
690 if (ret == ETIMEDOUTcxx . . $ `<external>/17922322188510340118/errno.h:94:9`!)
691 ret = 0;
692 else
693 ret = -ret;
694 }
695
696 /* Unlock */
697 CHECK_POSIX_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:555:10`!( pthread_mutex_unlock( &queue->mtx ), return -__ret__ );
698
699 return ret;
700 }