On Mon, Mar 14, 2016 at 11:03 AM, Kenneth Mastro <[email protected]>
wrote:

> I don't know anything about using external loggers with MHD and this isn't
> really any of my business, but filtering log messages based on the string
> seems like a bad idea.  That string could change in future releases (plus I
> guess you're doing extra string comparisons, but I doubt that amounts to
> very much).
>

I agree. And filtering/handling logs/errors using strings is a little bit
slow.


> If MHD doesn't provide some kind of 'message code' or a #define constant
> for the string (so you could compare it to something consistent), then
> maybe you could just log an extra message before you return MHD_NO?  E.g.,
> "Ignore the following message - there is no error - connection was
> intentionally refused."
>

I use this approach too, and I have a code for each message. It is very
nice because I can check the messagens using the `switch` statement.

Unfortunatelly MHD doesn't have error codes, but a quick fix to solve this
problem keeping the compatibility could be define this strings in
constants, so it would be nice to use something like this:

if (msg != MHD_internal_app_error)
 ...

Instead of:

if (msg != "Internal application error, closing connection.\n")
 ...

Maybe it's just me, but I always try to promote easy maintenance and avoid
> fragility whenever it's reasonably possible.  This seems like one of those
> times, albeit for a pretty minor thing.
>

Me too. It should be:

if (msg_code != MHD_code_internal_app_error)
 ...

// MHD_msg_internal_app_error = "Internal application error, closing
connection.\n"
// MHD_code_internal_app_error = 1000

-- 
Silvio Clécio

Reply via email to