Author: gonzalo
Date: 2005-05-07 14:54:36 -0400 (Sat, 07 May 2005)
New Revision: 44204
Modified:
trunk/mono/mono/io-layer/ChangeLog
trunk/mono/mono/io-layer/sockets.c
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/socket-io.c
Log:
2005-05-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* metadata/socket-io.c:
* io-layer/sockets.c: on windows, getsockopt/setsockopt for send/receive
timeout use an integer in milliseconds. We were using a struct timeval.
Modified: trunk/mono/mono/io-layer/ChangeLog
===================================================================
--- trunk/mono/mono/io-layer/ChangeLog 2005-05-07 18:47:14 UTC (rev 44203)
+++ trunk/mono/mono/io-layer/ChangeLog 2005-05-07 18:54:36 UTC (rev 44204)
@@ -1,3 +1,8 @@
+2005-05-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * sockets.c: on windows, getsockopt/setsockopt for send/receive timeout
+ use an integer in milliseconds. We were using a struct timeval.
+
2005-05-06 Dick Porter <[EMAIL PROTECTED]>
* handles-private.h:
Modified: trunk/mono/mono/io-layer/sockets.c
===================================================================
--- trunk/mono/mono/io-layer/sockets.c 2005-05-07 18:47:14 UTC (rev 44203)
+++ trunk/mono/mono/io-layer/sockets.c 2005-05-07 18:54:36 UTC (rev 44204)
@@ -392,7 +392,9 @@
{
gpointer handle = GUINT_TO_POINTER (fd);
int ret;
-
+ struct timeval tv;
+ void *tmp_val;
+
if (startup_count == 0) {
WSASetLastError (WSANOTINITIALISED);
return(SOCKET_ERROR);
@@ -402,8 +404,14 @@
WSASetLastError (WSAENOTSOCK);
return(SOCKET_ERROR);
}
-
- ret = getsockopt (fd, level, optname, optval, optlen);
+
+ tmp_val = optval;
+ if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
+ tmp_val = &tv;
+ *optlen = sizeof (tv);
+ }
+
+ ret = getsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
#ifdef DEBUG
@@ -416,6 +424,11 @@
return(SOCKET_ERROR);
}
+
+ if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
+ *((int *) optval) = tv.tv_sec * 1000 + tv.tv_usec;
+ *optlen = sizeof (int);
+ }
return(ret);
}
@@ -601,6 +614,8 @@
{
gpointer handle = GUINT_TO_POINTER (fd);
int ret;
+ const void *tmp_val;
+ struct timeval tv;
if (startup_count == 0) {
WSASetLastError (WSANOTINITIALISED);
@@ -611,8 +626,17 @@
WSASetLastError (WSAENOTSOCK);
return(SOCKET_ERROR);
}
-
- ret = setsockopt (fd, level, optname, optval, optlen);
+
+ tmp_val = optval;
+ if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
+ int ms = *((int *) optval);
+ tv.tv_sec = ms / 1000;
+ tv.tv_usec = ms % 1000;
+ tmp_val = &tv;
+ optlen = sizeof (tv);
+ }
+
+ ret = setsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
#ifdef DEBUG
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2005-05-07 18:47:14 UTC (rev 44203)
+++ trunk/mono/mono/metadata/ChangeLog 2005-05-07 18:54:36 UTC (rev 44204)
@@ -1,3 +1,9 @@
+2005-05-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * metadata/socket-io.c: on windows, getsockopt/setsockopt for
+ send/receive timeout use an integer in milliseconds. We were using a
+ struct timeval.
+
2005-05-06 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* locales.c:
Modified: trunk/mono/mono/metadata/socket-io.c
===================================================================
--- trunk/mono/mono/metadata/socket-io.c 2005-05-07 18:47:14 UTC (rev
44203)
+++ trunk/mono/mono/metadata/socket-io.c 2005-05-07 18:54:36 UTC (rev
44204)
@@ -24,6 +24,7 @@
#include <mono/metadata/threads.h>
/* FIXME change this code to not mess so much with the internals */
#include <mono/metadata/class-internals.h>
+#include <mono/metadata/threadpool-internals.h>
#include <sys/time.h>
@@ -1442,8 +1443,8 @@
int valsize=sizeof(val);
struct linger linger;
int lingersize=sizeof(linger);
- struct timeval tv;
- int tvsize=sizeof(tv);
+ int time_ms = 0;
+ int time_ms_size = sizeof (time_ms);
#ifdef SO_PEERCRED
struct ucred cred;
int credsize = sizeof(cred);
@@ -1477,8 +1478,7 @@
case SocketOptionName_SendTimeout:
case SocketOptionName_ReceiveTimeout:
- ret = _wapi_getsockopt (sock, system_level, system_name, &tv,
- &tvsize);
+ ret = _wapi_getsockopt (sock, system_level, system_name, (char
*) &time_ms, &time_ms_size);
break;
#ifdef SO_PEERCRED
@@ -1524,7 +1524,7 @@
case SocketOptionName_SendTimeout:
case SocketOptionName_ReceiveTimeout:
- obj = int_to_object (domain, (tv.tv_sec * 1000) + (tv.tv_usec /
1000));
+ obj = int_to_object (domain, time_ms);
break;
#ifdef SO_PEERCRED
@@ -1793,19 +1793,8 @@
return;
}
} else {
- switch(name) {
- case SocketOptionName_SendTimeout:
- case SocketOptionName_ReceiveTimeout: {
- struct timeval tv;
- tv.tv_sec = int_val / 1000;
- tv.tv_usec = (int_val % 1000) * 1000;
- ret = _wapi_setsockopt (sock, system_level,
system_name, &tv, sizeof (tv));
- break;
- }
- default:
- ret = _wapi_setsockopt (sock, system_level,
system_name, &int_val,
- sizeof(int_val));
- }
+ /* ReceiveTimeout/SendTimeout get here */
+ ret = _wapi_setsockopt (sock, system_level, system_name, (char
*) &int_val, sizeof (int_val));
}
if(ret==SOCKET_ERROR) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches