Mercurial > hg > freeDiameter
annotate libfdproto/fifo.c @ 662:2e94ef0515d7 1.1.0-rc1
Updated copyright information
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 14 Jan 2011 16:27:21 +0900 |
parents | f198d16fa7f4 |
children | 4a9f08d6b6ba |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * | |
4 * * | |
662
2e94ef0515d7
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
5 * Copyright (c) 2011, WIDE Project and NICT * |
0 | 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 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
36 /* FIFO queues module. |
0 | 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. | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
44 * -> consume any element that is in the queue, using fd_qu_tryget_int. |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
45 * -> then destroy the queue using fd_mq_del. |
0 | 46 */ |
47 | |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
451
diff
changeset
|
48 #include "fdproto-internal.h" |
0 | 49 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
50 /* Definition of a FIFO queue object */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
51 struct fifo { |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
52 int eyec; /* An eye catcher, also used to check a queue is valid. FIFO_EYEC */ |
0 | 53 |
54 pthread_mutex_t mtx; /* Mutex protecting this queue */ | |
55 pthread_cond_t cond; /* condition variable of the list */ | |
56 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
57 struct fd_list list; /* sentinel for the list of elements */ |
0 | 58 int count; /* number of objects in the list */ |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
59 int thrs; /* number of threads waiting for a new element (when count is 0) */ |
0 | 60 |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
61 uint16_t high; /* High level threshold (see libfreeDiameter.h for details) */ |
0 | 62 uint16_t low; /* Low level threshhold */ |
63 void *data; /* Opaque pointer for threshold callbacks */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
64 void (*h_cb)(struct fifo *, void **); /* The callbacks */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
65 void (*l_cb)(struct fifo *, void **); |
0 | 66 int highest;/* The highest count value for which h_cb has been called */ |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
67 int highest_ever; /* The max count value this queue has reached (for tweaking) */ |
0 | 68 }; |
69 | |
70 /* The eye catcher value */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
71 #define FIFO_EYEC 0xe7ec1130 |
0 | 72 |
73 /* Macro to check a pointer */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
74 #define CHECK_FIFO( _queue ) (( (_queue) != NULL) && ( (_queue)->eyec == FIFO_EYEC) ) |
0 | 75 |
76 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
77 /* Create a new queue */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
78 int fd_fifo_new ( struct fifo ** queue ) |
0 | 79 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
80 struct fifo * new; |
0 | 81 |
82 TRACE_ENTRY( "%p", queue ); | |
83 | |
84 CHECK_PARAMS( queue ); | |
85 | |
86 /* Create a new object */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
87 CHECK_MALLOC( new = malloc (sizeof (struct fifo) ) ); |
0 | 88 |
89 /* Initialize the content */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
90 memset(new, 0, sizeof(struct fifo)); |
0 | 91 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
92 new->eyec = FIFO_EYEC; |
0 | 93 CHECK_POSIX( pthread_mutex_init(&new->mtx, NULL) ); |
94 CHECK_POSIX( pthread_cond_init(&new->cond, NULL) ); | |
95 | |
96 fd_list_init(&new->list, NULL); | |
97 | |
98 /* We're done */ | |
99 *queue = new; | |
100 return 0; | |
101 } | |
102 | |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
103 /* Dump the content of a queue */ |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
104 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item)) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
105 { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
106 TRACE_ENTRY("%i %p %p %p", level, name, queue, dump_item); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
107 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
108 if (!TRACE_BOOL(level)) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
109 return; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
110 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
111 fd_log_debug("Dumping queue '%s' (%p):\n", name ?: "?", queue); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
112 if (!CHECK_FIFO( queue )) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
113 fd_log_debug(" Queue invalid!\n"); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
114 if (queue) |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
115 fd_log_debug(" (%x != %x)\n", queue->eyec, FIFO_EYEC); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
116 return; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
117 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
118 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
119 CHECK_POSIX_DO( pthread_mutex_lock( &queue->mtx ), /* continue */ ); |
11
6576ef5e01eb
Added some support for peers
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
120 fd_log_debug(" %d elements in queue / %d threads waiting\n", queue->count, queue->thrs); |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
121 fd_log_debug(" thresholds: %d / %d (h:%d), cb: %p,%p (%p), highest: %d\n", |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
122 queue->high, queue->low, queue->highest, |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
123 queue->h_cb, queue->l_cb, queue->data, |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
124 queue->highest_ever); |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
125 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
126 if (dump_item) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
127 struct fd_list * li; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
128 int i = 0; |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
129 for (li = queue->list.next; li != &queue->list; li = li->next) { |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
130 fd_log_debug(" [%i] item %p in fifo %p:\n", i++, li->o, queue); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
131 (*dump_item)(level, li->o); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
132 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
133 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
134 CHECK_POSIX_DO( pthread_mutex_unlock( &queue->mtx ), /* continue */ ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
135 |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
136 } |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
137 |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
138 /* Delete a queue. It must be empty. */ |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
139 int fd_fifo_del ( struct fifo ** queue ) |
0 | 140 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
141 struct fifo * q; |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
142 int loops = 0; |
0 | 143 |
144 TRACE_ENTRY( "%p", queue ); | |
145 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
146 CHECK_PARAMS( queue && CHECK_FIFO( *queue ) ); |
0 | 147 |
148 q = *queue; | |
149 | |
150 CHECK_POSIX( pthread_mutex_lock( &q->mtx ) ); | |
151 | |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
152 if ((q->count != 0) || (q->data != NULL)) { |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
153 TRACE_DEBUG(INFO, "The queue cannot be destroyed (%d, %p)", q->count, q->data); |
0 | 154 CHECK_POSIX_DO( pthread_mutex_unlock( &q->mtx ), /* no fallback */ ); |
155 return EINVAL; | |
156 } | |
157 | |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
158 /* Ok, now invalidate the queue */ |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
159 q->eyec = 0xdead; |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
160 |
156
e2dc300819b3
Fix overwriten thread location
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
139
diff
changeset
|
161 /* Have all waiting threads return an error */ |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
162 while (q->thrs) { |
138
4249a55f859a
Attempt to fix behavior on multi-CPU platforms
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
137
diff
changeset
|
163 CHECK_POSIX( pthread_mutex_unlock( &q->mtx )); |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
164 CHECK_POSIX( pthread_cond_signal(&q->cond) ); |
137
5510f73e1737
Replace non-posix pthread_yield with posix sched_yield
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
165 sched_yield(); |
139
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
166 if (loops >= 10) |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
167 /* sleep for a few milliseconds */ |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
168 usleep(50000); |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
169 |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
170 CHECK_POSIX( pthread_mutex_lock( &q->mtx ) ); |
139
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
171 ASSERT( ++loops < 20 ); /* detect infinite loops */ |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
172 } |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
173 |
0 | 174 /* sanity check */ |
175 ASSERT(FD_IS_LIST_EMPTY(&q->list)); | |
176 | |
177 /* And destroy it */ | |
178 CHECK_POSIX( pthread_mutex_unlock( &q->mtx ) ); | |
179 | |
451
4395961aad27
Some libc seem to have an issue with canceled threads...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
450
diff
changeset
|
180 CHECK_POSIX_DO( pthread_cond_destroy( &q->cond ), ); |
0 | 181 |
451
4395961aad27
Some libc seem to have an issue with canceled threads...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
450
diff
changeset
|
182 CHECK_POSIX_DO( pthread_mutex_destroy( &q->mtx ), ); |
0 | 183 |
184 free(q); | |
185 *queue = NULL; | |
186 | |
187 return 0; | |
188 } | |
189 | |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
190 /* Move the content of old into new, and update loc_update atomically. We leave the old queue empty but valid */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
191 int fd_fifo_move ( struct fifo * old, struct fifo * new, struct fifo ** loc_update ) |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
192 { |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
193 int loops = 0; |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
194 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
195 TRACE_ENTRY("%p %p %p", old, new, loc_update); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
196 CHECK_PARAMS( CHECK_FIFO( old ) && CHECK_FIFO( new )); |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
197 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
198 CHECK_PARAMS( ! old->data ); |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
199 if (new->high) { |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
200 TODO("Implement support for thresholds in fd_fifo_move..."); |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
201 } |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
202 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
203 /* Update loc_update */ |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
204 if (loc_update) |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
205 *loc_update = new; |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
206 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
207 /* Lock the queues */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
208 CHECK_POSIX( pthread_mutex_lock( &old->mtx ) ); |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
209 CHECK_POSIX( pthread_mutex_lock( &new->mtx ) ); |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
210 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
211 /* Any waiting thread on the old queue returns an error */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
212 old->eyec = 0xdead; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
213 while (old->thrs) { |
138
4249a55f859a
Attempt to fix behavior on multi-CPU platforms
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
137
diff
changeset
|
214 CHECK_POSIX( pthread_mutex_unlock( &old->mtx )); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
215 CHECK_POSIX( pthread_cond_signal(&old->cond) ); |
137
5510f73e1737
Replace non-posix pthread_yield with posix sched_yield
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
216 sched_yield(); |
139
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
217 if (loops >= 10) |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
218 /* sleep for a few milliseconds */ |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
219 usleep(50000); |
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
220 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
221 CHECK_POSIX( pthread_mutex_lock( &old->mtx ) ); |
139
8b8d11fadc4e
Attempt to fix behavior on multi-CPU platforms, take 2
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
138
diff
changeset
|
222 ASSERT( ++loops < 20 ); /* detect infinite loops */ |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
223 } |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
224 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
225 /* Move all data from old to new */ |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
226 fd_list_move_end( &new->list, &old->list ); |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
227 if (old->count && (!new->count)) { |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
228 CHECK_POSIX( pthread_cond_signal(&new->cond) ); |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
229 } |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
230 new->count += old->count; |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
231 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
232 /* Reset old */ |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
233 old->count = 0; |
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
234 old->eyec = FIFO_EYEC; |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
235 |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
236 /* Unlock, we're done */ |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
237 CHECK_POSIX( pthread_mutex_unlock( &new->mtx ) ); |
43
2db15632a63d
Added a large part of connection establishment logic, to test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
25
diff
changeset
|
238 CHECK_POSIX( pthread_mutex_unlock( &old->mtx ) ); |
25
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
239 |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
240 return 0; |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
241 } |
67ca08d5bc48
Completed connection context files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
242 |
0 | 243 /* Get the length of the queue */ |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
244 int fd_fifo_length ( struct fifo * queue, int * length ) |
0 | 245 { |
246 TRACE_ENTRY( "%p %p", queue, length ); | |
247 | |
248 /* Check the parameters */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
249 CHECK_PARAMS( CHECK_FIFO( queue ) && length ); |
0 | 250 |
251 /* lock the queue */ | |
252 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); | |
253 | |
254 /* Retrieve the count */ | |
255 *length = queue->count; | |
256 | |
257 /* Unlock */ | |
258 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); | |
259 | |
260 /* Done */ | |
261 return 0; | |
262 } | |
263 | |
264 /* alternate version with no error checking */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
265 int fd_fifo_length_noerr ( struct fifo * queue ) |
0 | 266 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
267 if ( !CHECK_FIFO( queue ) ) |
0 | 268 return 0; |
269 | |
270 return queue->count; /* Let's hope it's read atomically, since we are not locking... */ | |
271 } | |
272 | |
273 /* Set the thresholds of the queue */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
274 int fd_fifo_setthrhd ( struct fifo * queue, void * data, uint16_t high, void (*h_cb)(struct fifo *, void **), uint16_t low, void (*l_cb)(struct fifo *, void **) ) |
0 | 275 { |
276 TRACE_ENTRY( "%p %p %hu %p %hu %p", queue, data, high, h_cb, low, l_cb ); | |
277 | |
278 /* Check the parameters */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
279 CHECK_PARAMS( CHECK_FIFO( queue ) && (high > low) && (queue->data == NULL) ); |
0 | 280 |
281 /* lock the queue */ | |
282 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); | |
283 | |
284 /* Save the values */ | |
285 queue->high = high; | |
286 queue->low = low; | |
287 queue->data = data; | |
288 queue->h_cb = h_cb; | |
289 queue->l_cb = l_cb; | |
290 | |
291 /* Unlock */ | |
292 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); | |
293 | |
294 /* Done */ | |
295 return 0; | |
296 } | |
297 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
298 /* Post a new item in the queue */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
299 int fd_fifo_post_int ( struct fifo * queue, void ** item ) |
0 | 300 { |
301 struct fd_list * new; | |
302 int call_cb = 0; | |
303 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
304 TRACE_ENTRY( "%p %p", queue, item ); |
0 | 305 |
306 /* Check the parameters */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
307 CHECK_PARAMS( CHECK_FIFO( queue ) && item && *item ); |
0 | 308 |
309 /* Create a new list item */ | |
310 CHECK_MALLOC( new = malloc (sizeof (struct fd_list)) ); | |
311 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
312 fd_list_init(new, *item); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
313 *item = NULL; |
0 | 314 |
315 /* lock the queue */ | |
316 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); | |
317 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
318 /* Add the new item at the end */ |
0 | 319 fd_list_insert_before( &queue->list, new); |
320 queue->count++; | |
14
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
321 if (queue->highest_ever < queue->count) |
14cf6daf716d
Some progress on peers module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
322 queue->highest_ever = queue->count; |
0 | 323 if (queue->high && ((queue->count % queue->high) == 0)) { |
324 call_cb = 1; | |
325 queue->highest = queue->count; | |
326 } | |
327 | |
328 /* Signal if threads are asleep */ | |
329 if (queue->thrs > 0) { | |
330 CHECK_POSIX( pthread_cond_signal(&queue->cond) ); | |
331 } | |
332 | |
333 /* Unlock */ | |
334 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); | |
335 | |
336 /* Call high-watermark cb as needed */ | |
337 if (call_cb && queue->h_cb) | |
338 (*queue->h_cb)(queue, &queue->data); | |
339 | |
340 /* Done */ | |
341 return 0; | |
342 } | |
343 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
344 /* Pop the first item from the queue */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
345 static void * mq_pop(struct fifo * queue) |
0 | 346 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
347 void * ret = NULL; |
0 | 348 struct fd_list * li; |
349 | |
350 ASSERT( ! FD_IS_LIST_EMPTY(&queue->list) ); | |
351 | |
352 fd_list_unlink(li = queue->list.next); | |
353 queue->count--; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
354 ret = li->o; |
0 | 355 free(li); |
356 | |
357 return ret; | |
358 } | |
359 | |
360 /* Check if the low watermark callback must be called. */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
361 static __inline__ int test_l_cb(struct fifo * queue) |
0 | 362 { |
363 if ((queue->high == 0) || (queue->low == 0) || (queue->l_cb == 0)) | |
364 return 0; | |
365 | |
366 if (((queue->count % queue->high) == queue->low) && (queue->highest > queue->count)) { | |
367 queue->highest -= queue->high; | |
368 return 1; | |
369 } | |
370 | |
371 return 0; | |
372 } | |
373 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
374 /* Try poping an item */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
375 int fd_fifo_tryget_int ( struct fifo * queue, void ** item ) |
0 | 376 { |
377 int wouldblock = 0; | |
378 int call_cb = 0; | |
379 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
380 TRACE_ENTRY( "%p %p", queue, item ); |
0 | 381 |
382 /* Check the parameters */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
383 CHECK_PARAMS( CHECK_FIFO( queue ) && item ); |
0 | 384 |
385 /* lock the queue */ | |
386 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); | |
387 | |
388 /* Check queue status */ | |
389 if (queue->count > 0) { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
390 /* There are elements in the queue, so pick the first one */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
391 *item = mq_pop(queue); |
0 | 392 call_cb = test_l_cb(queue); |
393 } else { | |
394 wouldblock = 1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
395 *item = NULL; |
0 | 396 } |
397 | |
398 /* Unlock */ | |
399 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); | |
400 | |
401 /* Call low watermark callback as needed */ | |
402 if (call_cb) | |
403 (*queue->l_cb)(queue, &queue->data); | |
404 | |
405 /* Done */ | |
406 return wouldblock ? EWOULDBLOCK : 0; | |
407 } | |
408 | |
409 /* This handler is called when a thread is blocked on a queue, and cancelled */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
410 static void fifo_cleanup(void * queue) |
0 | 411 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
412 struct fifo * q = (struct fifo *)queue; |
0 | 413 TRACE_ENTRY( "%p", queue ); |
414 | |
415 /* The thread has been cancelled, therefore it does not wait on the queue anymore */ | |
416 q->thrs--; | |
417 | |
418 /* Now unlock the queue, and we're done */ | |
419 CHECK_POSIX_DO( pthread_mutex_unlock( &q->mtx ), /* nothing */ ); | |
420 | |
421 /* End of cleanup handler */ | |
422 return; | |
423 } | |
424 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
425 /* The internal function for fd_fifo_timedget and fd_fifo_get */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
426 static int fifo_tget ( struct fifo * queue, void ** item, int istimed, const struct timespec *abstime) |
0 | 427 { |
428 int timedout = 0; | |
429 int call_cb = 0; | |
430 | |
431 /* Check the parameters */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
432 CHECK_PARAMS( CHECK_FIFO( queue ) && item && (abstime || !istimed) ); |
0 | 433 |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
434 /* Initialize the return value */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
435 *item = NULL; |
0 | 436 |
437 /* lock the queue */ | |
438 CHECK_POSIX( pthread_mutex_lock( &queue->mtx ) ); | |
439 | |
440 awaken: | |
441 /* Check queue status */ | |
21
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
442 if (!CHECK_FIFO( queue )) { |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
443 /* The queue is being destroyed */ |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
444 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
445 TRACE_DEBUG(FULL, "The queue is being destroyed -> EPIPE"); |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
446 return EPIPE; |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
447 } |
bef197f6826f
Backup before week-end, cnxctx and server in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
14
diff
changeset
|
448 |
0 | 449 if (queue->count > 0) { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
450 /* There are items in the queue, so pick the first one */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
451 *item = mq_pop(queue); |
0 | 452 call_cb = test_l_cb(queue); |
453 } else { | |
454 int ret = 0; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
455 /* We have to wait for a new item */ |
0 | 456 queue->thrs++ ; |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
457 pthread_cleanup_push( fifo_cleanup, queue); |
0 | 458 if (istimed) { |
459 ret = pthread_cond_timedwait( &queue->cond, &queue->mtx, abstime ); | |
460 } else { | |
461 ret = pthread_cond_wait( &queue->cond, &queue->mtx ); | |
462 } | |
463 pthread_cleanup_pop(0); | |
464 queue->thrs-- ; | |
465 if (ret == 0) | |
466 goto awaken; /* test for spurious wake-ups */ | |
467 | |
468 if (istimed && (ret == ETIMEDOUT)) { | |
469 timedout = 1; | |
470 } else { | |
471 /* Unexpected error condition (means we need to debug) */ | |
472 ASSERT( ret == 0 /* never true */ ); | |
473 } | |
474 } | |
475 | |
476 /* Unlock */ | |
477 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); | |
478 | |
479 /* Call low watermark callback as needed */ | |
480 if (call_cb) | |
481 (*queue->l_cb)(queue, &queue->data); | |
482 | |
483 /* Done */ | |
484 return timedout ? ETIMEDOUT : 0; | |
485 } | |
486 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
487 /* Get the next available item, block until there is one */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
488 int fd_fifo_get_int ( struct fifo * queue, void ** item ) |
0 | 489 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
490 TRACE_ENTRY( "%p %p", queue, item ); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
491 return fifo_tget(queue, item, 0, NULL); |
0 | 492 } |
493 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
494 /* Get the next available item, block until there is one, or the timeout expires */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
495 int fd_fifo_timedget_int ( struct fifo * queue, void ** item, const struct timespec *abstime ) |
0 | 496 { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
497 TRACE_ENTRY( "%p %p %p", queue, item, abstime ); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
498 return fifo_tget(queue, item, 1, abstime); |
0 | 499 } |
500 |