https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106325
Revision: 106325
Author: petrb
Date: 2011-12-15 14:24:06 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Fixed write to shared data
Modified Paths:
--------------
trunk/tools/wmib/Core.cs
trunk/tools/wmib/DumpHtm.cs
Modified: trunk/tools/wmib/Core.cs
===================================================================
--- trunk/tools/wmib/Core.cs 2011-12-15 14:21:18 UTC (rev 106324)
+++ trunk/tools/wmib/Core.cs 2011-12-15 14:24:06 UTC (rev 106325)
@@ -224,6 +224,7 @@
public string datafile = "";
// if we need to update dump
public bool update = true;
+ public bool locked = false;
public class item
{
public item(string Key, string Text, string User, string Lock
= "false")
@@ -511,6 +512,10 @@
public void setKey(string Text, string key, string user)
{
+ while (locked)
+ {
+ i
+ }
try
{
foreach (item data in text)
@@ -546,6 +551,10 @@
}
public void rmKey(string key, string user)
{
+ while (locked)
+ {
+ System.Threading.Thread.Sleep(200);
+ }
foreach (item keys in text)
{
if (keys.key == key)
Modified: trunk/tools/wmib/DumpHtm.cs
===================================================================
--- trunk/tools/wmib/DumpHtm.cs 2011-12-15 14:21:18 UTC (rev 106324)
+++ trunk/tools/wmib/DumpHtm.cs 2011-12-15 14:24:06 UTC (rev 106325)
@@ -22,6 +22,7 @@
{
public config.channel Channel;
public string dumpname;
+ // This function is called on start of bot
public static void Start()
{
while (true)
@@ -63,19 +64,27 @@
}
public void Make()
{
- string text;
- text = CreateHeader();
- text = text + "<table border=1 width=100%>\n<tr><td
width=10%>Key</td><td>Value</td></tr>\n";
- if (Channel.Keys.text.Count > 0)
+ try
{
- foreach (irc.dictionary.item Key in Channel.Keys.text)
+ string text;
+ text = CreateHeader();
+ text = text + "<table border=1 width=100%>\n<tr><td
width=10%>Key</td><td>Value</td></tr>\n";
+ Channel.Keys.locked = true;
+ if (Channel.Keys.text.Count > 0)
{
- text = text + AddLine(Key.key, Key.text);
+ foreach (irc.dictionary.item Key in Channel.Keys.text)
+ {
+ text = text + AddLine(Key.key, Key.text);
+ }
}
+ Channel.Keys.locked = false;
+ text = text + "<table>\n";
+ text = text + CreateFooter();
+ System.IO.File.WriteAllText(dumpname, text);
+ } catch (Exception b)
+ {
+ Channel.Keys.locked = false;
+ Console.WriteLine(b.Message);
}
- text = text + "<table>\n";
- text = text + CreateFooter();
- System.IO.File.WriteAllText(dumpname, text);
- }
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs