Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.5 SuperSocket.SocketEngine.SocketSession.OnSendingCompleted NullReferenceException #139

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3866431
removed the files which will not be released in v1.5
kerryjiang Dec 26, 2012
d606acb
updated the push script
kerryjiang Dec 26, 2012
d68bc03
updated the assembly version
kerryjiang Dec 26, 2012
ffbcd43
updated the copyright year in the assembly info
kerryjiang Dec 27, 2012
0b5bb78
removed the useless code in the test cases
kerryjiang Dec 27, 2012
3c1c9d4
added the missed TestFixture attribute in some test cases
kerryjiang Dec 27, 2012
fa92f40
improved the test case TestMaxConnection
kerryjiang Dec 30, 2012
12229a8
removed the useless file RunServer.bat
kerryjiang Jan 2, 2013
c878a4c
updated README.TXT
kerryjiang Jan 3, 2013
08ea506
updated the assembly version to 1.5.1
kerryjiang Jan 8, 2013
eb93c15
updated README.TXT
kerryjiang Jan 3, 2013
3bfe6fe
improved the code to allow accessing socket session from appSession w…
kerryjiang Jan 8, 2013
ae1886a
added test cases for FixedHeaderReceiveFilter
kerryjiang Jan 8, 2013
256df9a
fixed stopping listening issue
kerryjiang Jan 10, 2013
d839f40
dont't fire OnAcceptNewClient event if a socket error received
kerryjiang Jan 11, 2013
5101ce3
made the ServerPush sample workable
kerryjiang Jan 14, 2013
06735fc
improved the CountSpliterReceiveFilter and FixedSizeReceiveFilter to …
kerryjiang Jan 15, 2013
99f62fb
ignore more CloseReason
kerryjiang Jan 24, 2013
4b357f5
improved SmartPool
kerryjiang Jan 24, 2013
49ad75b
improved CloseReason
kerryjiang Jan 24, 2013
b9181c3
improved the socket listener
kerryjiang Jan 24, 2013
c0f8757
don't throw exception when send if the socket is not connected
kerryjiang Jan 25, 2013
a6a7f50
improved socket session closing handling and sending queue management
kerryjiang Jan 25, 2013
9846930
improved Test project
kerryjiang Jan 25, 2013
025bbcc
fixed the bug that ConnectionFilter's Initialized method never get fired
kerryjiang Jan 27, 2013
b3d7eb0
added the SendingQueue information into the performance log
kerryjiang Jan 30, 2013
2e8068a
tried to fixed async sending memory leak issue
kerryjiang Jan 30, 2013
2595b1f
improved the code of async sending
kerryjiang Jan 31, 2013
bd91915
fixed a PerformanceCounter issue
kerryjiang Jan 31, 2013
93ea6aa
fixed a bug in FixedSizeReceiveFilter
kerryjiang Feb 3, 2013
91dfe41
removed the session parameter from the TerminatorReceiveFilter's cons…
kerryjiang Feb 8, 2013
01fe245
upgraded the assembly version to 1.5.2
kerryjiang Feb 8, 2013
120ea62
fixed the logging file path issue when the SuperSocket runs in mono-s…
kerryjiang Feb 8, 2013
ef3ee9b
fixed a listener error log bug
kerryjiang Feb 27, 2013
6c25095
fixed a bug about performance logging in linux
kerryjiang Mar 11, 2013
d6773ef
fixed the bug that the udp socket won't continue to receive data if t…
kerryjiang Mar 12, 2013
a0137c6
fixed one bug in a UDP test case
kerryjiang Mar 28, 2013
d13384c
fixed a linux compatibility issue in the UDP test cases
kerryjiang Apr 2, 2013
bb448a1
improved the keep alive setting for Mono platform
kerryjiang Apr 2, 2013
a041ed3
fixed some warnings which can cause building error in Xamarin Studio
kerryjiang Apr 3, 2013
81a9c3a
removed a conflicted logging extension method
kerryjiang Apr 7, 2013
7006ae1
added back a missing ignored socket error
kerryjiang Apr 7, 2013
54717b0
improved the logging code in the socket session classes
kerryjiang Apr 9, 2013
ad6bd62
upgraded the assembly version to v1.5.3
kerryjiang Apr 14, 2013
f1ccac1
fixed a bug which would be produced when the receiveBufferSize is ver…
kerryjiang Apr 14, 2013
52832f9
fixed the bug that the ConfigurationCollectionAttribute doesn't work …
kerryjiang Apr 17, 2013
4ade4fc
updated README.TXT
kerryjiang Apr 27, 2013
060cf4b
fixed a comment issue in the LogFactoryBase class
kerryjiang May 6, 2013
4a5def9
catch the AppDomain's unhandled exceptions
kerryjiang May 7, 2013
ceebf06
fixed a bug that InSending status is not cleared when return the Send…
kerryjiang May 16, 2013
4498fcb
fixed the InSending/InReceiving state uncontrolled issue
kerryjiang May 21, 2013
28031a2
updated NUnit
kerryjiang May 23, 2013
03cd725
added Udp test cases for the built-in receive filters
kerryjiang May 23, 2013
809f457
fixed a bug which can cause the closed event will be fired multiple t…
kerryjiang May 24, 2013
31cbeb2
added more test cases for ReceiveFilters
kerryjiang May 26, 2013
58a885d
upgraded the assembly version to 1.5.4
kerryjiang Jul 10, 2013
765204f
fixed a bug that when you close a session, the data is being sent won…
kerryjiang Jul 14, 2013
9692202
fixed the default clear idle session parameters in the config model c…
kerryjiang Jul 16, 2013
08b7437
fixed serializing exception for CommandAssemblyConfig and ListenerCon…
kerryjiang Aug 15, 2013
a821933
fixed a bug that default security option doesn't work for listeners
kerryjiang Aug 19, 2013
e9b3ebf
fixed a security loading error if the listener's security has not bee…
kerryjiang Aug 22, 2013
07807f0
fixed the remoting server lifetime issue in the AppDomain isolation mode
kerryjiang Aug 31, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Common/ConfigurationExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ public static string GetValue(this NameValueCollection collection, string key, s
public static void Deserialize<TElement>(this TElement section, XmlReader reader)
where TElement : ConfigurationElement
{
if (section is ConfigurationElementCollection)
{
var collectionType = section.GetType();
var att = collectionType.GetCustomAttributes(typeof(ConfigurationCollectionAttribute), true).FirstOrDefault() as ConfigurationCollectionAttribute;

if (att != null)
{
var property = collectionType.GetProperty("AddElementName", BindingFlags.NonPublic | BindingFlags.Instance);
property.SetValue(section, att.AddItemName, null);

property = collectionType.GetProperty("RemoveElementName", BindingFlags.NonPublic | BindingFlags.Instance);
property.SetValue(section, att.RemoveItemName, null);

property = collectionType.GetProperty("ClearElementName", BindingFlags.NonPublic | BindingFlags.Instance);
property.SetValue(section, att.ClearItemsName, null);
}
}

var deserializeElementMethod = typeof(TElement).GetMethod("DeserializeElement", BindingFlags.NonPublic | BindingFlags.Instance);
deserializeElementMethod.Invoke(section, new object[] { reader, false });
}
Expand Down
115 changes: 83 additions & 32 deletions Common/SmartPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@
namespace SuperSocket.Common
{
/// <summary>
/// The basic interface of smart pool
/// The pool information class
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ISmartPool<T>
public interface IPoolInfo
{
/// <summary>
/// Initializes the specified min pool size.
/// </summary>
/// <param name="minPoolSize">The min size of the pool.</param>
/// <param name="maxPoolSize">The max size of the pool.</param>
/// <param name="sourceCreator">The source creator.</param>
/// <returns></returns>
void Initialize(int minPoolSize, int maxPoolSize, ISmartPoolSourceCreator<T> sourceCreator);

/// <summary>
/// Gets the min size of the pool.
/// </summary>
Expand All @@ -48,6 +38,31 @@ public interface ISmartPool<T>
/// </value>
int AvialableItemsCount { get; }


/// <summary>
/// Gets the total items count, include items in the pool and outside the pool.
/// </summary>
/// <value>
/// The total items count.
/// </value>
int TotalItemsCount { get; }
}

/// <summary>
/// The basic interface of smart pool
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ISmartPool<T> : IPoolInfo
{
/// <summary>
/// Initializes the specified min pool size.
/// </summary>
/// <param name="minPoolSize">The min size of the pool.</param>
/// <param name="maxPoolSize">The max size of the pool.</param>
/// <param name="sourceCreator">The source creator.</param>
/// <returns></returns>
void Initialize(int minPoolSize, int maxPoolSize, ISmartPoolSourceCreator<T> sourceCreator);

/// <summary>
/// Pushes the specified item into the pool.
/// </summary>
Expand Down Expand Up @@ -186,6 +201,19 @@ public int AvialableItemsCount
}
}

private int m_TotalItemsCount;

/// <summary>
/// Gets the total items count, include items in the pool and outside the pool.
/// </summary>
/// <value>
/// The total items count.
/// </value>
public int TotalItemsCount
{
get { return m_TotalItemsCount; }
}

/// <summary>
/// Initializes the specified min and max pool size.
/// </summary>
Expand Down Expand Up @@ -228,8 +256,12 @@ public void Initialize(int minPoolSize, int maxPoolSize, ISmartPoolSourceCreator
{
m_GlobalStack.Push(items[i]);
}

m_TotalItemsCount = m_MinPoolSize;
}

private int m_IsIncreasing = 0;

/// <summary>
/// Pushes the specified item into the pool.
/// </summary>
Expand All @@ -239,6 +271,24 @@ public void Push(T item)
m_GlobalStack.Push(item);
}

