mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Avoid logging pre-verstring EPIPE from sharing downstreams.
If you use the new 'plink -shareexists' feature, then on Unix at least it's possible for the upstream to receive EPIPE, because the downstream makes a test connection and immediately closes it, so that upstream fails to write its version string. This looks a bit ugly in the upstream's Event Log, so I'm making a special case: an error of 'broken pipe' type, which occurs on a socket from a connection sharing downstream, before we've received a version string from that downstream, is treated as an unusual kind of normal connection termination and not logged as an error.
This commit is contained in:
parent
7c2ea22784
commit
5133d2a133
23
sshshare.c
23
sshshare.c
@ -133,6 +133,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
#include "tree234.h"
|
#include "tree234.h"
|
||||||
@ -914,8 +915,26 @@ static int share_closing(Plug plug, const char *error_msg, int error_code,
|
|||||||
int calling_back)
|
int calling_back)
|
||||||
{
|
{
|
||||||
struct ssh_sharing_connstate *cs = (struct ssh_sharing_connstate *)plug;
|
struct ssh_sharing_connstate *cs = (struct ssh_sharing_connstate *)plug;
|
||||||
if (error_msg)
|
|
||||||
ssh_sharing_logf(cs->parent->ssh, cs->id, "%s", error_msg);
|
if (error_msg) {
|
||||||
|
#ifdef BROKEN_PIPE_ERROR_CODE
|
||||||
|
/*
|
||||||
|
* Most of the time, we log what went wrong when a downstream
|
||||||
|
* disappears with a socket error. One exception, though, is
|
||||||
|
* receiving EPIPE when we haven't received a protocol version
|
||||||
|
* string from the downstream, because that can happen as a result
|
||||||
|
* of plink -shareexists (opening the connection and instantly
|
||||||
|
* closing it again without bothering to read our version string).
|
||||||
|
* So that one case is not treated as a log-worthy error.
|
||||||
|
*/
|
||||||
|
printf("%d %d\n", error_code, cs->got_verstring);
|
||||||
|
if (error_code == BROKEN_PIPE_ERROR_CODE && !cs->got_verstring)
|
||||||
|
/* do nothing */;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
ssh_sharing_logf(cs->parent->ssh, cs->id,
|
||||||
|
"Socket error: %s", error_msg);
|
||||||
|
}
|
||||||
share_begin_cleanup(cs);
|
share_begin_cleanup(cs);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@ typedef void *Context; /* FIXME: probably needs changing */
|
|||||||
|
|
||||||
extern Backend pty_backend;
|
extern Backend pty_backend;
|
||||||
|
|
||||||
|
#define BROKEN_PIPE_ERROR_CODE EPIPE /* used in sshshare.c */
|
||||||
|
|
||||||
typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
|
typedef uint32_t uint32; /* C99: uint32_t defined in stdint.h */
|
||||||
#define PUTTY_UINT32_DEFINED
|
#define PUTTY_UINT32_DEFINED
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ struct FontSpec *fontspec_new(const char *name,
|
|||||||
#define PLATFORM_HAS_SMEMCLR /* inhibit cross-platform one in misc.c */
|
#define PLATFORM_HAS_SMEMCLR /* inhibit cross-platform one in misc.c */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BROKEN_PIPE_ERROR_CODE ERROR_BROKEN_PIPE /* used in sshshare.c */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dynamically linked functions. These come in two flavours:
|
* Dynamically linked functions. These come in two flavours:
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user