Skip to content

Commit

Permalink
Fixed getsockopt for time values
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh authored and d3m3vilurr committed Sep 12, 2023
1 parent 5259c80 commit a13cf8c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion newlib/libc/sys/vita/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,27 @@ int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
return -1;
}

int res = sceNetGetsockopt(fdmap->sce_uid, level, optname, optval, (unsigned int *)optlen);
int res;
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)
{
if (optlen < sizeof(struct timeval))
{
__vita_fd_drop(fdmap);
errno = EINVAL;
return -1;
}

int wait = 0;
unsigned int sce_optlen = sizeof(wait);
res = sceNetGetsockopt(fdmap->sce_uid, level, optname, &wait, &sce_optlen);

*optlen = sizeof(struct timeval);
struct timeval *timeout = optval;
timeout->tv_sec = wait / 1000000;
timeout->tv_usec = wait % 1000000;
} else {
res = sceNetGetsockopt(fdmap->sce_uid, level, optname, optval, (unsigned int *)optlen);
}

__vita_fd_drop(fdmap);

Expand Down

0 comments on commit a13cf8c

Please sign in to comment.