bool TryPopWithWait(out T item, int waitTicks)
{
var spinWait = new SpinWait();

while (true)
{
spinWait.SpinOnce();

if (m_GlobalStack.TryPop(out item))
return true;

if (spinWait.Count >= waitTicks)
{
return false;
}
}
}

/// <summary>
/// Tries to get one item from the pool.
/// </summary>
Expand All @@ -253,42 +303,43 @@ public bool TryGet(out T item)
var currentSourceCount = m_CurrentSourceCount;

if (currentSourceCount >= m_ItemsSource.Length)
return false;

if (Interlocked.CompareExchange(ref m_CurrentSourceCount, currentSourceCount + 1, currentSourceCount) != currentSourceCount)
{
var spinWait = new SpinWait();
return TryPopWithWait(out item, 100);
}

while (true)
{
spinWait.SpinOnce();
var isIncreasing = m_IsIncreasing;

if (m_GlobalStack.TryPop(out item))
return true;
if (isIncreasing == 1)
return TryPopWithWait(out item, 100);

if (spinWait.Count >= 100)
return false;
}
}
if (Interlocked.CompareExchange(ref m_IsIncreasing, 1, isIncreasing) != isIncreasing)
return TryPopWithWait(out item, 100);

IncreaseCapacity();

int totalItemsCount = 0;
m_IsIncreasing = 0;

for (var i = 0; i < currentSourceCount; i++)
if (!m_GlobalStack.TryPop(out item))
{
totalItemsCount += m_ItemsSource[i].Count;
return false;
}

totalItemsCount = Math.Min(totalItemsCount, m_MaxPoolSize - totalItemsCount);
return true;
}

private void IncreaseCapacity()
{
var newItemsCount = Math.Min(m_TotalItemsCount, m_MaxPoolSize - m_TotalItemsCount);

T[] items;
m_ItemsSource[currentSourceCount] = m_SourceCreator.Create(totalItemsCount, out items);
m_ItemsSource[m_CurrentSourceCount] = m_SourceCreator.Create(newItemsCount, out items);

m_TotalItemsCount += newItemsCount;

for (var i = 0; i < items.Length; i++)
{
m_GlobalStack.Push(items[i]);
}

return m_GlobalStack.TryPop(out item);
}
}
}
115 changes: 0 additions & 115 deletions Facility/HttpBase/HttpReceiveFilterBase.cs

This file was deleted.

71 changes: 0 additions & 71 deletions Facility/HttpBase/HttpRequestInfoBase.cs

This file was deleted.

Loading