- if(!cb->conn_forced_closed || cb->send_buf_free== 0)
- {
- /*when not forced connection*/
- /*or buffer not initialized -- happens if forceReconnect happens before first connection*/
+
+ /* wg_force_reconnect_check does not flush the buffer before closing a
+ * sending socket, so only call wg_reset_buffer() if the socket was closed
+ * for a different reason (tracked in cb->reconnect_interval_reached). */
+ if (!cb->reconnect_interval_reached || (cb->send_buf_free == 0))