summaryrefslogtreecommitdiff
path: root/canohost.c
diff options
context:
space:
mode:
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/canohost.c b/canohost.c
index 057f061b6..8ad684d6c 100644
--- a/canohost.c
+++ b/canohost.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: canohost.c,v 1.40 2004/06/21 17:36:31 avsm Exp $"); 15RCSID("$OpenBSD: canohost.c,v 1.41 2004/07/21 11:51:29 djm Exp $");
16 16
17#include "packet.h" 17#include "packet.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -382,7 +382,13 @@ get_peer_port(int sock)
382int 382int
383get_remote_port(void) 383get_remote_port(void)
384{ 384{
385 return get_port(0); 385 static int port = -1;
386
387 /* Cache to avoid getpeername() on a dead connection */
388 if (port == -1)
389 port = get_port(0);
390
391 return port;
386} 392}
387 393
388int 394int