fjpanag commented on PR #9497:
URL: https://github.com/apache/nuttx/pull/9497#issuecomment-1600700892

   I get it now.
   
   The thing is that `fdcheck_restore()` does not know if it operates on a raw 
or a protected descriptor.
   
   I believe that the first thing to do is fix this.  
   For example, when `fdcheck_protect()` protects an fd, it can set a flag 
(let's say set bit 31).  
   Then `fdcheck_restore()` can check if this flag is set (and thus if the fd 
is actually protected), and act accordingly.
   
   As a first defense, `fdcheck_restore()` should raise an error when it is 
passed an unprotected fd.  
   This would have saved a lot of time when troubleshooting this specific 
issue.  
   Users will immediately be informed about the wrong use (or at least the 
limitations) of `fdcheck_restore()`.
   
   As a second step, in these cases `fdcheck_restore()` can return an invalid 
fd so, code like the one mentioned above may work correctly? I am still 
experimenting with this.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to