If that's the case, shouldn't it be write_timeout_constant in both lines, rather than write_timeout_multiplier in the second?

AFAICT, it should be write_timeout_constant + (write_timeout_multiplier * expected_bytes), with that resulting milliseconds value _then_ converted to timeval via the div/mod procedure. In any case, that's what the proposed replacement logic does.