RFR: 8303942: os::write should write completely [v2]

Ioi Lam iklam at openjdk.org
Wed May 3 15:16:16 UTC 2023


On Wed, 3 May 2023 11:43:11 GMT, Afshin Zafari <duke at openjdk.org> wrote:

>> `os::write` is implemented using loops until the whole bytes are written. All uses of `os::write` in a loop are changed to single call. 
>> Platform dependent versions of the `os::write` are also renamed and moved to private sections accordingly.
>> Wrong uses/interpretations of return values from `os::write` in JFR code are corrected.
>> 
>> ###Test
>> local: hotspot tier1
>> mach5: tiers 1-5
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8303942: os::write should write completely

Can you update os.hpp to indicate that the buffer will be fully written? 

I would also request that the input size to be changed to size_t, to be consistent with the C library. There are too many dubious casting of size_t to int in the code.


#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t count);


Also, when an error happens, what is the returned value? Is it always negative. or will you return the number of partially written bytes?

For failures, I think returning the number of partially written bytes is not useful. The failure would be caused by an unrecoverable error, so you can't try to write the remaining bytes again (or else we are back to the original loop!). For simplicity, this function can simply return -1 to indicate failure, and 0 to indicate success.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13750#issuecomment-1533220365


More information about the hotspot-dev mailing list