coap_can_exit(): check if all data is dispatched

small fixes in ordering operators
This commit is contained in:
Olaf Bergmann committed 2010-07-12 23:51:50 +02:00
1 parent 72500fa297
commit 4fe0a6459f
2 files changed
+14 -5

No files matched your search

+11 -5
View File
@@ -128,7 +128,7 @@ coap_insert_node(coap_queue_t **queue, coap_queue_t *node,
/* replace queue head if PDU's time is less than head's time */
q = *queue;
if ( order( node, q ) ) {
if ( order( node, q ) < 0) {
node->next = q;
*queue = node;
return 1;
@@ -138,7 +138,7 @@ coap_insert_node(coap_queue_t **queue, coap_queue_t *node,
do {
p = q;
q = q->next;
} while ( q && ! order( node, q ) );
} while ( q && order( node, q ) >= 0 );
/* insert new item */
node->next = q;
@@ -322,7 +322,7 @@ coap_send( coap_context_t *context, const struct sockaddr_in6 *dst, coap_pdu_t *
int
_order_timestamp( coap_queue_t *lhs, coap_queue_t *rhs ) {
return lhs && rhs && ( lhs->t < rhs->t );
return lhs && rhs && ( lhs->t < rhs->t ) ? -1 : 1;
}
coap_tid_t
@@ -380,8 +380,10 @@ coap_retransmit( coap_context_t *context, coap_queue_t *node ) {
int
_order_transaction_id( coap_queue_t *lhs, coap_queue_t *rhs ) {
return lhs && rhs && lhs->pdu && rhs->pdu &&
( lhs->pdu->hdr->id < lhs->pdu->hdr->id );
return ( lhs && rhs && lhs->pdu && rhs->pdu &&
( lhs->pdu->hdr->id < lhs->pdu->hdr->id ) )
? -1
: 1;
}
int
@@ -521,4 +523,8 @@ coap_register_message_handler( coap_context_t *context, coap_message_handler_t h
context->msg_handler = (void (*)( void *, coap_queue_t *, void *)) handler;
}
int
coap_can_exit( coap_context_t *context ) {
return !context || (context->recvqueue == NULL && context->sendqueue == NULL);
}
+3
View File
@@ -98,4 +98,7 @@ int coap_remove_transaction( coap_queue_t **queue, coap_tid_t id );
/** Dispatches the PDUs from the receive queue in given context. */
void coap_dispatch( coap_context_t *context );
/** Returns 1 if there are no messages to send or to dispatch in the context's queues. */
int coap_can_exit( coap_context_t *context );
#endif /* _COAP_NET_H_ */