dialog: prevent double free in case of errors

(cherry picked from commit eef59c1d7b47ecc35438c01e7dcbdfeea903115a)
QM_MALLOC: proper fragment debugging patterns for x86_64
(cherry picked from commit cd201b680102ffcbe554851d1e6f44ace3c72daa)
core: improve CPU usage of the TCP_MAIN process

	* iterate through and close connections at most once per second
(cherry picked from commit 3ac3b042c7b74cc6c84af0a987ac65cde17f8e6b)

Conflicts:

	tcp_main.c
(cherry picked from commit 3a8fdd9470d36e867b9f4ee0346efe3a7b03250c)