You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Benjamin Bannier <be...@mesosphere.io> on 2019/02/23 20:41:00 UTC
Review Request 70046: Prevented closing invalid file descriptors.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/
-----------------------------------------------------------
Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
Repository: mesos
Description
-------
During the refactoring of `d838f2958e` we reorganized the code flow to
propagate failures from `os::close` and introduce code which migh
close an invalid file descriptor. While this would produce an `Error`
result from `mktemp` in any case, it would have lead to confusing
error messages in that scenario. This patch prevents closing invalid
file descriptors altogether which is consistent with the
pre-refactoring behavior.
Diffs
-----
3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
Diff: https://reviews.apache.org/r/70046/diff/1/
Testing
-------
`make check`
Thanks,
Benjamin Bannier
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Benjamin Mahler <bm...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/#review213186
-----------------------------------------------------------
Ship it!
Ship It!
- Benjamin Mahler
On Feb. 25, 2019, 9:19 p.m., Benjamin Bannier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70046/
> -----------------------------------------------------------
>
> (Updated Feb. 25, 2019, 9:19 p.m.)
>
>
> Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
>
>
> Repository: mesos
>
>
> Description
> -------
>
> During the refactoring of `d838f2958e` we reorganized the code flow to
> propagate failures from `os::close` and introduce code which migh
> close an invalid file descriptor. While this would produce an `Error`
> result from `mktemp` in any case, it would have lead to confusing
> error messages in that scenario. This patch prevents closing invalid
> file descriptors altogether which is consistent with the
> pre-refactoring behavior.
>
>
> Diffs
> -----
>
> 3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
>
>
> Diff: https://reviews.apache.org/r/70046/diff/2/
>
>
> Testing
> -------
>
> `make check`
>
>
> Thanks,
>
> Benjamin Bannier
>
>
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Benjamin Bannier <be...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/
-----------------------------------------------------------
(Updated Feb. 25, 2019, 10:19 p.m.)
Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
Changes
-------
Simplify code more as suggested by Ben
Repository: mesos
Description
-------
During the refactoring of `d838f2958e` we reorganized the code flow to
propagate failures from `os::close` and introduce code which migh
close an invalid file descriptor. While this would produce an `Error`
result from `mktemp` in any case, it would have lead to confusing
error messages in that scenario. This patch prevents closing invalid
file descriptors altogether which is consistent with the
pre-refactoring behavior.
Diffs (updated)
-----
3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
Diff: https://reviews.apache.org/r/70046/diff/2/
Changes: https://reviews.apache.org/r/70046/diff/1-2/
Testing
-------
`make check`
Thanks,
Benjamin Bannier
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Mesos Reviewbot <re...@mesos.apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/#review213124
-----------------------------------------------------------
Patch looks great!
Reviews applied: [70046]
Passed command: export OS='ubuntu:14.04' BUILDTOOL='autotools' COMPILER='gcc' CONFIGURATION='--verbose --disable-libtool-wrappers --disable-parallel-test-execution' ENVIRONMENT='GLOG_v=1 MESOS_VERBOSE=1'; ./support/docker-build.sh
- Mesos Reviewbot
On Feb. 23, 2019, 12:41 p.m., Benjamin Bannier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70046/
> -----------------------------------------------------------
>
> (Updated Feb. 23, 2019, 12:41 p.m.)
>
>
> Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
>
>
> Repository: mesos
>
>
> Description
> -------
>
> During the refactoring of `d838f2958e` we reorganized the code flow to
> propagate failures from `os::close` and introduce code which migh
> close an invalid file descriptor. While this would produce an `Error`
> result from `mktemp` in any case, it would have lead to confusing
> error messages in that scenario. This patch prevents closing invalid
> file descriptors altogether which is consistent with the
> pre-refactoring behavior.
>
>
> Diffs
> -----
>
> 3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
>
>
> Diff: https://reviews.apache.org/r/70046/diff/1/
>
>
> Testing
> -------
>
> `make check`
>
>
> Thanks,
>
> Benjamin Bannier
>
>
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Benjamin Bannier <be...@mesosphere.io>.
> On Feb. 25, 2019, 6:06 p.m., Benjamin Mahler wrote:
> > 3rdparty/stout/include/stout/os/posix/mktemp.hpp
> > Line 47 (original), 47 (patched)
> > <https://reviews.apache.org/r/70046/diff/1/?file=2126560#file2126560line47>
> >
> > Can we just simplify this by returning early?
> >
> > ```
> > if (fd < 0) {
> > return ErrnoError();
> > }
> >
> > Try<Nothing> close = os::close(fd);
> >
> > // We propagate `close` failures if creation of the temp file was successful.
> > if (close.isError()) {
> > return Error("Failed to close '" + stringify(fd) + "':" + close.error());
> > }
> >
> > return temp;
> > ```
> >
> > Seems easier to read as being correct too?
> >
> > Also, this lets `temp` become just `std::string` without the `Try`.
Much nicer solution, agreed!
I posted an additional cleanup as https://reviews.apache.org/r/70053/.
- Benjamin
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/#review213170
-----------------------------------------------------------
On Feb. 25, 2019, 10:19 p.m., Benjamin Bannier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70046/
> -----------------------------------------------------------
>
> (Updated Feb. 25, 2019, 10:19 p.m.)
>
>
> Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
>
>
> Repository: mesos
>
>
> Description
> -------
>
> During the refactoring of `d838f2958e` we reorganized the code flow to
> propagate failures from `os::close` and introduce code which migh
> close an invalid file descriptor. While this would produce an `Error`
> result from `mktemp` in any case, it would have lead to confusing
> error messages in that scenario. This patch prevents closing invalid
> file descriptors altogether which is consistent with the
> pre-refactoring behavior.
>
>
> Diffs
> -----
>
> 3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
>
>
> Diff: https://reviews.apache.org/r/70046/diff/2/
>
>
> Testing
> -------
>
> `make check`
>
>
> Thanks,
>
> Benjamin Bannier
>
>
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Benjamin Mahler <bm...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/#review213170
-----------------------------------------------------------
3rdparty/stout/include/stout/os/posix/mktemp.hpp
Line 47 (original), 47 (patched)
<https://reviews.apache.org/r/70046/#comment299040>
Can we just simplify this by returning early?
```
if (fd < 0) {
return ErrnoError();
}
Try<Nothing> close = os::close(fd);
// We propagate `close` failures if creation of the temp file was successful.
if (close.isError()) {
return Error("Failed to close '" + stringify(fd) + "':" + close.error());
}
return temp;
```
Seems easier to read as being correct too?
Also, this lets `temp` become just `std::string` without the `Try`.
- Benjamin Mahler
On Feb. 23, 2019, 8:41 p.m., Benjamin Bannier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70046/
> -----------------------------------------------------------
>
> (Updated Feb. 23, 2019, 8:41 p.m.)
>
>
> Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
>
>
> Repository: mesos
>
>
> Description
> -------
>
> During the refactoring of `d838f2958e` we reorganized the code flow to
> propagate failures from `os::close` and introduce code which migh
> close an invalid file descriptor. While this would produce an `Error`
> result from `mktemp` in any case, it would have lead to confusing
> error messages in that scenario. This patch prevents closing invalid
> file descriptors altogether which is consistent with the
> pre-refactoring behavior.
>
>
> Diffs
> -----
>
> 3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
>
>
> Diff: https://reviews.apache.org/r/70046/diff/1/
>
>
> Testing
> -------
>
> `make check`
>
>
> Thanks,
>
> Benjamin Bannier
>
>
Re: Review Request 70046: Prevented closing invalid file descriptors.
Posted by Mesos Reviewbot Windows <re...@mesos.apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70046/#review213123
-----------------------------------------------------------
PASS: Mesos patch 70046 was successfully built and tested.
Reviews applied: `['70046']`
All the build artifacts available at: http://dcos-win.westus2.cloudapp.azure.com/artifacts/mesos-reviewbot-testing/2926/mesos-review-70046
- Mesos Reviewbot Windows
On Feb. 23, 2019, 8:41 p.m., Benjamin Bannier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70046/
> -----------------------------------------------------------
>
> (Updated Feb. 23, 2019, 8:41 p.m.)
>
>
> Review request for mesos, Benjamin Mahler and Chun-Hung Hsiao.
>
>
> Repository: mesos
>
>
> Description
> -------
>
> During the refactoring of `d838f2958e` we reorganized the code flow to
> propagate failures from `os::close` and introduce code which migh
> close an invalid file descriptor. While this would produce an `Error`
> result from `mktemp` in any case, it would have lead to confusing
> error messages in that scenario. This patch prevents closing invalid
> file descriptors altogether which is consistent with the
> pre-refactoring behavior.
>
>
> Diffs
> -----
>
> 3rdparty/stout/include/stout/os/posix/mktemp.hpp 8dab2599f13c3e1dab109423c8a938ec16540aaf
>
>
> Diff: https://reviews.apache.org/r/70046/diff/1/
>
>
> Testing
> -------
>
> `make check`
>
>
> Thanks,
>
> Benjamin Bannier
>
>