mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Get rid of fatalbox() completely.
It's an incoherent concept! There should not be any such thing as an error box that terminates the entire program but is not modal. If it's bad enough to terminate the whole program, i.e. _all_ currently live connections, then there's no point in permitting progress to continue in windows other than the affected one, because all windows are affected anyway. So all previous uses of fatalbox() have become modalfatalbox(), except those which looked to me as if they shouldn't have been fatal in the first place, e.g. lingering pieces of error handling in winnet.c which ought to have had the severity of 'give up on this particular Socket and close it' rather than 'give up on the ENTIRE UNIVERSE'.
This commit is contained in:
@ -5522,23 +5522,6 @@ void optimised_move(void *frontend, int to, int from, int lines)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print a message box and perform a fatal exit.
|
||||
*/
|
||||
void fatalbox(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *stuff, morestuff[100];
|
||||
|
||||
va_start(ap, fmt);
|
||||
stuff = dupvprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
sprintf(morestuff, "%.70s Fatal Error", appname);
|
||||
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
|
||||
sfree(stuff);
|
||||
cleanup_exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a modal (Really Bad) message box and perform a fatal exit.
|
||||
*/
|
||||
|
@ -257,7 +257,7 @@ void sk_init(void)
|
||||
winsock_module = load_system32_dll("wsock32.dll");
|
||||
}
|
||||
if (!winsock_module)
|
||||
fatalbox("Unable to load any WinSock library");
|
||||
modalfatalbox("Unable to load any WinSock library");
|
||||
|
||||
#ifndef NO_IPV6
|
||||
/* Check if we have getaddrinfo in Winsock */
|
||||
@ -348,7 +348,7 @@ void sk_init(void)
|
||||
if (!sk_startup(2,2) &&
|
||||
!sk_startup(2,0) &&
|
||||
!sk_startup(1,1)) {
|
||||
fatalbox("Unable to initialise WinSock");
|
||||
modalfatalbox("Unable to initialise WinSock");
|
||||
}
|
||||
|
||||
sktree = newtree234(cmpfortree);
|
||||
@ -1529,26 +1529,20 @@ void try_send(Actual_Socket s)
|
||||
*/
|
||||
s->writable = FALSE;
|
||||
return;
|
||||
} else if (nsent == 0 ||
|
||||
err == WSAECONNABORTED || err == WSAECONNRESET) {
|
||||
} else {
|
||||
/*
|
||||
* If send() returns CONNABORTED or CONNRESET, we
|
||||
* unfortunately can't just call plug_closing(),
|
||||
* because it's quite likely that we're currently
|
||||
* _in_ a call from the code we'd be calling back
|
||||
* to, so we'd have to make half the SSH code
|
||||
* reentrant. Instead we flag a pending error on
|
||||
* the socket, to be dealt with (by calling
|
||||
* plug_closing()) at some suitable future moment.
|
||||
* If send() returns a socket error, we unfortunately
|
||||
* can't just call plug_closing(), because it's quite
|
||||
* likely that we're currently _in_ a call from the
|
||||
* code we'd be calling back to, so we'd have to make
|
||||
* half the SSH code reentrant. Instead we flag a
|
||||
* pending error on the socket, to be dealt with (by
|
||||
* calling plug_closing()) at some suitable future
|
||||
* moment.
|
||||
*/
|
||||
s->pending_error = err;
|
||||
queue_toplevel_callback(socket_error_callback, s);
|
||||
return;
|
||||
} else {
|
||||
/* We're inside the Windows frontend here, so we know
|
||||
* that the frontend handle is unnecessary. */
|
||||
logevent(NULL, winsock_error_string(err));
|
||||
fatalbox("%s", winsock_error_string(err));
|
||||
}
|
||||
} else {
|
||||
if (s->sending_oob) {
|
||||
@ -1738,12 +1732,8 @@ void select_result(WPARAM wParam, LPARAM lParam)
|
||||
ret = p_recv(s->s, buf, sizeof(buf), MSG_OOB);
|
||||
noise_ultralight(ret);
|
||||
if (ret <= 0) {
|
||||
const char *str = (ret == 0 ? "Internal networking trouble" :
|
||||
winsock_error_string(p_WSAGetLastError()));
|
||||
/* We're inside the Windows frontend here, so we know
|
||||
* that the frontend handle is unnecessary. */
|
||||
logevent(NULL, str);
|
||||
fatalbox("%s", str);
|
||||
int err = p_WSAGetLastError();
|
||||
plug_closing(s->plug, winsock_error_string(err), err, 0);
|
||||
} else {
|
||||
plug_receive(s->plug, 2, buf, ret);
|
||||
}
|
||||
|
@ -22,20 +22,6 @@ struct agent_callback {
|
||||
int len;
|
||||
};
|
||||
|
||||
void fatalbox(const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
va_start(ap, p);
|
||||
vfprintf(stderr, p, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
if (logctx) {
|
||||
log_free(logctx);
|
||||
logctx = NULL;
|
||||
}
|
||||
cleanup_exit(1);
|
||||
}
|
||||
void modalfatalbox(const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
Reference in New Issue
Block a user