r106325 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106324‎ | r106325 | r106326 >
Date:14:24, 15 December 2011
Author:petrb
Status:resolved (Comments)
Tags:
Comment:
Fixed write to shared data
Modified paths:
  • /trunk/tools/wmib/Core.cs (modified) (history)
  • /trunk/tools/wmib/DumpHtm.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/DumpHtm.cs
@@ -22,6 +22,7 @@
2323 {
2424 public config.channel Channel;
2525 public string dumpname;
 26+ // This function is called on start of bot
2627 public static void Start()
2728 {
2829 while (true)
@@ -63,19 +64,27 @@
6465 }
6566 public void Make()
6667 {
67 - string text;
68 - text = CreateHeader();
69 - text = text + "<table border=1 width=100%>\n<tr><td width=10%>Key</td><td>Value</td></tr>\n";
70 - if (Channel.Keys.text.Count > 0)
 68+ try
7169 {
72 - foreach (irc.dictionary.item Key in Channel.Keys.text)
 70+ string text;
 71+ text = CreateHeader();
 72+ text = text + "<table border=1 width=100%>\n<tr><td width=10%>Key</td><td>Value</td></tr>\n";
 73+ Channel.Keys.locked = true;
 74+ if (Channel.Keys.text.Count > 0)
7375 {
74 - text = text + AddLine(Key.key, Key.text);
 76+ foreach (irc.dictionary.item Key in Channel.Keys.text)
 77+ {
 78+ text = text + AddLine(Key.key, Key.text);
 79+ }
7580 }
 81+ Channel.Keys.locked = false;
 82+ text = text + "<table>\n";
 83+ text = text + CreateFooter();
 84+ System.IO.File.WriteAllText(dumpname, text);
 85+ } catch (Exception b)
 86+ {
 87+ Channel.Keys.locked = false;
 88+ Console.WriteLine(b.Message);
7689 }
77 - text = text + "<table>\n";
78 - text = text + CreateFooter();
79 - System.IO.File.WriteAllText(dumpname, text);
80 - }
8190 }
8291 }
Index: trunk/tools/wmib/Core.cs
@@ -224,6 +224,7 @@
225225 public string datafile = "";
226226 // if we need to update dump
227227 public bool update = true;
 228+ public bool locked = false;
228229 public class item
229230 {
230231 public item(string Key, string Text, string User, string Lock = "false")
@@ -511,6 +512,10 @@
512513
513514 public void setKey(string Text, string key, string user)
514515 {
 516+ while (locked)
 517+ {
 518+ i
 519+ }
515520 try
516521 {
517522 foreach (item data in text)
@@ -546,6 +551,10 @@
547552 }
548553 public void rmKey(string key, string user)
549554 {
 555+ while (locked)
 556+ {
 557+ System.Threading.Thread.Sleep(200);
 558+ }
550559 foreach (item keys in text)
551560 {
552561 if (keys.key == key)

Comments

#Comment by Nikerabbit (talk | contribs)   10:49, 16 December 2011

Adding r106325 to followups manually.

Status & tagging log