Hi,

I've noticed some weird behavior of the setsockopt(2) system call.

Given the following little test program ...

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


#include <err.h>
#include <stdio.h>

#include <sys/socket.h>

int
main(int argc, char *argv[])
{
        int              fd[2];
        struct timeval   t = { .tv_sec = 650, .tv_usec = 0 };

        if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, fd) == -1)
                err(1, "socketpair");

        while (1) {
                if (setsockopt(fd[0], SOL_SOCKET, SO_RCVTIMEO, &t,
                    sizeof(t)) == -1)
                        err(1, "setsockopt");

                printf("%llu: OK.\n", t.tv_sec++);
        }

        return (0);
}

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

... this is the output:

# ./test
650: OK.
651: OK.
652: OK.
653: OK.
654: OK.
655: OK.
test: setsockopt: Numerical argument out of domain
#

Does anybody know why tv_sec=656 an illegal value for SO_RCVTIMEO while
655 still appears to be alright? I was expecting this to happen for much
larger tv_sec values, something like ULLONG_MAX / 1000000000ULL.

I was using an amd64 machine running 6.6-stable to compile and run the
test code.

Any help is being appreciated.

Matthias


Reply via email to