You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/08 17:15:21 UTC

[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #2488: libs/libc: correct the getrandom(2) prototype

patacongo edited a comment on pull request #2488:
URL: https://github.com/apache/incubator-nuttx/pull/2488#issuecomment-740772533


   > But now you directly ignore the error at all, could you tell me how can the caller handle these error case securely?
   > 
   >     1. nxsem_wait_uninterruptible return fail
   >    ...
   
   From #2497 
   
   getrandom() is not a cancellation point and must not implement any cancellation point logic. It should not use nxsem_wait_uninterruptible() but should use something like nxsem_wait_noncancelable(). nxsem_wait-noncancelable() has not been formalized but would simply ignore the ECANCELED error (as well as the EINTR error).
   
   In that case, getrandom would correctly ignore the cancellation request and simply call nxsem_wait() again.
   
   ECANCELED should only occur in the deferred cancellation mode. In other modes, the task calling getrandom() will be terminated immediately with no return value. (I think anyway. I haven't looked at the code in a long time). In the deferred cancellation mode, cancellation can only occur at a few cancellation points; getrandom() is not a cancellatoin point.
   
   In normal usage, ECANCELED is never seen by the application code.  It is either not generated or is handled by the lower level cancellation point (which getrandom() is not).  Hence, there is no need to return the ECANCELED error code.
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org