Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Aug 14, 2023
1 parent c82bc4c commit 6dacb4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 9 additions & 7 deletions libudpard/udpard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,23 +1698,25 @@ int_fast8_t udpardRxSubscriptionReceive(struct UdpardRxSubscription* const self,
const uint_fast8_t redundant_iface_index,
struct UdpardRxTransfer* const out_transfer)
{
bool release = true;
int_fast8_t result = -UDPARD_ERROR_ARGUMENT;
int_fast8_t result = -UDPARD_ERROR_ARGUMENT;
if ((self != NULL) && (timestamp_usec != TIMESTAMP_UNSET) && (datagram_payload.data != NULL) &&
(redundant_iface_index < UDPARD_NETWORK_INTERFACE_COUNT_MAX) && (out_transfer != NULL))
{
result = rxPortAcceptFrame(&self->port,
result = rxPortAcceptFrame(&self->port,
redundant_iface_index,
timestamp_usec,
datagram_payload,
self->memory,
out_transfer);
release = false;
}
if ((self != NULL) && release)
else if (self != NULL)
{
memFreePayload(self->memory.payload, datagram_payload);
}
else
{
(void) 0;
}
return result;
}

Expand Down Expand Up @@ -1827,13 +1829,13 @@ int_fast8_t udpardRxRPCDispatcherReceive(struct UdpardRxRPCDispatcher* const sel
self->memory,
&out_transfer->base);
release = false;
}
} // else, the application is not interested in this service-ID (does not know how to handle it).
// Expose the port instance to the caller if requested.
if (out_port != NULL)
{
*out_port = item;
}
}
} // else, we didn't accept so we just ignore this frame
}
if ((self != NULL) && release)
{
Expand Down
6 changes: 5 additions & 1 deletion libudpard/udpard.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ void udpardRxSubscriptionFree(struct UdpardRxSubscription* const self);
/// fragment of the reassembled transfer payload or free it using the corresponding memory resource
/// (see UdpardRxMemoryResources) if the datagram is not needed for reassembly. Because of the ownership transfer,
/// the datagram payload buffer has to be mutable (non-const).
/// In the case of an invalid argument error the library will attempt to free the datagram payload buffer.
/// One exception is that if the "self" pointer is invalid, the library will be unable to process or free the datagram,
/// which may lead to a memory leak in the application; hence, the caller should always check that the "self" pointer
/// is always valid.
///
/// The accepted datagram may either be invalid, carry a non-final part of a multi-frame transfer,
/// carry a final part of a valid multi-frame transfer, or carry a valid single-frame transfer.
Expand Down Expand Up @@ -1021,6 +1023,8 @@ int_fast8_t udpardRxRPCDispatcherCancel(struct UdpardRxRPCDispatcher* const self
/// It is the analog of udpardRxSubscriptionReceive for RPC-service transfers.
/// Please refer to the documentation of udpardRxSubscriptionReceive for the usage information.
///
/// Frames (datagrams) that belong to transfers for which there is no active RX RPC port are ignored.
///
/// The "out_port" pointer-to-pointer can be used to retrieve the specific UdpardRxRPCPort instance that was used to
/// process the received transfer. Remember that each UdpardRxRPCPort instance has a user reference field,
/// which in combination with this feature can be used to construct OOP interfaces on top of the library.
Expand Down

0 comments on commit 6dacb4e

Please sign in to comment.