102 if (s >= 0) { 103 socklen_t len; 104 int arg, res; 105 struct linger linger; 106 107 /* copy socket options that are relevant to SDP */ 108 len = sizeof(arg); 109 if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, &len) == 0) 110 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, len); 111 len = sizeof(arg); 112 if (getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, &len) == 0) 113 setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, len); 114 len = sizeof(linger); 115 if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (void*)&linger, &len) == 0) 116 setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, len); 117 118 RESTARTABLE(dup2(s, fd), res); 119 if (res < 0) 120 JNU_ThrowIOExceptionWithLastError(env, "dup2"); 121 RESTARTABLE(close(s), res); 122 } 123 } | 102 if (s >= 0) { 103 socklen_t len; 104 int arg, res; 105 struct linger linger; 106 107 /* copy socket options that are relevant to SDP */ 108 len = sizeof(arg); 109 if (getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, &len) == 0) 110 setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, len); 111 len = sizeof(arg); 112 if (getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, &len) == 0) 113 setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char*)&arg, len); 114 len = sizeof(linger); 115 if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (void*)&linger, &len) == 0) 116 setsockopt(s, SOL_SOCKET, SO_LINGER, (char*)&linger, len); 117 118 RESTARTABLE(dup2(s, fd), res); 119 if (res < 0) 120 JNU_ThrowIOExceptionWithLastError(env, "dup2"); 121 RESTARTABLE(close(s), res); 122 if (res < 0 && !(*env)->ExceptionOccurred(env)) 123 JNU_ThrowIOExceptionWithLastError(env, "close"); 124 } 125 } |