1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Optimizing startup time by delaying neon SSPI initialization until the first WebDAV/S3 connection

Assuming we do not need SSPI for plain HTTPS connections (like updates check)

Source commit: c9dd331a99d5fe0d0ba97aa2210e3b4e5689ad35
This commit is contained in:
Martin Prikryl
2025-08-19 09:18:11 +00:00
parent 1601a5baa5
commit c45ae10ded
2 changed files with 32 additions and 30 deletions

View File

@@ -345,6 +345,13 @@ int ne_sock_init(void)
if (err != 0) {
return init_state = -1;
}
#ifndef WINSCP
#ifdef HAVE_SSPI
if (ne_sspi_init() < 0) {
return init_state = -1;
}
#endif
#endif
#endif
#ifdef NE_HAVE_SOCKS
@@ -366,16 +373,6 @@ int ne_sock_init(void)
#endif
init_state = 1;
#ifdef WIN32
#ifdef HAVE_SSPI
// This fails on Wine, and we do not want to abort
// whole Neon initialization because of that
if (ne_sspi_init() < 0) {
return -2;
}
#endif
#endif
return 0;
}

View File

@@ -17,6 +17,11 @@
#include <ne_redirect.h>
#include <ne_xmlreq.h>
#include <ne_locks.h>
// ne_sspi.h is not a public interface, so it is not ready to be included from C++
#define HAVE_SSPI
NE_BEGIN_DECLS
#include <ne_sspi.h>
NE_END_DECLS
#include <expat.h>
#include "WebDAVFileSystem.h"
@@ -89,31 +94,14 @@ static UnicodeString PathUnescape(const char * Path)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
static bool NeonInitialized = false;
static bool NeonSspiInitialized = false;
static int NeonSspiInitialized = -1;
//---------------------------------------------------------------------------
void __fastcall NeonInitialize()
{
// Even if this fails, we do not want to interrupt WinSCP starting for that.
// Anyway, it can hardly fail.
// Though it fails on Wine on Debian VM, because of ne_sspi_init():
// sspi: QuerySecurityPackageInfo [failed] [80090305].
// sspi: Unable to get negotiate maximum packet size
int NeonResult = ne_sock_init();
if (NeonResult == 0)
{
NeonInitialized = true;
NeonSspiInitialized = true;
}
else if (NeonResult == -2)
{
NeonInitialized = true;
NeonSspiInitialized = false;
}
else
{
NeonInitialized = false;
NeonSspiInitialized = false;
}
NeonInitialized = (NeonResult == 0);
}
//---------------------------------------------------------------------------
void __fastcall NeonFinalize()
@@ -122,6 +110,7 @@ void __fastcall NeonFinalize()
{
ne_sock_exit();
NeonInitialized = false;
NeonSspiInitialized = -1;
}
}
//---------------------------------------------------------------------------
@@ -132,7 +121,23 @@ void __fastcall RequireNeon(TTerminal * Terminal)
throw Exception(LoadStr(NEON_INIT_FAILED2));
}
if (!NeonSspiInitialized)
if (NeonSspiInitialized < 0)
{
// This fails on Wine on Debian VM:
// sspi: QuerySecurityPackageInfo [failed] [80090305].
// sspi: Unable to get negotiate maximum packet size
// This takes about second, when debugging, that's why it is postponed until the first connection.
if (ne_sspi_init() < 0)
{
NeonSspiInitialized = 0;
}
else
{
NeonSspiInitialized = 1;
}
}
if (NeonSspiInitialized <= 0)
{
Terminal->LogEvent(L"Warning: SSPI initialization failed.");
}