Commit 9e78f4ac authored by Alessandro Rubini's avatar Alessandro Rubini

send functions: return -1 on error and 1 on stamping error (stamp invalid)

This is the first step to fix a problem introduced by commit 79ffd673
(a fix to release 4.1.2 forward ported to master).

When we get a bad timestamp in sending sync, we should not return "error"
but a special value for "no timestamp". Otherwise the caller goes to
"faulty" state and can't sync any more (this situation loops over).

Also, check for timestamp errors only for event message, or we break
out of the messaging loop during wr synchronization (when we get bad
timestamps for frames whose timestamp we don't care about).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 4c16bad8
......@@ -345,7 +345,11 @@ extern void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup);
extern void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req);
extern void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp);
/* each of them returns 0 if no error and -1 in case of error in send */
/* each of them returns 0 if ok, -1 in case of error in send, 1 if stamp err */
#define PP_SEND_OK 0
#define PP_SEND_ERROR -1
#define PP_SEND_NO_STAMP 1
extern int msg_issue_announce(struct pp_instance *ppi);
extern int msg_issue_sync_followup(struct pp_instance *ppi);
extern int msg_issue_delay_req(struct pp_instance *ppi);
......
......@@ -42,15 +42,15 @@ static inline int __send_and_log(struct pp_instance *ppi, int msglen,
&ppi->last_snt_time, chtype, 0) < msglen) {
pp_diag(ppi, frames, 1, "%s(%d) Message can't be sent\n",
pp_msg_names[msgtype], msgtype);
return -1;
return PP_SEND_ERROR;
}
/* FIXME: diagnosticst should be looped back in the send method */
pp_diag(ppi, frames, 1, "SENT %02d bytes at %d.%09d (%s)\n", msglen,
(int)(ppi->last_snt_time.seconds),
(int)(ppi->last_snt_time.nanoseconds),
pp_msg_names[msgtype]);
if (ppi->last_snt_time.correct == 0)
return -1;
if (chtype == PP_NP_EVT && ppi->last_snt_time.correct == 0)
return PP_SEND_NO_STAMP;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment