Skip to content

Commit

Permalink
Fix query combiner bug resulting in lost write queries.
Browse files Browse the repository at this point in the history
- This was the cause of the issue that resulted in some servers not
  being marked as offline expectedly.  If the query combiner ran
  out of space, buffered queries were lost due to the wrong query
  variable being executed.
  • Loading branch information
SkywingvL committed Feb 3, 2013
1 parent 6406ec6 commit 5efe7ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions NWNMasterServer/NWGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ public NWGameServer(NWMasterServer MasterServer, IPEndPoint ServerAddress)
/// Save the server to the database. The server is assumed to be
/// locked.
/// </summary>
public void Save()
/// <returns>True if the save was successful.</returns>
public bool Save()
{
if (MasterServer.ConnectionString == null)
return;
return false;

try
{
Expand Down Expand Up @@ -187,7 +188,10 @@ ON DUPLICATE KEY UPDATE
Logger.Log(LogLevel.Error, "NWGameServer.Save(): Failed to save server {0}: Exception: {1}",
ServerAddress,
e);
return false;
}

return true;
}

/// <summary>
Expand Down Expand Up @@ -712,7 +716,12 @@ private void HeartbeatTimer_Elapsed(object sender, ElapsedEventArgs e)
ActivePlayerCount = 0;
Online = false;
Expired = true;
Save();

if (!Save())
{
Logger.Log(LogLevel.Error, "NWGameServer.HeartbeatTimer_Elapsed(): Server {0} could not be saved as expired.", this);
Expired = false;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion NWNMasterServer/NWMasterServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void ExecuteQueryNoReaderCombine(string Query)
QueryCombineTimer.Start();

if (DirectQuery != null)
MySqlHelper.ExecuteNonQuery(ConnectionString, Query);
MySqlHelper.ExecuteNonQuery(ConnectionString, DirectQuery);
}
catch (Exception e)
{
Expand Down

0 comments on commit 5efe7ad

Please sign in to comment.