From: <br...@us...> - 2008-12-08 11:06:29
|
Revision: 438 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=438&view=rev Author: brus07 Date: 2008-12-08 11:06:24 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Fixed bug with multiple times add to queue of submits. Added new log SystemMessage in SocketServerGate. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-12-07 21:57:19 UTC (rev 437) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-12-08 11:06:24 UTC (rev 438) @@ -37,11 +37,8 @@ if (message.IsType("TestingSubmit") == true) { Submit submit = Submit.CreateFromXml(message.Message); - if (dataContainer.Add(submit) == true) - { - OnLogMessage("Send", submit.id + " to " + clientIndex); - base.DataSender(message, clientIndex); - } + OnLogMessage("Send", submit.id + " to " + clientIndex); + base.DataSender(message, clientIndex); return; } @@ -71,11 +68,16 @@ for (int index = 0; index < submitList.Items.Length; index++) { - if (dataContainer.Contains(submitList.Items[index]) == false) + if (dataContainer.Add(submitList.Items[index]) == true) { SystemMessage sysMes = new SystemMessage(submitList.Items[index].ToString(), "TestingSubmit"); + OnLogMessage("SystemSend", submitList.Items[index].id + " to Pool"); pool.Send(sysMes); } + else + { + OnLogMessage("SystemReceive", submitList.Items[index].id + "is in queue"); + } } return true; } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs 2008-12-07 21:57:19 UTC (rev 437) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/WorkingPool.cs 2008-12-08 11:06:24 UTC (rev 438) @@ -2,13 +2,14 @@ using AcmContester.Library.LibraryExtention; using System.Collections.Generic; using System.Threading; +using AcmContester.Library.LibraryExtention.Data; namespace AcmContester.Plugins.MediatorPlugins.SocketServerGatePlugin { class WorkingPool { - internal delegate bool SebdDataDelegate(SystemMessage s); - internal event SebdDataDelegate onSendData; + internal delegate bool SendDataDelegate(SystemMessage s); + internal event SendDataDelegate onSendData; private bool OnSendData(SystemMessage sysMes) { @@ -18,7 +19,7 @@ return false; } - private Dictionary<SystemMessage, object> poolWork = new Dictionary<SystemMessage, object>(); + private Dictionary<int, SystemMessage> poolWork = new Dictionary<int, SystemMessage>(); private bool poolWorking = false; private void runPool() @@ -33,12 +34,13 @@ { if (poolWork.Count == 0) break; - foreach (SystemMessage sysMes in poolWork.Keys) + foreach (int key in poolWork.Keys) { + SystemMessage sysMes = poolWork[key]; //TODO: potribno zrobyty, shob pry posylci "poolWork" ne buv zalokanyj if (OnSendData(sysMes) == true) { - poolWork.Remove(sysMes); + poolWork.Remove(key); break; } } @@ -63,7 +65,13 @@ { lock (poolWork) { - poolWork.Add(sysMes, null); + if (sysMes.IsType("TestingSubmit")) + { + //TODO: \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE1\xF3\xE4\xE5 \xF6\xE5 \xE7\xE2\xB3\xE4\xF1\xE8 \xE7\xE0\xE1\xF0\xE0\xF2\xE8 + Submit submit = Submit.CreateFromXml(sysMes.Message); + if (poolWork.ContainsKey(submit.id) == false) + poolWork.Add(submit.id, sysMes); + } } startPool(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |