From 28a94a4ad733a13a3bf6d27f6c3c4936708fc131 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 9 Jul 2003 22:53:55 +0000 Subject: [PATCH] Change OS_bind_tcp_server_socket to set SO_REUSEADDR. --- v7/src/microcode/syscall.h | 5 +++-- v7/src/microcode/uxsock.c | 22 +++++++++++++++++----- v7/src/microcode/uxtop.c | 5 +++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/v7/src/microcode/syscall.h b/v7/src/microcode/syscall.h index 69efa12d2..77fac4dcf 100644 --- a/v7/src/microcode/syscall.h +++ b/v7/src/microcode/syscall.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: syscall.h,v 1.16 2003/07/09 04:13:44 cph Exp $ +$Id: syscall.h,v 1.17 2003/07/09 22:53:51 cph Exp $ Copyright 1993,1994,1995,1996,1997,1999 Massachusetts Institute of Technology Copyright 2000,2003 Massachusetts Institute of Technology @@ -109,7 +109,8 @@ enum syscall_names syscall_mktime, syscall_dld, syscall_statfs, - syscall_fstatfs + syscall_fstatfs, + syscall_setsockopt }; enum syserr_names diff --git a/v7/src/microcode/uxsock.c b/v7/src/microcode/uxsock.c index 0268b5dfb..8b6852db7 100644 --- a/v7/src/microcode/uxsock.c +++ b/v7/src/microcode/uxsock.c @@ -1,8 +1,9 @@ /* -*-C-*- -$Id: uxsock.c,v 1.30 2003/02/14 18:28:24 cph Exp $ +$Id: uxsock.c,v 1.31 2003/07/09 22:53:38 cph Exp $ -Copyright (c) 1990-2001 Massachusetts Institute of Technology +Copyright 1993,1996,1997,1998,1999,2000 Massachusetts Institute of Technology +Copyright 2001,2003 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -251,13 +252,24 @@ DEFUN (OS_bind_tcp_server_socket, (channel, host, port), unsigned int port) { struct sockaddr_in address; + int one = 1; + (address . sin_family) = AF_INET; memcpy ((& (address . sin_addr)), host, (sizeof (address . sin_addr))); (address . sin_port) = port; + + STD_VOID_SYSTEM_CALL + (syscall_setsockopt, + (setsockopt ((CHANNEL_DESCRIPTOR (channel)), + SOL_SOCKET, + SO_REUSEADDR, + (&one), + (sizeof (one))))); STD_VOID_SYSTEM_CALL - (syscall_bind, (UX_bind ((CHANNEL_DESCRIPTOR (channel)), - ((struct sockaddr *) (&address)), - (sizeof (struct sockaddr_in))))); + (syscall_bind, + (UX_bind ((CHANNEL_DESCRIPTOR (channel)), + ((struct sockaddr *) (&address)), + (sizeof (struct sockaddr_in))))); } #ifndef SOCKET_LISTEN_BACKLOG diff --git a/v7/src/microcode/uxtop.c b/v7/src/microcode/uxtop.c index f5dd9af8d..28653b860 100644 --- a/v7/src/microcode/uxtop.c +++ b/v7/src/microcode/uxtop.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxtop.c,v 1.29 2003/07/09 04:13:33 cph Exp $ +$Id: uxtop.c,v 1.30 2003/07/09 22:53:55 cph Exp $ Copyright 1990,1991,1992,1993,1994,1995 Massachusetts Institute of Technology Copyright 1996,1997,1999,2000,2002,2003 Massachusetts Institute of Technology @@ -386,7 +386,8 @@ static char * syscall_names_table [] = "mktime", "dynamic-load", "statfs", - "fstatfs" + "fstatfs", + "setsockopt" }; void -- 2.25.1