[Mono-list] Some bugfixes for mono - new diff format

Jaroslaw Kowalski jarek@atm.com.pl
Sun, 28 Apr 2002 23:15:45 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0075_01C1EF0A.9FA581E0
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: 7bit

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" <jarek@atm.com.pl>
To: <mono-list@ximian.com>
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
>

------=_NextPart_000_0075_01C1EF0A.9FA581E0
Content-Type: text/plain;
	name="patch4.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch4.txt"

? metadata/new_threads.c=0A=
? metadata/patches.txt=0A=
Index: jit/jit.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/jit/jit.c,v=0A=
retrieving revision 1.155=0A=
diff -u -r1.155 jit.c=0A=
--- jit/jit.c	23 Apr 2002 03:19:17 -0000	1.155=0A=
+++ jit/jit.c	28 Apr 2002 21:11:56 -0000=0A=
@@ -3686,3 +3686,16 @@=0A=
 =0A=
 }=0A=
 =0A=
+void thread_unhandled_exception_cleanup(MonoObject *exc)=0A=
+{=0A=
+	/* fixme: anything more? */=0A=
+	=0A=
+	ExitThread(0);=0A=
+}=0A=
+=0A=
+void =0A=
+init_tls()=0A=
+{=0A=
+	/* this function is called in the context of newly-created thread */=0A=
+	TlsSetValue (exc_cleanup_id, thread_unhandled_exception_cleanup);=0A=
+}=0A=
Index: interpreter/interp.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/interpreter/interp.c,v=0A=
retrieving revision 1.172=0A=
diff -u -r1.172 interp.c=0A=
--- interpreter/interp.c	22 Apr 2002 11:04:12 -0000	1.172=0A=
+++ interpreter/interp.c	28 Apr 2002 21:11:59 -0000=0A=
@@ -3984,4 +3984,10 @@=0A=
 }=0A=
 =0A=
 =0A=
+void =0A=
+init_tls()=0A=
+{=0A=
+	/* this function is called in the context of newly-created thread */=0A=
+}=0A=
+=0A=
 =0A=
Index: metadata/threads.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/metadata/threads.c,v=0A=
retrieving revision 1.18=0A=
diff -u -r1.18 threads.c=0A=
--- metadata/threads.c	23 Apr 2002 09:12:25 -0000	1.18=0A=
+++ metadata/threads.c	28 Apr 2002 21:12:00 -0000=0A=
@@ -77,6 +77,7 @@=0A=
 	TlsSetValue (current_object_key, start_info->obj);=0A=
 	start_func =3D start_info->func;=0A=
 	mono_domain_set (start_info->domain);=0A=
+	init_tls();=0A=
 	this =3D start_info->this;=0A=
 	g_free (start_info);=0A=
 	=0A=
Index: metadata/threads.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/metadata/threads.h,v=0A=
retrieving revision 1.13=0A=
diff -u -r1.13 threads.h=0A=
--- metadata/threads.h	22 Apr 2002 18:43:38 -0000	1.13=0A=
+++ metadata/threads.h	28 Apr 2002 21:12:00 -0000=0A=
@@ -18,6 +18,7 @@=0A=
 =0A=
 extern void mono_thread_init (MonoDomain *domain);=0A=
 extern void mono_thread_cleanup(void);=0A=
+extern void init_tls(void);=0A=
 =0A=
 MonoObject *mono_thread_create (MonoDomain *domain, gpointer func);=0A=
 =0A=

------=_NextPart_000_0075_01C1EF0A.9FA581E0
Content-Type: text/plain;
	name="patch1.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch1.txt"

Index: TcpClient.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mcs/class/System/System.Net.Sockets/TcpClient.cs,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 TcpClient.cs=0A=
--- TcpClient.cs	6 Jan 2002 10:58:38 -0000	1.3=0A=
+++ TcpClient.cs	28 Apr 2002 21:10:01 -0000=0A=
@@ -92,7 +92,7 @@=0A=
 		protected Socket Client=0A=
 		{=0A=
 			get { return client; }=0A=
-			set { client =3D value; } //TODO: should we be able to set the =
socket like this?=0A=
+			set { client =3D value; }=0A=
 		}=0A=
 =0A=
 		/// <summary>=0A=
@@ -103,7 +103,8 @@=0A=
 		/// <param name=3D"s"></param>=0A=
 		internal void SetTcpClient (Socket s) =0A=
 		{=0A=
-			Client =3D s; // client or Client?  They are the same at the moment=0A=
+			client =3D s;=0A=
+			stream =3D new NetworkStream(client, true);=0A=
 		}=0A=
 		=0A=
 		/// <summary>=0A=

------=_NextPart_000_0075_01C1EF0A.9FA581E0
Content-Type: text/plain;
	name="patch2.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch2.txt"

