Bugzilla bug #17188: NSPR should not automatically set the SO_KEEPALIVE
authorwtc%netscape.com
Tue, 26 Oct 1999 22:58:55 +0000
changeset 910 44fd468dfc569589d4eec76d9c25c1da847418ad
parent 909 4651a2475b39b2056dc29a4ec283d39ca412c7a3
child 911 66a094e85c597d4798253491707618ab380d6fbd
push idunknown
push userunknown
push dateunknown
bugs17188
Bugzilla bug #17188: NSPR should not automatically set the SO_KEEPALIVE socket option on a new TCP socket. The HAVE_SOCKET_KEEPALIVE macro is obsolete. r=srinivas@netscape.com. Modified files: _beos.h, _os2.h, _unixos.h, _win16.h, _win95.h, _winnt.h, prsocket.c, and ptio.c.
pr/include/md/_beos.h
pr/include/md/_os2.h
pr/include/md/_unixos.h
pr/include/md/_win16.h
pr/include/md/_win95.h
pr/include/md/_winnt.h
pr/src/io/prsocket.c
pr/src/pthreads/ptio.c
--- a/pr/include/md/_beos.h
+++ b/pr/include/md/_beos.h
@@ -138,18 +138,16 @@ struct _MDDir {
     DIR		*d;
 };
 
 #define PR_DIRECTORY_SEPARATOR		'/'
 #define PR_DIRECTORY_SEPARATOR_STR	"/"
 #define PR_PATH_SEPARATOR		':'
 #define PR_PATH_SEPARATOR_STR		":"
 
-#undef HAVE_SOCKET_KEEPALIVE
-
 #define GETTIMEOFDAY(tp)	gettimeofday((tp), NULL)
 
 /* --- Memory-mapped files stuff --- not implemented on BeOS */
 
 struct _MDFileMap {
     PRInt8 unused;
 };
 
--- a/pr/include/md/_os2.h
+++ b/pr/include/md/_os2.h
@@ -50,17 +50,16 @@
  */
 
 #define PR_LINKER_ARCH      "os2"
 #define _PR_SI_SYSNAME        "OS2"
 #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
 
 #define HAVE_DLL
 #undef  HAVE_THREAD_AFFINITY
-#define HAVE_SOCKET_KEEPALIVE
 #undef  _PR_HAVE_ATOMIC_OPS
 
 #define HANDLE unsigned long
 #define HINSTANCE HMODULE
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 /* --- Globals --- */
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -437,18 +437,16 @@ extern PRStatus _MD_set_fd_inheritable(P
 extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
 #define _MD_GETHOSTNAME		_MD_gethostname
 
 extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);
 #define _MD_GETSYSINFO		_MD_getsysinfo
 
 extern int _MD_unix_get_nonblocking_connect_error(int osfd);
 
-#define HAVE_SOCKET_KEEPALIVE
-
 /* Memory-mapped files */
 
 struct _MDFileMap {
     PRIntn prot;
     PRIntn flags;
     PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */
 };
 
--- a/pr/include/md/_win16.h
+++ b/pr/include/md/_win16.h
@@ -36,17 +36,16 @@
 #define _PR_SI_SYSNAME        "WIN16"
 #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
 
 #define HAVE_DLL
 #define _PR_NO_PREEMPT
 #define _PR_LOCAL_THREADS_ONLY
 #undef  _PR_GLOBAL_THREADS_ONLY
 #undef  HAVE_THREAD_AFFINITY
-#define HAVE_SOCKET_KEEPALIVE
 #define _PR_HAVE_ATOMIC_OPS
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 extern struct PRLock        *_pr_schedLock;
 extern char                 * _pr_top_of_task_stack;
 
 
--- a/pr/include/md/_win95.h
+++ b/pr/include/md/_win95.h
@@ -30,17 +30,16 @@
  */
 
 #define PR_LINKER_ARCH      "win32"
 #define _PR_SI_SYSNAME        "WIN95"
 #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
 
 #define HAVE_DLL
 #undef  HAVE_THREAD_AFFINITY
-#define HAVE_SOCKET_KEEPALIVE
 #define _PR_HAVE_ATOMIC_OPS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 /* --- Globals --- */
 extern struct PRLock                      *_pr_schedLock;
 
