From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Twhtf-0003ds-PQ for qemu-devel@nongnu.org; Sat, 19 Jan 2013 18:32:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Twhte-0007JI-KF for qemu-devel@nongnu.org; Sat, 19 Jan 2013 18:32:23 -0500 Received: from moutng.kundenserver.de ([212.227.126.171]:63565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Twhte-0007JC-9V for qemu-devel@nongnu.org; Sat, 19 Jan 2013 18:32:22 -0500 Message-ID: <1358638333.3091.3.camel@Quad> From: Laurent Vivier Date: Sun, 20 Jan 2013 00:32:13 +0100 In-Reply-To: <1357064651-30072-1-git-send-email-laurent@vivier.eu> References: <1356983610-14793-1-git-send-email-laurent@vivier.eu> <1357064651-30072-1-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH][v2] linux-user: correct setsockopt() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , qemu-devel@nongnu.org ping ? Le mardi 01 janvier 2013 =C3=A0 19:24 +0100, Laurent Vivier a =C3=A9crit : > From: Laurent Vivier >=20 > SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int >=20 > To test this, you can use : >=20 > QEMU_STRACE=3D ping localhost 2>&1 |grep TIMEO > 568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) =3D 0 > 568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) =3D 0 >=20 > Signed-off-by: Laurent Vivier > --- > v2: pass checkpatch.pl >=20 > linux-user/syscall.c | 28 ++++++++++++++++++++++------ > 1 file changed, 22 insertions(+), 6 deletions(-) >=20 > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index e99adab..2b2bd2b 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -1491,6 +1491,28 @@ static abi_long do_setsockopt(int sockfd, int leve= l, int optname, > break; > case TARGET_SOL_SOCKET: > switch (optname) { > + case TARGET_SO_RCVTIMEO: > + { > + struct timeval tv; > + > + optname =3D SO_RCVTIMEO; > + > +set_timeout: > + if (optlen !=3D sizeof(struct target_timeval)) { > + return -TARGET_EINVAL; > + } > + > + if (copy_from_user_timeval(&tv, optval_addr)) { > + return -TARGET_EFAULT; > + } > + > + ret =3D get_errno(setsockopt(sockfd, SOL_SOCKET, optname= , > + &tv, sizeof(tv))); > + return ret; > + } > + case TARGET_SO_SNDTIMEO: > + optname =3D SO_SNDTIMEO; > + goto set_timeout; > /* Options with 'int' argument. */ > case TARGET_SO_DEBUG: > optname =3D SO_DEBUG; > @@ -1542,12 +1564,6 @@ static abi_long do_setsockopt(int sockfd, int leve= l, int optname, > case TARGET_SO_RCVLOWAT: > optname =3D SO_RCVLOWAT; > break; > - case TARGET_SO_RCVTIMEO: > - optname =3D SO_RCVTIMEO; > - break; > - case TARGET_SO_SNDTIMEO: > - optname =3D SO_SNDTIMEO; > - break; > break; > default: > goto unimplemented; --=20 "Just play. Have fun. Enjoy the game." - Michael Jordan "Just play. Have fun. Enjoy the game." - Michael Jordan