Merge "Return the correct error code in multi-thread mode"