#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include "putty.h"
/* the above field _must_ be first in the structure */
Socket s;
+ int closed_on_socket_error;
int bufsize;
void *frontend;
int sent_console_eof, sent_socket_eof;
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
logevent(raw->frontend, msg);
+ sfree(msg);
}
static void raw_check_close(Raw raw)
if (raw->s) {
sk_close(raw->s);
raw->s = NULL;
+ raw->closed_on_socket_error = TRUE;
notify_remote_exit(raw->frontend);
}
logevent(raw->frontend, error_msg);
raw = snew(struct raw_backend_data);
raw->fn = &fn_table;
raw->s = NULL;
+ raw->closed_on_socket_error = FALSE;
*backend_handle = raw;
raw->sent_console_eof = raw->sent_socket_eof = FALSE;
sfree(*realhost);
*realhost = dupstr(loghost);
- colon = strrchr(*realhost, ':');
- if (colon) {
- /*
- * FIXME: if we ever update this aspect of ssh.c for
- * IPv6 literal management, this should change in line
- * with it.
- */
+
+ colon = host_strrchr(*realhost, ':');
+ if (colon)
*colon++ = '\0';
- }
}
return NULL;
Raw raw = (Raw) handle;
if (raw->s != NULL)
return -1; /* still connected */
+ else if (raw->closed_on_socket_error)
+ return INT_MAX; /* a socket error counts as an unclean exit */
else
/* Exit codes are a meaningless concept in the Raw protocol */
return 0;