SNTP_oneshot mistakenly return RTCS_OK

cancel
Showing results for 
Search instead for 
Did you mean: 

SNTP_oneshot mistakenly return RTCS_OK

Jump to solution
144 Views
NXP Employee
NXP Employee

MQX 4.2

I think I found a bug in SNTP_oneshot().  By accident SNTP_oneshot() returns RTCS_OK while NTP server is not reachable. 

If the TPC/IP is very busy, the select function will return RTCS_ERROR because RTCSCMD_issue can't alloc a message from queue pool. Then the err is not zero, it causes a wrong RTCS_OK return value.

static uint32_t  SNTP_timed_send_recv

   (

      uint32_t sock,

         /*[IN] socket */

      _ip_address  *destination,

         /*[IN] remote IP NTP service */

      uint32_t  *msec_count_ptr

         /*[IN] millisecond timeout value */

   )

{ /* Body */

………………………………………..

 

   /* Accept only correct replies */

   do  {

………………………………………………… 

      RTCS_FD_ZERO(&rfds);

      RTCS_FD_SET(sock, &rfds);

      err = select(1, &rfds, NULL, NULL, timeout);

 

      if(RTCS_ERROR ==  err)

      {

          break;

      }

 

…………………………………….

   } while (msec_count > 0);

 

   *msec_count_ptr = msec_count;

   if (err == 0) {

      error_code = RTCSERR_TIMEOUT;

   } else  {

      error_code = RTCS_OK;

   } /* Endif */

 

   return error_code;

} /* Endbody */

Labels (1)
Tags (3)
0 Kudos
1 Solution
35 Views
NXP TechSupport
NXP TechSupport

Hi S.z:

Thanks you for your feedback. I would suggest you change 'break' to 'continue', this maybe fix this issue. 

Regards

Daniel

View solution in original post

0 Kudos
1 Reply
36 Views
NXP TechSupport
NXP TechSupport

Hi S.z:

Thanks you for your feedback. I would suggest you change 'break' to 'continue', this maybe fix this issue. 

Regards

Daniel

View solution in original post

0 Kudos