Ejemplo n.º 1
0
static int
owqueue_signal_read
(
	OWQueue * queue
)
{
	OWQueueEvent event = 0 ;
	if (pthread_mutex_lock (& queue->state_mutex))
	{
		return -1 ;
	}
	if (owqueue_is_empty (queue))
	{
		queue->is_empty = 1 ;
		event |= OWQUEUE_EMPTY ;
	}
	if (queue->space_needed <= owqueue_get_available_space (queue))
	{
		queue->space_needed = 0 ;
		event |= OWQUEUE_SPACE_AVAILABLE ;
	}
	if (event != 0 && queue->callback_function != NULL)
	{
		queue->callback_function (queue, event, (void *) queue->callback_user_data) ;
	}
	if (pthread_mutex_unlock (& queue->state_mutex))
	{
		return -1 ;
	}
	return 0 ;
}
Ejemplo n.º 2
0
int
owsl_socket_is_readable
(
	OWSLSocketInfo * socket
)
{
	return
	(
		(
			socket->type_info->mode == OWSL_MODE_DATAGRAM
			||
			socket->connected > 0
			||
			socket->listening > 0
		)
		&&
		(
			socket->in_queue == NULL
			||
			! owqueue_is_empty (socket->in_queue)
		)
		&&
		(
			socket->type_info->is_readable == NULL
			||
			socket->type_info->is_readable (socket)
		)
	) ;
}
Ejemplo n.º 3
0
static int
owqueue_signal_empty
(
	OWQueue * queue
)
{
	if (pthread_mutex_lock (& queue->state_mutex))
	{
		return -1 ;
	}
	if (owqueue_is_empty (queue))
	{
		queue->is_empty = 1 ;
		if (queue->callback_function != NULL)
		{
			queue->callback_function (queue, OWQUEUE_EMPTY, (void *) queue->callback_user_data) ;
		}
	}
	if (pthread_mutex_unlock (& queue->state_mutex))
	{
		return -1 ;
	}
	return 0 ;
}