mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00: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:
parent
d1f62c3e0f
commit
4f3f4ed691
@ -88,7 +88,6 @@ void set_raw_mouse_mode(void *frontend, int m) { }
|
||||
void request_paste(void *frontend) { }
|
||||
void do_beep(void *frontend, int a) { }
|
||||
void sys_cursor(void *frontend, int x, int y) { }
|
||||
void fatalbox(const char *fmt, ...) { exit(0); }
|
||||
void modalfatalbox(const char *fmt, ...) { exit(0); }
|
||||
void nonfatal(const char *fmt, ...) { }
|
||||
|
||||
|
15
pscp.c
15
pscp.c
@ -91,21 +91,6 @@ static void tell_user(FILE *stream, const char *fmt, ...)
|
||||
/*
|
||||
* Print an error message and perform a fatal exit.
|
||||
*/
|
||||
void fatalbox(const char *fmt, ...)
|
||||
{
|
||||
char *str, *str2;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
str = dupvprintf(fmt, ap);
|
||||
str2 = dupcat("Fatal: ", str, "\n", NULL);
|
||||
sfree(str);
|
||||
va_end(ap);
|
||||
tell_str(stderr, str2);
|
||||
sfree(str2);
|
||||
errs++;
|
||||
|
||||
cleanup_exit(1);
|
||||
}
|
||||
void modalfatalbox(const char *fmt, ...)
|
||||
{
|
||||
char *str, *str2;
|
||||
|
14
psftp.c
14
psftp.c
@ -2442,20 +2442,6 @@ static int verbose = 0;
|
||||
/*
|
||||
* Print an error message and perform a fatal exit.
|
||||
*/
|
||||
void fatalbox(const char *fmt, ...)
|
||||
{
|
||||
char *str, *str2;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
str = dupvprintf(fmt, ap);
|
||||
str2 = dupcat("Fatal: ", str, "\n", NULL);
|
||||
sfree(str);
|
||||
va_end(ap);
|
||||
fputs(str2, stderr);
|
||||
sfree(str2);
|
||||
|
||||
cleanup_exit(1);
|
||||
}
|
||||
void modalfatalbox(const char *fmt, ...)
|
||||
{
|
||||
char *str, *str2;
|
||||
|
2
putty.h
2
putty.h
@ -642,10 +642,8 @@ void optimised_move(void *frontend, int, int, int);
|
||||
void set_raw_mouse_mode(void *frontend, int);
|
||||
void connection_fatal(void *frontend, const char *, ...);
|
||||
void nonfatal(const char *, ...);
|
||||
void fatalbox(const char *, ...);
|
||||
void modalfatalbox(const char *, ...);
|
||||
#ifdef macintosh
|
||||
#pragma noreturn(fatalbox)
|
||||
#pragma noreturn(modalfatalbox)
|
||||
#endif
|
||||
void do_beep(void *frontend, int);
|
||||
|
26
terminal.c
26
terminal.c
@ -1085,19 +1085,19 @@ static termline *lineptr(Terminal *term, int y, int lineno, int screen)
|
||||
|
||||
/* We assume that we don't screw up and retrieve something out of range. */
|
||||
if (line == NULL) {
|
||||
fatalbox("line==NULL in terminal.c\n"
|
||||
"lineno=%d y=%d w=%d h=%d\n"
|
||||
"count(scrollback=%p)=%d\n"
|
||||
"count(screen=%p)=%d\n"
|
||||
"count(alt=%p)=%d alt_sblines=%d\n"
|
||||
"whichtree=%p treeindex=%d\n\n"
|
||||
"Please contact <putty@projects.tartarus.org> "
|
||||
"and pass on the above information.",
|
||||
lineno, y, term->cols, term->rows,
|
||||
term->scrollback, count234(term->scrollback),
|
||||
term->screen, count234(term->screen),
|
||||
term->alt_screen, count234(term->alt_screen), term->alt_sblines,
|
||||
whichtree, treeindex);
|
||||
modalfatalbox("line==NULL in terminal.c\n"
|
||||
"lineno=%d y=%d w=%d h=%d\n"
|
||||
"count(scrollback=%p)=%d\n"
|
||||
"count(screen=%p)=%d\n"
|
||||
"count(alt=%p)=%d alt_sblines=%d\n"
|
||||
"whichtree=%p treeindex=%d\n\n"
|
||||
"Please contact <putty@projects.tartarus.org> "
|
||||
"and pass on the above information.",
|
||||
lineno, y, term->cols, term->rows,
|
||||
term->scrollback, count234(term->scrollback),
|
||||
term->screen, count234(term->screen),
|
||||
term->alt_screen, count234(term->alt_screen),
|
||||
term->alt_sblines, whichtree, treeindex);
|
||||
}
|
||||
assert(line != NULL);
|
||||
|
||||
|
@ -3705,18 +3705,6 @@ void nonfatal_message_box(void *window, const char *msg)
|
||||
FALSE, &buttons_ok);
|
||||
}
|
||||
|
||||
void fatalbox(const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *msg;
|
||||
va_start(ap, p);
|
||||
msg = dupvprintf(p, ap);
|
||||
va_end(ap);
|
||||
fatal_message_box(NULL, msg);
|
||||
sfree(msg);
|
||||
cleanup_exit(1);
|
||||
}
|
||||
|
||||
void nonfatal(const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -23,16 +23,6 @@
|
||||
SockAddr unix_sock_addr(const char *path);
|
||||
Socket new_unix_listener(SockAddr listenaddr, Plug plug);
|
||||
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
void modalfatalbox(const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -29,23 +29,6 @@ static void *logctx;
|
||||
|
||||
static struct termios orig_termios;
|
||||
|
||||
void fatalbox(const char *p, ...)
|
||||
{
|
||||
struct termios cf;
|
||||
va_list ap;
|
||||
premsg(&cf);
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
va_start(ap, p);
|
||||
vfprintf(stderr, p, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
postmsg(&cf);
|
||||
if (logctx) {
|
||||
log_free(logctx);
|
||||
logctx = NULL;
|
||||
}
|
||||
cleanup_exit(1);
|
||||
}
|
||||
void modalfatalbox(const char *p, ...)
|
||||
{
|
||||
struct termios cf;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user