This commit ensures that write callbacks are getting called only after the data has been sent via the network.
Without this fix, a situation could appear when a write callback could get called before the actual encrypted data would have been sent to the network. Instead, it would get called right after it would have been passed to the OpenSSL (i.e. encrypted).
Most likely, the issue does not reveal itself often because the callback call was asynchronous, so in most cases it should have been called after the data has been sent, but that was not guaranteed by the code logic.
Also, this commit removes one memory allocation (netievent) from a hot path, as there is no need to call this callback asynchronously anymore.
Closes #3271 (closed)