--- a/pr/include/md/_winnt.h
+++ b/pr/include/md/_winnt.h
@@ -42,17 +42,16 @@
 
 #define PR_LINKER_ARCH      "win32"
 #define _PR_SI_SYSNAME        "WINNT"
 #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
 
 #define HAVE_DLL
 #define HAVE_CUSTOM_USER_THREADS
 #define HAVE_THREAD_AFFINITY
-#define HAVE_SOCKET_KEEPALIVE
 #define _PR_HAVE_ATOMIC_OPS
 #define _PR_HAVE_ATOMIC_CAS
 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
 
 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
 
 /* --- Globals --- */
 extern struct PRLock                      *_pr_schedLock;
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -1178,17 +1178,16 @@ static const PRIOMethods* PR_GetSocketPo
 {
     return &socketpollfdMethods;
 }  /* PR_GetSocketPollFdMethods */
 
 
 PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
 {
 	PRInt32 osfd;
-	int one = 1;
 	PRFileDesc *fd;
 
 	if (!_pr_initialized) _PR_ImplicitInitialization();
 	if (AF_INET != domain
 #if defined(_PR_INET6)
 			&& AF_INET6 != domain
 #endif
 #if defined(XP_UNIX)
@@ -1197,34 +1196,16 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRIn
 			) {
 		PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
 		return NULL;
 	}
 	osfd = _PR_MD_SOCKET(domain, type, proto);
 	if (osfd == -1) {
 		return 0;
 	}
-#ifdef HAVE_SOCKET_KEEPALIVE
-	/* "Keep-alive" packets are specific to TCP. */
-	if ((domain == AF_INET
-#if defined(_PR_INET6)
-			|| domain == AF_INET6
-#endif
-			) && type == SOCK_STREAM) {
-		if (setsockopt(osfd, (int)SOL_SOCKET, SO_KEEPALIVE,
-#ifdef XP_OS2_VACPP
-            (char *)&one, sizeof(one) ) < 0) {
-#else
-		    (const void *) &one, sizeof(one) ) < 0) {
-#endif
-			_PR_MD_CLOSE_SOCKET(osfd);
-			return 0;
-		}
-	}
-#endif
 	if (type == SOCK_STREAM)
 		fd = PR_AllocFileDesc(osfd, PR_GetTCPMethods());
 	else
 		fd = PR_AllocFileDesc(osfd, PR_GetUDPMethods());
 	/*
 	 * Make the sockets non-blocking
 	 */
 	if (fd != NULL)
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -3067,17 +3067,17 @@ static PRIOMethods _pr_socketpollfd_meth
     || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO)
 #define _PR_FCNTL_FLAGS O_NONBLOCK
 #else
 #error "Can't determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type)
 {
-    PRInt32 flags, one = 1;
+    PRInt32 flags;
     PRFileDesc *fd = _PR_Getfd();
     
     if (fd == NULL) PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     else
     {
         fd->secret->md.osfd = osfd;
         fd->secret->state = _PR_FILEDESC_OPEN;
         /* By default, a Unix fd is not closed on exec. */
@@ -3096,18 +3096,16 @@ static PRFileDesc *pt_SetMethods(PRIntn 
             case PR_DESC_FILE:
                 fd->methods = PR_GetFileMethods();
                 break;
             case PR_DESC_SOCKET_TCP:
                 fd->methods = PR_GetTCPMethods();
                 flags = fcntl(osfd, F_GETFL, 0);
                 flags |= _PR_FCNTL_FLAGS;
                 (void)fcntl(osfd, F_SETFL, flags);
-                (void)setsockopt(osfd, SOL_SOCKET, SO_KEEPALIVE,
-                    (_PRSockOptVal_t) &one, sizeof(one));
                 break;
             case PR_DESC_SOCKET_UDP:
                 fd->methods = PR_GetUDPMethods();
                 flags = fcntl(osfd, F_GETFL, 0);
                 flags |= _PR_FCNTL_FLAGS;
                 (void)fcntl(osfd, F_SETFL, flags);
                 break;
             case PR_DESC_PIPE: