bitwiseworks / libc

LIBC Next (kLIBC fork)
9 stars 4 forks source link

readv() writev() #126

Closed SilvanScherrer closed 1 year ago

SilvanScherrer commented 1 year ago

both use if (iovcnt <= 0 || iovcnt > 16) which might be ok. But IOV_MAX itself is defined with 1024 in syslimits.h. This seems inconsistent to me.

dmik commented 1 year ago

We should definitely change readv and writev to use IOV_MAX instead of a hard-coded value, as per Posix.

dmik commented 1 year ago

This is the original Silvan's ticket that describes where he faced it: http://trac.netlabs.org/ports/ticket/11.

SilvanScherrer commented 1 year ago

see also for needed changes bevore the above fix https://github.com/bitwiseworks/libuv-os2/commit/ac6be5dce0484bf8a6f188a906784b3d40db2437

komh commented 1 year ago

IOV_MAX which is 1024 is too big. In case of a socket, it may worse a performance if very large datum is passed. Because if total size of daum is bigger than buffer size of OS/2 socket(default 32768), then unnecessary buffer concatenation overhead of remaining datum occurs.

Anyway, any other macros for the same purpose are defined to 16. It would be better that IOV_MAX also has the same value.

limits.h:#define        _XOPEN_IOV_MAX          16
sys/socket.h:#define    MSG_MAXIOVLEN   16