Added lock around fd/file_id manipulation.