file: Only release file after being under the table lock
file: Only release file after being under the table lock

Also refactored dup2/3 and fixed a minor issue.

Signed-off-by: Pedro Falcato <d037c3eb54456eb57a351d3e1361e11b3d89c857@gmail.com>

heatd/Onyx,heatd/Onyx,heatd/Onyx,heatd/Onyx