From 29de169741b074ce9158bce94f0b8db5088cdcf2 Mon Sep 17 00:00:00 2001 From: MegaBrutal Date: Wed, 17 Oct 2018 17:30:30 +0200 Subject: [PATCH] Fix TLogger.AddStdLine to work with Wine 1.6 Wine 1.6 gives a standard output handle to the service process, albeit all writes to it fails. Because of this, TLogger.AddStdLine did not even write to the log file due to short-circuit evaluation. Now I made sure to attempt both stdout and logfile writes. Native Windows doesn't provide an stdout handle for service processes (GetStdHandle returns 0), in which case MgSMTP detects it has no stdout and redirects its output to mgsmtp_stdout.log. Wine 3.0 behaves the same, so I deemed the Wine 1.6 behaviour a bug. Therefore, I find this quick fix sufficient - there is no need to bother with Wine 1.6 compatibility any further, e.g. by checking if Wine 1.6 gave a writable stdout handle or not. Users of MgSMTP on Wine are rather suggested to update to Wine 3.0. modified: Log.pas modified: MgSMTP.pas --- Log.pas | 12 +++++++++--- MgSMTP.pas | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Log.pas b/Log.pas index 9800121..46538b2 100644 --- a/Log.pas +++ b/Log.pas @@ -1,6 +1,6 @@ { MegaBrutal's SMTP Server (MgSMTP) - Copyright (C) 2010-2014 MegaBrutal + Copyright (C) 2010-2018 MegaBrutal This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -146,14 +146,20 @@ end; function TLogger.AddStdLine(Line: string): boolean; { Log message to both stdout and smtp.log. } +var outresult, logresult: boolean; begin - Result:= Out.AddLine(Line) and AddLine(Line); + outresult:= Out.AddLine(Line); + logresult:= AddLine(Line); + Result:= outresult and logresult; end; function TLogger.AddStdLine(Agent, Line: string): boolean; { Log message to both stdout and smtp.log. } +var outresult, logresult: boolean; begin - Result:= Out.AddLine(Agent, Line) and AddLine(Agent, Line); + outresult:= Out.AddLine(Agent, Line); + logresult:= AddLine(Agent, Line); + Result:= outresult and logresult; end; diff --git a/MgSMTP.pas b/MgSMTP.pas index 79821d9..438f0b6 100644 --- a/MgSMTP.pas +++ b/MgSMTP.pas @@ -49,7 +49,7 @@ const document what bugfix/feature are you testing with the actual build. This will be logged to help you differentiate outputs of subsequent builds in your logs. If left empty, it won't be added to the logs. } - DEVCOMMENT = 'ListenAddress'; + DEVCOMMENT = 'Wine 1.6 AddStdLine fix'; var -- 2.34.1