> On Sept. 8, 2017, 7:43 a.m., Qian Zhang wrote:
> > src/slave/containerizer/mesos/isolators/network/ports.cpp
> > Line 112 (original), 112 (patched)
> > <https://reviews.apache.org/r/60495/diff/13-15/?file=1808218#file1808218line112>
> >
> >     Why do we need a `for` loop like this? I think the previous `while` 
> > loop is good enough.

If we want to depend on `errno`, we need to guarantee that it is `0` before we 
call the `readddir`. Since there is non-trivial logic inside the loop, it is 
difficult to be confident that nothing we call is going to change it, 
particularly if this code is ever updated.


> On Sept. 8, 2017, 7:43 a.m., Qian Zhang wrote:
> > src/slave/containerizer/mesos/isolators/network/ports.cpp
> > Line 124 (original), 125 (patched)
> > <https://reviews.apache.org/r/60495/diff/13-15/?file=1808218#file1808218line125>
> >
> >     This seems too strict, since here we are already going to return an 
> > error out, I think we can simply ignore the error of `closedir()`.

The only way `closedir` can fail is if we give it a bad pointer, so if we check 
this I think `CHECK` is appropriate. I don't understand the rationale of 
wanting to check the `readdir` but not the `closedir` since the error 
conditions for these are identical.


> On Sept. 8, 2017, 7:43 a.m., Qian Zhang wrote:
> > src/slave/containerizer/mesos/isolators/network/ports.cpp
> > Lines 144 (patched)
> > <https://reviews.apache.org/r/60495/diff/13-15/?file=1808218#file1808218line144>
> >
> >     Better to change this to:
> >     ```
> >       if (closedir(dir) == -1) {
> >         return ErrnoError("Failed to close directory '" + fdPath + "'");
> >       }
> >     ```
> >     This is also aligned with how you handle the error of `opendir()` in 
> > the above.

I don't understand why we want to check the error return for this one but not 
the others. Since the `closedir` can't fail, IMHO we should just either assert 
or ignore it consistently.


- James


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/60495/#review184953
-----------------------------------------------------------


On Sept. 7, 2017, 9:50 p.m., James Peach wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/60495/
> -----------------------------------------------------------
> 
> (Updated Sept. 7, 2017, 9:50 p.m.)
> 
> 
> Review request for mesos, Qian Zhang and Jiang Yan Xu.
> 
> 
> Bugs: MESOS-7675
>     https://issues.apache.org/jira/browse/MESOS-7675
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Implemented network ports isolator socket utilities to find the
> inode numbers of all the listening sockets, and the inodes of the
> open sockets for a process. Together, these utilities can tell us
> which sockets a process is listening on.
> 
> 
> Diffs
> -----
> 
>   src/slave/containerizer/mesos/isolators/network/ports.hpp PRE-CREATION 
>   src/slave/containerizer/mesos/isolators/network/ports.cpp PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/60495/diff/15/
> 
> 
> Testing
> -------
> 
> make check (Fedora 26)
> 
> 
> Thanks,
> 
> James Peach
> 
>

Reply via email to