thread patches

try to reopen file if open failed, respecting given timeout value