News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
Sync Issue?  
by Matthew Reitano [mreitano at interport dot net]
posted on 2003/09/05

During stress tests, my client is throwing an exception:

ErrorNotification: System.ArgumentException: Value does not fall within the expected range.
at Org.Mentalis.Security.Ssl.SecureSocket.EndSend(IAsyncResult asyncResult) in C:\Projects\CDS\DataConnector\Org.Mentalis.Security\Ssl\SecureSocket.cs:line 370
at DCSockets.DCSocketsHandler.SendCallback(IAsyncResult ar) in c:\projects\cds\dataconnector\dcsockets\dcsocketshandler.cs:line 113

Which I've traced through, and it's hitting this code in SocketController.EndSend(IAsyncResult):

index = FindIndex(ar, m_ToSendList);
if (index < 0)
return null;
ret = (TransferItem)m_ToSendList[index];

...and returning null. I noticed not all of the references to m_ToSendList are syncd - shouldn't they be?

by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2003/09/05

Are you sure you're passing the right IAsyncResult to the right SecureSocket? Or that you're not calling EndSend with the same IAsyncResult twice? [just to make sure :-)]
The SecureSocket holds a list of things it has to send, the active send and a list of things that have been sent [m_ToSendList, m_ActiveSend and m_SentList respectively]. What you're seeing is that the SecureSocket cannot find your IAsyncResult in any of these lists.

I'll try to reproduce your results, but could you send me your stress test if possible?

And yes, all references to m_ToSendList should be syncrhonized -- and as far as we know, they are. All public methods and callbacks are synchronized and all private and protected methods are only called from synchronized methods.

by Hans Andersen [hans at enterprisedt dot com]
posted on 2004/12/16

Hi

We've had this problem also and have tracked down the cause of it. Before I explain I'll give the fix:

1. In the main SecureNetworkStream constructor comment out the third if statement, i.e. if (!socket.Connected || socket.SocketType != SocketType.Stream) throw new ArgumentException();

2. In SecureSocket.BeginReceive comment out the second if statement, i.e. if (!Connected && m_SentShutdownNotification) throw new SocketException();

When you do this SecureNetworkStream.Read will return 0 when it reaches the end of the stream as it should instead of sometimes throwing an exception instead.

The exception gets thrown if you call SecureNetworkStream.Read after the machine on the other end has closed the connection.

Often code will keep reading until Read returns zero, so if that final read happens after the other machine has closed the socket then the exception will get thrown before Read gets a chance to return zero. The problem is intermittent because it depends on the timing of the two actions.

Hope that helps,
Hans Andersen
Enterprise Distributed Technologies

PS: Thanks to the Mentalis guys for giving this great software to the world.

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.