Author: gonzalo
Date: 2005-05-23 17:26:23 -0400 (Mon, 23 May 2005)
New Revision: 44919
Modified:
trunk/mcs/class/System/System.Net.Sockets/ChangeLog
trunk/mcs/class/System/System.Net.Sockets/Socket.cs
trunk/mcs/class/System/System.Net/ChangeLog
trunk/mcs/class/System/System.Net/WebConnection.cs
Log:
2005-05-23 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* System.Net/WebConnection.cs: prevent 2 nullrefs when the aborting
during Connect() and reset the status to Success before starting a
new request.
* System.Net.Sockets/Socket.cs: apply the same hack on blocking Connect
calls as the one used in Accept.
Fixes bug #75025.
Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2005-05-23 21:11:27 UTC (rev
44918)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2005-05-23 21:26:23 UTC (rev
44919)
@@ -1,3 +1,9 @@
+2005-05-23 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * WebConnection.cs: prevent 2 nullrefs when the aborting during
+ Connect() and reset the status to Success before starting a new
+ request.
+
2005-05-19 Sebastien Pouliot <[EMAIL PROTECTED]>
* WebRequest.cs: Throw NotImplementedException (not NotSupported
Modified: trunk/mcs/class/System/System.Net/WebConnection.cs
===================================================================
--- trunk/mcs/class/System/System.Net/WebConnection.cs 2005-05-23 21:11:27 UTC
(rev 44918)
+++ trunk/mcs/class/System/System.Net/WebConnection.cs 2005-05-23 21:26:23 UTC
(rev 44919)
@@ -126,9 +126,12 @@
status =
WebExceptionStatus.Success;
break;
} catch (SocketException) {
- socket.Close();
- socket = null;
- status =
WebExceptionStatus.ConnectFailure;
+ // This might be null if the
request is aborted
+ if (socket != null) {
+ socket.Close();
+ socket = null;
+ status =
WebExceptionStatus.ConnectFailure;
+ }
}
}
}
@@ -526,8 +529,10 @@
Data.request = request;
Connect ();
if (status != WebExceptionStatus.Success) {
- request.SetWriteStreamError (status);
- Close (true);
+ if (status !=
WebExceptionStatus.RequestCanceled) {
+ request.SetWriteStreamError (status);
+ Close (true);
+ }
return;
}
@@ -546,6 +551,7 @@
lock (this) {
if (!busy) {
busy = true;
+ status = WebExceptionStatus.Success;
ThreadPool.QueueUserWorkItem (initConn,
request);
} else {
lock (queue) {
Modified: trunk/mcs/class/System/System.Net.Sockets/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-05-23 21:11:27 UTC
(rev 44918)
+++ trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-05-23 21:26:23 UTC
(rev 44919)
@@ -1,3 +1,8 @@
+2005-05-23 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+ * Socket.cs: apply the same hack on blocking Connect calls as the one
+ used in Accept.
+
2005-05-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* Socket.cs: see bug #74842, which is fixed with this patch for details
Modified: trunk/mcs/class/System/System.Net.Sockets/Socket.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-05-23 21:11:27 UTC
(rev 44918)
+++ trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-05-23 21:26:23 UTC
(rev 44919)
@@ -778,14 +778,14 @@
private extern static IntPtr Accept_internal(IntPtr sock,
out int error);
- Thread accept_thread;
+ Thread blocking_thread;
public Socket Accept() {
if (disposed && closed)
throw new ObjectDisposedException (GetType
().ToString ());
int error = 0;
IntPtr sock = (IntPtr) (-1);
- accept_thread = Thread.CurrentThread;
+ blocking_thread = Thread.CurrentThread;
try {
sock = Accept_internal(socket, out error);
} catch (ThreadAbortException the) {
@@ -794,7 +794,7 @@
error = 10004;
}
} finally {
- accept_thread = null;
+ blocking_thread = null;
}
if (error != 0) {
@@ -805,10 +805,6 @@
this.SocketType,
this.ProtocolType, sock);
- // The MS runtime (really the OS, we suspect)
- // sets newly accepted sockets to have the
- // same Blocking status as the listening
- // socket
accepted.Blocking = this.Blocking;
return(accepted);
}
@@ -1060,10 +1056,21 @@
throw new ArgumentNullException("remote_end");
}
- int error;
-
SocketAddress serial = remote_end.Serialize ();
- Connect_internal(socket, serial, out error);
+ int error = 0;
+
+ blocking_thread = Thread.CurrentThread;
+ try {
+ Connect_internal (socket, serial, out error);
+ } catch (ThreadAbortException the) {
+ if (disposed) {
+ Thread.ResetAbort ();
+ error = 10004;
+ }
+ } finally {
+ blocking_thread = null;
+ }
+
if (error != 0) {
throw new SocketException (error);
}
@@ -1727,9 +1734,9 @@
IntPtr x = socket;
socket = (IntPtr) (-1);
Close_internal (x, out error);
- if (accept_thread != null) {
- accept_thread.Abort ();
- accept_thread = null;
+ if (blocking_thread != null) {
+ blocking_thread.Abort ();
+ blocking_thread = null;
}
if (error != 0)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches