Move MTProxy policy engine from tgnet/ to self-contained jni/mtproxy/ module. Consolidate reconnect hold computation into single MtProxyRetryAuthority owner (was split across Connection, ConnectionSocket, endpoint policy, and probe coordinator, causing hold misalignment bugs). Add MtProxyTerminalDiagnostic module with host tests for pre-I/O verdict preservation (fixes 02.07/30.06 clobber livelocks). Auto-generate phase classification (isPreIoTerminalVerdict, needsReconnectBackoff, isObservationFacadePhase, isLocalSchedulerTimeout) from single Python contract into both C++ and Java to eliminate parallel maintenance. Pass native hold (coordinator terminal hold + endpoint cooldown) via JNI to Java so reconnect timer and health store use THE clock, not re-derived ones. Optimize log flushing: batch debug lines, flush errors immediately. Add module boundary guard, host build system (MSVC), and unit tests for retry logic and terminal diagnostic derivation.
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
/*
|
|
* This is the source code of tgnet library v. 1.1
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
*/
|
|
|
|
#ifndef MTPROXYTERMINALDIAGNOSTIC_H
|
|
#define MTPROXYTERMINALDIAGNOSTIC_H
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
|
|
#include "MtProxyStartupTimeline.h"
|
|
|
|
// Pure derivation of the terminal close diagnostic from module-visible
|
|
// facts. ConnectionSocket::deriveMtProxyTerminalDiagnostic is a thin
|
|
// wrapper: it gates on isCurrentMtProxyConnection()/reason and performs
|
|
// the logging side effects; the classification decision lives here so it
|
|
// is host-compiled and cannot silently diverge from the phase contract.
|
|
namespace MtProxyPhase {
|
|
|
|
struct TerminalDiagnosticInput {
|
|
// Current proxyCheckDiagnostic value at close time.
|
|
const char *currentDiagnostic = "";
|
|
const MtProxyStartupTimeline *timeline = nullptr;
|
|
bool socketConnectedLogged = false;
|
|
int32_t closeReason = 0;
|
|
// errno captured on the socket (0 when none).
|
|
int32_t socketError = 0;
|
|
};
|
|
|
|
struct TerminalDiagnosticResult {
|
|
std::string diagnostic;
|
|
// True when the diagnostic was re-derived from the local startup
|
|
// timeline; the caller re-runs its pre-TCP timeout classification for
|
|
// logging in that case (matching the historical side-effect order).
|
|
bool timelineDerived = false;
|
|
};
|
|
|
|
TerminalDiagnosticResult deriveTerminalDiagnostic(const TerminalDiagnosticInput &input);
|
|
|
|
}
|
|
|
|
#endif
|