You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Michael Park (JIRA)" <ji...@apache.org> on 2016/05/24 21:26:12 UTC

[jira] [Updated] (MESOS-5237) The windows version of `os::access` has differing behavior than the POSIX version.

     [ https://issues.apache.org/jira/browse/MESOS-5237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Park updated MESOS-5237:
--------------------------------
    Description: 
The POSIX version of {{os::access}} looks like this:

{code}
inline Try<bool> access(const std::string& path, int how)
{
  if (::access(path.c_str(), how) < 0) {
    if (errno == EACCES) {
      return false;
    } else {
      return ErrnoError();
    }
  }
  return true;
}
{code}

Compare this to the Windows version of {{os::access}} which looks like this following:

{code}
inline Try<bool> access(const std::string& fileName, int how)
{
  if (::_access(fileName.c_str(), how) != 0) {
    return ErrnoError("access: Could not access path '" + fileName + "'");
  }

  return true;
}
{code}

As we can see, the case where {{errno}} is set to {{EACCES}} is handled differently between the 2 functions.

We can actually consolidate the 2 functions by simply using the POSIX version. The challenge is that on POSIX, we should use {{::access}} and {{::_access}} on Windows. Note however, that this problem is already solved, as we have an implementation of {{::access}} for Windows in {{3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp}} which simply defers to {{::_access}}.

Thus, I propose to simply consolidate the 2 implementations.

  was:
The POSIX version of {{os::access}} looks like this:

{code}
inline Try<bool> access(const std::string& path, int how)
{
  if (::access(path.c_str(), how) < 0) {
    if (errno == EACCES) {
      return false;
    } else {
      return ErrnoError();
    }
  }
  return true;
}
{code}

Compare this to the Windows version of {{os::access}} which looks like this following:

{code}
inline Try<bool> access(const std::string& fileName, int how)
{
  if (::_access(fileName.c_str(), how) != 0) {
    return ErrnoError("access: Could not access path '" + fileName + "'");
  }

  return true;
}
{code}

As we can see, the case where {{errno}} is set to {{EACCES}} is handled differently between the 2 functions.

We can actually consolidate the 2 functions by simply using the POSIX version. The challenge is that on POSIX, we should use {{::access}} and {{_::access}} on Windows. Note however, that this problem is already solved, as we have an implementation of {{::access}} for Windows in {{3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp}} which simply defers to {{::_access}}.

Thus, I propose to simply consolidate the 2 implementations.


> The windows version of `os::access` has differing behavior than the POSIX version.
> ----------------------------------------------------------------------------------
>
>                 Key: MESOS-5237
>                 URL: https://issues.apache.org/jira/browse/MESOS-5237
>             Project: Mesos
>          Issue Type: Bug
>          Components: stout
>            Reporter: Michael Park
>            Assignee: Michael Park
>              Labels: mesosphere,, windows
>
> The POSIX version of {{os::access}} looks like this:
> {code}
> inline Try<bool> access(const std::string& path, int how)
> {
>   if (::access(path.c_str(), how) < 0) {
>     if (errno == EACCES) {
>       return false;
>     } else {
>       return ErrnoError();
>     }
>   }
>   return true;
> }
> {code}
> Compare this to the Windows version of {{os::access}} which looks like this following:
> {code}
> inline Try<bool> access(const std::string& fileName, int how)
> {
>   if (::_access(fileName.c_str(), how) != 0) {
>     return ErrnoError("access: Could not access path '" + fileName + "'");
>   }
>   return true;
> }
> {code}
> As we can see, the case where {{errno}} is set to {{EACCES}} is handled differently between the 2 functions.
> We can actually consolidate the 2 functions by simply using the POSIX version. The challenge is that on POSIX, we should use {{::access}} and {{::_access}} on Windows. Note however, that this problem is already solved, as we have an implementation of {{::access}} for Windows in {{3rdparty/libprocess/3rdparty/stout/include/stout/windows.hpp}} which simply defers to {{::_access}}.
> Thus, I propose to simply consolidate the 2 implementations.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)