Override TemporaryFile's default move constructor
Summary: A default move constructor/move assignment operator caused a bunch of bugs in my test that was depending on the move constructor to either not close the underlying file descriptor or to ensure that the TemporaryFile object doesn't have a dangling reference to a file descriptor that has already been closed. The current implementation caused both the moved' from and to object to share the same underlying file descriptor and when the former object is destroyed it ends up closing the file descriptor leaving the latter with a dangling file descriptor which could be reused for some other socket(s)/file descriptor by the kernel and ends up causing seg-faults when the latter object is eventually destroyed due to it releasing a file descriptor that now belongs to some other resource. I changed the move constructor/move assignment operator to have the former semantics to not close the underlying file descriptor of the move'd from object (by releasing it and assigning it to the move'd to object). I am not sure if anyone would ever want the alternative semantics because the TemporaryFile object would not be usable without a valid underlying file descriptor Reviewed By: yfeldblum Differential Revision: D6182075 fbshipit-source-id: bc809d704449c1c1182d76cdfa2f7d17b38a719a
Showing
Please register or sign in to comment