core/executor: avoid double closing serialization fd
authorMike Yuan <me@yhndnzj.com>
Wed, 29 Nov 2023 15:18:23 +0000 (23:18 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 30 Nov 2023 09:56:59 +0000 (09:56 +0000)
commit79bad078bb9403aab6a9c45bf4769e684bdc3f59
treeeb0ec608a0c179109913838ca36f8423405855e1
parent2292d377a2911382ffe24fad2e4c67a5999257b9
core/executor: avoid double closing serialization fd

Before this commit, between fdopen() (in parse_argv()) and fdset_remove(),
the serialization fd is owned by both arg_serialization FILE stream and fdset.
Therefore, if something wrong happens between the two calls, or if --deserialize=
is specified more than once, we end up closing the serialization fd twice.
Normally this doesn't matter much, but I still think it's better to fix this.

Let's call fdset_new_fill() after parsing serialization fd hence.
We set the fd to CLOEXEC in parse_argv(), so it will be filtered
when the fdset is created.

While at it, also move fdset_new_fill() under the second log_open(), so
that we always log to the log target specified in arguments.
src/core/executor.c