Index: Win32Exception.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: =
/mono/mcs/class/System/System.ComponentModel/Win32Exception.cs,v=0A=
retrieving revision 1.3=0A=
diff -u -r1.3 Win32Exception.cs=0A=
--- Win32Exception.cs	27 Apr 2002 18:52:58 -0000	1.3=0A=
+++ Win32Exception.cs	28 Apr 2002 21:10:22 -0000=0A=
@@ -72,6 +72,57 @@=0A=
 				       Locale.GetText("proto no supported"));=0A=
 			w32_errors.Add(10044,=0A=
 				       Locale.GetText("socket not supproted"));=0A=
+			w32_errors.Add(10004,=0A=
+			    Locale.GetText("interrupted"));=0A=
+=0A=
+			w32_errors.Add(10013,=0A=
+			    Locale.GetText("WSAEACCES"));=0A=
+			w32_errors.Add(11002,=0A=
+			    Locale.GetText("WSATRY_AGAIN"));=0A=
+			w32_errors.Add(10022,=0A=
+			    Locale.GetText("Invalid arguments"));=0A=
+			w32_errors.Add(10014,=0A=
+			    Locale.GetText("WSAEFAULT"));=0A=
+			w32_errors.Add(11003,=0A=
+			    Locale.GetText("WSANO_RECOVERY"));=0A=
+			w32_errors.Add(11004,=0A=
+			    Locale.GetText("WSANO_DATA"));=0A=
+			w32_errors.Add(10040,=0A=
+			    Locale.GetText("WSAEMSGSIZE"));=0A=
+			w32_errors.Add(10024,=0A=
+			    Locale.GetText("WSAEMFILE"));=0A=
+			w32_errors.Add(10042,=0A=
+			    Locale.GetText("WSAENOPROTOOPT"));=0A=
+			w32_errors.Add(10050,=0A=
+			    Locale.GetText("Network subsystem is down"));=0A=
+			w32_errors.Add(10051,=0A=
+			    Locale.GetText("WSAENETUNREACH"));=0A=
+			w32_errors.Add(10035,=0A=
+			    Locale.GetText("WSAEWOULDBLOCK"));=0A=
+			w32_errors.Add(10036,=0A=
+			    Locale.GetText("WSAEINPROGRESS"));=0A=
+			w32_errors.Add(10060,=0A=
+			    Locale.GetText("WSAETIMEDOUT"));=0A=
+			w32_errors.Add(10037,=0A=
+			    Locale.GetText("WSAEALREADY"));=0A=
+			w32_errors.Add(10061,=0A=
+			    Locale.GetText("Connection refused"));=0A=
+			w32_errors.Add(10045,=0A=
+			    Locale.GetText("WSAEOPNOTSUPP"));=0A=
+			w32_errors.Add(10038,=0A=
+			    Locale.GetText("The descriptor is not a socket"));=0A=
+			w32_errors.Add(10055,=0A=
+			    Locale.GetText("Not enough buffer space is available"));=0A=
+			w32_errors.Add(10056,=0A=
+			    Locale.GetText("Socket is already connected"));=0A=
+			w32_errors.Add(10048,=0A=
+			    Locale.GetText("Address already in use"));=0A=
+			w32_errors.Add(10057,=0A=
+			    Locale.GetText("The socket is not connected"));=0A=
+			w32_errors.Add(10058,=0A=
+			    Locale.GetText("The socket has been shut down"));=0A=
+			w32_errors.Add(10093,=0A=
+			    Locale.GetText("Winsock not initialized"));=0A=
 		}=0A=
 =0A=
 		private static string W32ErrorMessage(int error_code) {=0A=

------=_NextPart_000_0075_01C1EF0A.9FA581E0
Content-Type: text/plain;
	name="patch3.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch3.txt"

Index: sockets.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/io-layer/sockets.c,v=0A=
retrieving revision 1.7=0A=
diff -u -r1.7 sockets.c=0A=
--- sockets.c	23 Apr 2002 04:49:39 -0000	1.7=0A=
+++ sockets.c	28 Apr 2002 21:11:18 -0000=0A=
@@ -302,6 +302,11 @@=0A=
 		case EFAULT:=0A=
 			WSASetLastError(WSAEFAULT);=0A=
 			break;=0A=
+	=0A=
+		case EADDRINUSE:=0A=
+			WSASetLastError(WSAEADDRINUSE);=0A=
+			break;=0A=
+=0A=
 		case EROFS:=0A=
 		case ENAMETOOLONG:=0A=
 		case ENOENT:=0A=
@@ -609,7 +614,12 @@=0A=
 		return(SOCKET_ERROR);=0A=
 	}=0A=
 	=0A=
+#ifdef MSG_NOSIGNAL=0A=
+	ret=3Dsend(socket_handle->fd, msg, len, send_flags | MSG_NOSIGNAL);=0A=
+#else=0A=
 	ret=3Dsend(socket_handle->fd, msg, len, send_flags);=0A=
+#endif=0A=
+=0A=
 	if(ret=3D=3D-1) {=0A=
 #ifdef DEBUG=0A=
 		g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",=0A=

------=_NextPart_000_0075_01C1EF0A.9FA581E0--