Changeset 1186:56c36d1007b4 in freeDiameter for libfdproto
- Timestamp:
- Jun 7, 2013, 7:48:34 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/fifo.c
r1127 r1186 646 646 } 647 647 648 /* Test if data is available in the queue, without pulling it */ 649 int fd_fifo_select ( struct fifo * queue, const struct timespec *abstime ) 650 { 651 int ret = 0; 652 TRACE_ENTRY( "%p %p", queue, abstime ); 653 654 CHECK_PARAMS_DO( CHECK_FIFO( queue ), return -EINVAL ); 655 656 /* lock the queue */ 657 CHECK_POSIX_DO( pthread_mutex_lock( &queue->mtx ), return -__ret__ ); 658 659 awaken: 660 ret = (queue->count > 0 ) ? queue->count : 0; 661 if ((ret == 0) && (abstime != NULL)) { 662 /* We have to wait for a new item */ 663 queue->thrs++ ; 664 pthread_cleanup_push( fifo_cleanup, queue); 665 ret = pthread_cond_timedwait( &queue->cond_pull, &queue->mtx, abstime ); 666 pthread_cleanup_pop(0); 667 queue->thrs-- ; 668 if (ret == 0) 669 goto awaken; /* test for spurious wake-ups */ 670 671 if (ret == ETIMEDOUT) 672 ret = 0; 673 else 674 ret = -ret; 675 } 676 677 /* Unlock */ 678 CHECK_POSIX_DO( pthread_mutex_unlock( &queue->mtx ), return -__ret__ ); 679 680 return ret; 681 }
Note: See TracChangeset
for help on using the changeset viewer.