Changeset 21:bef197f6826f in freeDiameter for libfreeDiameter/fifo.c
- Timestamp:
- Oct 8, 2009, 8:05:16 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfreeDiameter/fifo.c
r14 r21 136 136 } 137 137 138 /* Delete a queue. It must be unused. */138 /* Delete a queue. It must be empty. */ 139 139 int fd_fifo_del ( struct fifo ** queue ) 140 140 { 141 141 struct fifo * q; 142 int loops = 0; 142 143 143 144 TRACE_ENTRY( "%p", queue ); … … 149 150 CHECK_POSIX( pthread_mutex_lock( &q->mtx ) ); 150 151 151 if ((q->count != 0) || (q->thrs != 0) || (q->data != NULL)) { 152 TRACE_DEBUG(INFO, "The queue cannot be destroyed (%d, %d, %p)", q->count, q->thrs, q->data); 152 /* Ok, now invalidate the queue */ 153 q->eyec = 0xdead; 154 155 if ((q->count != 0) || (q->data != NULL)) { 156 TRACE_DEBUG(INFO, "The queue cannot be destroyed (%d, %p)", q->count, q->data); 153 157 CHECK_POSIX_DO( pthread_mutex_unlock( &q->mtx ), /* no fallback */ ); 154 158 return EINVAL; 155 159 } 156 160 161 while (q->thrs) { 162 CHECK_POSIX( pthread_cond_signal(&q->cond) ); 163 CHECK_POSIX( pthread_mutex_unlock( &q->mtx )); 164 pthread_yield(); 165 CHECK_POSIX( pthread_mutex_lock( &q->mtx ) ); 166 ASSERT( ++loops < 10 ); /* detect infinite loops */ 167 } 168 157 169 /* sanity check */ 158 170 ASSERT(FD_IS_LIST_EMPTY(&q->list)); 159 160 /* Ok, now invalidate the queue */161 q->eyec = 0xdead;162 171 163 172 /* And destroy it */ … … 379 388 awaken: 380 389 /* Check queue status */ 390 if (!CHECK_FIFO( queue )) { 391 /* The queue is being destroyed */ 392 CHECK_POSIX( pthread_mutex_unlock( &queue->mtx ) ); 393 TRACE_DEBUG(FULL, "The queue is being destroyed -> EPIPE"); 394 return EPIPE; 395 } 396 381 397 if (queue->count > 0) { 382 398 /* There are items in the queue, so pick the first one */
Note: See TracChangeset
for help on using the changeset viewer.