[smuxi] [Engine] Correctly lock CommitMessage before use
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] [Engine] Correctly lock CommitMessage before use
- Date: Fri, 28 Feb 2014 20:23:50 +0000 (UTC)
commit c7449f0213b8ee3fb9a09b3a7abde0ba494bada0
Author: Mirco Bauer <meebey meebey net>
Date: Sun Feb 26 12:14:48 2012 +0100
[Engine] Correctly lock CommitMessage before use
src/Engine/MessageBuffers/GitMessageBuffer.cs | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/Engine/MessageBuffers/GitMessageBuffer.cs b/src/Engine/MessageBuffers/GitMessageBuffer.cs
index b197fa4..1ffa07b 100644
--- a/src/Engine/MessageBuffers/GitMessageBuffer.cs
+++ b/src/Engine/MessageBuffers/GitMessageBuffer.cs
@@ -105,7 +105,6 @@ namespace Smuxi.Engine
var msgFilePath = Path.Combine(RepositoryPath, msgFileName);
using (var writer = File.OpenWrite(msgFilePath))
using (var textWriter = new StreamWriter(writer, Encoding.UTF8)) {
- //JsonSerializer.SerializeToStream(msg, writer);
JsonSerializer.SerializeToWriter(msg, textWriter);
}
@@ -126,9 +125,11 @@ namespace Smuxi.Engine
// FIXME: delete file when index was written to disk
File.Delete(msgFilePath);
- CommitMessage.Append(
- String.Format("{0}: {1}\n", msgFileName, msg.ToString())
- );
+ lock (CommitMessage) {
+ CommitMessage.Append(
+ String.Format("{0}: {1}\n", msgFileName, msg.ToString())
+ );
+ }
// TODO: create tree, commit tree, repack repo reguraly (see rugged docs)
}
@@ -232,8 +233,9 @@ namespace Smuxi.Engine
if (repo == null) {
return;
}
- lock (repo) {
- if (repo.Index.Count == 0 || CommitMessage.Length == 0) {
+ lock (repo)
+ lock (CommitMessage) {
+ if (CommitMessage.Length == 0) {
// nothing to commit
return;
}
@@ -249,7 +251,6 @@ namespace Smuxi.Engine
#endif
start = DateTime.UtcNow;
- // FIXME: CommitMessage is not thread-safe!
repo.Commit(CommitMessage.ToString(), false);
stop = DateTime.UtcNow;
#if MSGBUF_DEBUG
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]