Skip to content

Commit

Permalink
port: Convey targeted forwarding errors to the caller.
Browse files Browse the repository at this point in the history
The port_forward_to() method clobbers the specific error code returned
by the transport layer with -1.  This patch lets the code preserve the
specific error in question.

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed May 24, 2020
1 parent a6e0b83 commit 5aa19dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions port.c
Original file line number Diff line number Diff line change
Expand Up @@ -2737,8 +2737,10 @@ int port_forward_to(struct port *p, struct ptp_message *msg)
{
int cnt;
cnt = transport_sendto(p->trp, &p->fda, TRANS_GENERAL, msg);
if (cnt <= 0) {
return -1;
if (cnt < 0) {
return cnt;
} else if (!cnt) {
return -EIO;
}
port_stats_inc_tx(p, msg);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion port.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int port_forward(struct port *p, struct ptp_message *msg);
* Forward a message on a given port to the address stored in the message.
* @param port A pointer previously obtained via port_open().
* @param msg The message to send. Must be in network byte order.
* @return Zero on success, non-zero otherwise.
* @return Zero on success, negative errno value otherwise.
*/
int port_forward_to(struct port *p, struct ptp_message *msg);

Expand Down

0 comments on commit 5aa19dd

Please sign in to comment.