I don't really know enough about this to offer a strong opinion. With that caveat in place...
I
tend to try to write code that is 'fault tolerant' when possible - if
I'm asking the code to do something that's already done, it ends up
being a no-op. When writing multi-threaded code, that's usually a lot
easier than dealing with the (possible) error.
In this case
- I see Christian's point. This could be a serious error in the app.
However - with what I just said above in mind - maybe MHD being "nicer"
about it would be helpful in some situations.
As a
compromise, how about some way to just ask MHD if the connection is
already suspended? If you have a situation like Flavio's, he'd still
have to do the check, but at least this way he's not having to keep a
parallel state in his code. I.e., he could write his own 'suspend'
function that checks if it's suspended and just makes the MHD suspend call if it's not. Not
dissimilar to what he's doing now, but the storage is probably more
reliable.