Patches again: using -u option on diff as advised by Duncan Mak
Please verify my init_tls() idea before committing, I'm not sure if it
should be done this way....
Jarek
----- Original Message -----
From: "Jaroslaw Kowalski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, April 28, 2002 10:28 PM
Subject: [Mono-list] Some bugfixes for mono
> This weekend I've been hacking on socket- and exception- related code:
>
> Here come some patches, I'd like to be introduced in mono (only verified
on
> RedHat Linux 7.2)
>
> 1. Fixed an error where TcpClient returned from
> TcpListener::AcceptTcpClient() would return null from GetStream() instead
of
> correct NetworkStream object.
>
> [patch1.txt]
>
> 2. Improved Win32Exception error messages a bit by scanning through source
> code looking for WSASetLastError() and adding errors along with their
> descriptions to Win32Exception.cs file
>
> [patch2.txt]
>
> 3. Attempted to fix a problem where send() to a closed socket resulted in
a
> signal being raised. Fixed this by including MSG_NOSIGNAL flag in a call
to
> send(). Also fixed some diagnostics in bind() call.
>
> [patch3.txt]
>
> 4. Attempted to fix a problem with assert() being called when an exception
> was thrown in a thread (JIT-only). exc_cleanup_id TLS Entry needs to be
> filled for newly created threads. I added init_tls() function that is
no-op
> in MINT code and sets up the required TLS entry in JIT mode.
>
> [patch4.txt]
>
> Hope it helps someone,
> Regards,
>
> Jarek
>
? metadata/new_threads.c
? metadata/patches.txt
Index: jit/jit.c
===================================================================
RCS file: /mono/mono/mono/jit/jit.c,v
retrieving revision 1.155
diff -u -r1.155 jit.c
--- jit/jit.c 23 Apr 2002 03:19:17 -0000 1.155
+++ jit/jit.c 28 Apr 2002 21:11:56 -0000
@@ -3686,3 +3686,16 @@
}
+void thread_unhandled_exception_cleanup(MonoObject *exc)
+{
+ /* fixme: anything more? */
+
+ ExitThread(0);
+}
+
+void
+init_tls()
+{
+ /* this function is called in the context of newly-created thread */
+ TlsSetValue (exc_cleanup_id, thread_unhandled_exception_cleanup);
+}
Index: interpreter/interp.c
===================================================================
RCS file: /mono/mono/mono/interpreter/interp.c,v
retrieving revision 1.172
diff -u -r1.172 interp.c
--- interpreter/interp.c 22 Apr 2002 11:04:12 -0000 1.172
+++ interpreter/interp.c 28 Apr 2002 21:11:59 -0000
@@ -3984,4 +3984,10 @@
}
+void
+init_tls()
+{
+ /* this function is called in the context of newly-created thread */
+}
+
Index: metadata/threads.c
===================================================================
RCS file: /mono/mono/mono/metadata/threads.c,v
retrieving revision 1.18
diff -u -r1.18 threads.c
--- metadata/threads.c 23 Apr 2002 09:12:25 -0000 1.18
+++ metadata/threads.c 28 Apr 2002 21:12:00 -0000
@@ -77,6 +77,7 @@
TlsSetValue (current_object_key, start_info->obj);
start_func = start_info->func;
mono_domain_set (start_info->domain);
+ init_tls();
this = start_info->this;
g_free (start_info);
Index: metadata/threads.h
===================================================================
RCS file: /mono/mono/mono/metadata/threads.h,v
retrieving revision 1.13
diff -u -r1.13 threads.h
--- metadata/threads.h 22 Apr 2002 18:43:38 -0000 1.13
+++ metadata/threads.h 28 Apr 2002 21:12:00 -0000
@@ -18,6 +18,7 @@
extern void mono_thread_init (MonoDomain *domain);
extern void mono_thread_cleanup(void);
+extern void init_tls(void);
MonoObject *mono_thread_create (MonoDomain *domain, gpointer func);
Index: TcpClient.cs
===================================================================
RCS file: /mono/mcs/class/System/System.Net.Sockets/TcpClient.cs,v
retrieving revision 1.3
diff -u -r1.3 TcpClient.cs
--- TcpClient.cs 6 Jan 2002 10:58:38 -0000 1.3
+++ TcpClient.cs 28 Apr 2002 21:10:01 -0000
@@ -92,7 +92,7 @@
protected Socket Client
{
get { return client; }
- set { client = value; } //TODO: should we be able to set the
socket like this?
+ set { client = value; }
}
/// <summary>
@@ -103,7 +103,8 @@
/// <param name="s"></param>
internal void SetTcpClient (Socket s)
{
- Client = s; // client or Client? They are the same at the
moment
+ client = s;
+ stream = new NetworkStream(client, true);
}
/// <summary>
Index: Win32Exception.cs
===================================================================
RCS file: /mono/mcs/class/System/System.ComponentModel/Win32Exception.cs,v
retrieving revision 1.3
diff -u -r1.3 Win32Exception.cs
--- Win32Exception.cs 27 Apr 2002 18:52:58 -0000 1.3
+++ Win32Exception.cs 28 Apr 2002 21:10:22 -0000
@@ -72,6 +72,57 @@
Locale.GetText("proto no supported"));
w32_errors.Add(10044,
Locale.GetText("socket not supproted"));
+ w32_errors.Add(10004,
+ Locale.GetText("interrupted"));
+
+ w32_errors.Add(10013,
+ Locale.GetText("WSAEACCES"));
+ w32_errors.Add(11002,
+ Locale.GetText("WSATRY_AGAIN"));
+ w32_errors.Add(10022,
+ Locale.GetText("Invalid arguments"));
+ w32_errors.Add(10014,
+ Locale.GetText("WSAEFAULT"));
+ w32_errors.Add(11003,
+ Locale.GetText("WSANO_RECOVERY"));
+ w32_errors.Add(11004,
+ Locale.GetText("WSANO_DATA"));
+ w32_errors.Add(10040,
+ Locale.GetText("WSAEMSGSIZE"));
+ w32_errors.Add(10024,
+ Locale.GetText("WSAEMFILE"));
+ w32_errors.Add(10042,
+ Locale.GetText("WSAENOPROTOOPT"));
+ w32_errors.Add(10050,
+ Locale.GetText("Network subsystem is down"));
+ w32_errors.Add(10051,
+ Locale.GetText("WSAENETUNREACH"));
+ w32_errors.Add(10035,
+ Locale.GetText("WSAEWOULDBLOCK"));
+ w32_errors.Add(10036,
+ Locale.GetText("WSAEINPROGRESS"));
+ w32_errors.Add(10060,
+ Locale.GetText("WSAETIMEDOUT"));
+ w32_errors.Add(10037,
+ Locale.GetText("WSAEALREADY"));
+ w32_errors.Add(10061,
+ Locale.GetText("Connection refused"));
+ w32_errors.Add(10045,
+ Locale.GetText("WSAEOPNOTSUPP"));
+ w32_errors.Add(10038,
+ Locale.GetText("The descriptor is not a socket"));
+ w32_errors.Add(10055,
+ Locale.GetText("Not enough buffer space is available"));
+ w32_errors.Add(10056,
+ Locale.GetText("Socket is already connected"));
+ w32_errors.Add(10048,
+ Locale.GetText("Address already in use"));
+ w32_errors.Add(10057,
+ Locale.GetText("The socket is not connected"));
+ w32_errors.Add(10058,
+ Locale.GetText("The socket has been shut down"));
+ w32_errors.Add(10093,
+ Locale.GetText("Winsock not initialized"));
}
private static string W32ErrorMessage(int error_code) {
Index: sockets.c
===================================================================
RCS file: /mono/mono/mono/io-layer/sockets.c,v
retrieving revision 1.7
diff -u -r1.7 sockets.c
--- sockets.c 23 Apr 2002 04:49:39 -0000 1.7
+++ sockets.c 28 Apr 2002 21:11:18 -0000
@@ -302,6 +302,11 @@
case EFAULT:
WSASetLastError(WSAEFAULT);
break;
+
+ case EADDRINUSE:
+ WSASetLastError(WSAEADDRINUSE);
+ break;
+
case EROFS:
case ENAMETOOLONG:
case ENOENT:
@@ -609,7 +614,12 @@
return(SOCKET_ERROR);
}
+#ifdef MSG_NOSIGNAL
+ ret=send(socket_handle->fd, msg, len, send_flags | MSG_NOSIGNAL);
+#else
ret=send(socket_handle->fd, msg, len, send_flags);
+#endif
+
if(ret==-1) {
#ifdef DEBUG
g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",