Semi-address reentrancy issues caused by waitForBytesWritten before exec().
Semi-address reentrancy issues caused by waitForBytesWritten before exec().

If a client sends commands without waiting for the greeting message we
crashed in slotNewData because the parser had not been initialized yet.
Similarly, if we get LOGOUT before exec() we could in theory leak a session
thread.

The first issue is fixed by simple reordering, to fully fix this we would
need to ensure the greeting isn't send before exec() (and thus no data can
be received before that, as a side-effect of waitForBytesWritten()). This
however can't be done with a queued connection, since "this" belongs to the
wrong thread. Fixing this requires a bit of refactoring of the session
thread.

Anyway, nothing of this is relevant for real-world clients (they need the
greeting for the protocol version before sending anything), but only for
running automated raw protocol tests with socat/asapcat, and for that case
we at least don't crash anymore now.

kolab-groupware/akonadi,kolab-groupware/akonadi,kolab-groupware/akonadi,kolab-groupware/akonadi