dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog support/socket.c


From: Radek Polak
Subject: [dotgnu-pnet-commits] pnet ChangeLog support/socket.c
Date: Mon, 22 Oct 2007 08:20:21 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnet
Changes by:     Radek Polak <radekp>    07/10/22 08:20:21

Modified files:
        .              : ChangeLog 
        support        : socket.c 

Log message:
        implement recieve and send timouts socket options

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3510&r2=1.3511
http://cvs.savannah.gnu.org/viewcvs/pnet/support/socket.c?cvsroot=dotgnu-pnet&r1=1.27&r2=1.28

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3510
retrieving revision 1.3511
diff -u -b -r1.3510 -r1.3511
--- ChangeLog   22 Oct 2007 04:41:46 -0000      1.3510
+++ ChangeLog   22 Oct 2007 08:20:21 -0000      1.3511
@@ -1,5 +1,10 @@
 2007-10-22  Radek Polak  <address@hidden>
 
+       * support/socket.c: Implement recieve and send timeouts socket
+       options. This fixes bug #18785.
+
+2007-10-22  Radek Polak  <address@hidden>
+
        * engine/debugger.c: Dump information whether image contains entry
        point.
 

Index: support/socket.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/support/socket.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- support/socket.c    25 Nov 2006 18:11:52 -0000      1.27
+++ support/socket.c    22 Oct 2007 08:20:21 -0000      1.28
@@ -1017,13 +1017,40 @@
 {
 #ifdef HAVE_SETSOCKOPT
        ILInt32 nativeLevel, nativeName;
+       int optlen;
+#ifdef IL_WIN32_NATIVE
+       ILInt32 optval;
+#else
+       union
+       {
+               ILInt32 value;
+               struct timeval timeout;
+       } optval;
+#endif
+
        if(SocketOptionsToNative(level, name, &nativeLevel,&nativeName)==0)
        {
                ILSysIOSetErrno(IL_ERRNO_EINVAL);
                return 0;
        }
+#ifdef IL_WIN32_NATIVE
+       optlen = sizeof(optval);
+       optval = value;
+#else
+       if(name == IL_SO_SEND_TIMEOUT || name == IL_SO_RECV_TIMEOUT)
+       {
+               optlen = sizeof(optval.timeout);
+               optval.timeout.tv_sec = value / 1000;
+               optval.timeout.tv_usec = (value % 1000) * 1000;
+       }
+       else
+       {
+               optlen = sizeof(optval.value);
+               optval.value = value;
+       }
+#endif 
        return (setsockopt((int)(ILNativeInt)sockfd,nativeLevel,nativeName,
-                       (void *)&value, sizeof(value))== 0);
+                       (void *)&optval, optlen)== 0);
 #else
        ILSysIOSetErrno(IL_ERRNO_EINVAL);
        return 0;
@@ -1034,24 +1061,58 @@
                                                   ILInt32 name, ILInt32 *value)
 {
 #ifdef HAVE_GETSOCKOPT
-       int option = 0;
-       int len=sizeof(ILInt32);
        ILInt32 nativeLevel, nativeName;
+       int optlen;
+#ifdef IL_WIN32_NATIVE
+       ILInt32 optval;
+#else
+       union
+       {
+               ILInt32 value;
+               struct timeval timeout;
+       } optval;
+#endif
+
        if(SocketOptionsToNative(level, name, &nativeLevel,&nativeName)==0)
        {
                ILSysIOSetErrno(IL_ERRNO_EINVAL);
                return 0;
        }
-       if(getsockopt((int)(ILNativeInt)sockfd,nativeLevel,nativeName,
-                                                               (void 
*)&option,&len) == 0)
+
+#ifdef IL_WIN32_NATIVE
+       optlen = sizeof(optval);
+#else
+       if(name == IL_SO_SEND_TIMEOUT || name == IL_SO_RECV_TIMEOUT)
        {
-               *value = (ILInt32)option;
-               return 1;
+               optlen = sizeof(optval.timeout);
        }
        else
        {
+               optlen = sizeof(optval.value);
+       }
+#endif 
+
+       if(getsockopt((int)(ILNativeInt)sockfd,nativeLevel,nativeName,
+                                                               (void 
*)&optval,&optlen) != 0)
+       {
                return 0;
        }
+
+#ifdef IL_WIN32_NATIVE
+       *value = optval;
+#else
+       if(name == IL_SO_SEND_TIMEOUT || name == IL_SO_RECV_TIMEOUT)
+       {
+               *value = (ILInt32)(optval.timeout.tv_sec * 1000 +
+                                                  optval.timeout.tv_usec / 
1000);
+       }
+       else
+       {
+               *value = optval.value;
+       }
+#endif
+
+       return 1;
 #else
        ILSysIOSetErrno(IL_ERRNO_EINVAL);
        return 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]