@@ -1074,7 +1074,7 @@ static rem_port* listener_socket(rem_port* port, USHORT flag, const addrinfo* pa
1074
1074
* binds the socket and calls listen().
1075
1075
* For multi-client server (SuperServer or SuperClassic) return listener
1076
1076
* port.
1077
- * For classic server - accept incoming connections and fork worker
1077
+ * For Classic server - accept incoming connections and fork worker
1078
1078
* processes, return NULL at exit;
1079
1079
* On error throw exception.
1080
1080
*
@@ -1088,27 +1088,28 @@ static rem_port* listener_socket(rem_port* port, USHORT flag, const addrinfo* pa
1088
1088
if (n == -1 )
1089
1089
gds__log (" setsockopt: error setting IPV6_V6ONLY to %d" , ipv6_v6only);
1090
1090
1091
+ #ifndef WIN_NT
1092
+ // dimitr: on Windows, lack of SO_REUSEADDR works the same way as it was specified on POSIX,
1093
+ // i.e. it allows binding to a port in a TIME_WAIT/FIN_WAIT state. If this option
1094
+ // is turned on explicitly, then a port can be re-bound regardless of its state,
1095
+ // e.g. while it's listening. This is surely not what we want.
1096
+ // We set this options for any kind of listener, including standalone Classic.
1097
+
1098
+ int optval = TRUE ;
1099
+ n = setsockopt (port->port_handle , SOL_SOCKET, SO_REUSEADDR,
1100
+ (SCHAR*) &optval, sizeof (optval));
1101
+ if (n == -1 )
1102
+ {
1103
+ inet_error (true , port, " setsockopt REUSE" , isc_net_connect_listen_err, INET_ERRNO);
1104
+ }
1105
+ #endif
1106
+
1091
1107
if (flag & SRVR_multi_client)
1092
1108
{
1093
1109
struct linger lingerInfo;
1094
1110
lingerInfo.l_onoff = 0 ;
1095
1111
lingerInfo.l_linger = 0 ;
1096
1112
1097
- #ifndef WIN_NT
1098
- // dimitr: on Windows, lack of SO_REUSEADDR works the same way as it was specified on POSIX,
1099
- // i.e. it allows binding to a port in a TIME_WAIT/FIN_WAIT state. If this option
1100
- // is turned on explicitly, then a port can be re-bound regardless of its state,
1101
- // e.g. while it's listening. This is surely not what we want.
1102
-
1103
- int optval = TRUE ;
1104
- n = setsockopt (port->port_handle , SOL_SOCKET, SO_REUSEADDR,
1105
- (SCHAR*) &optval, sizeof (optval));
1106
- if (n == -1 )
1107
- {
1108
- inet_error (true , port, " setsockopt REUSE" , isc_net_connect_listen_err, INET_ERRNO);
1109
- }
1110
- #endif
1111
-
1112
1113
// Get any values for SO_LINGER so that they can be reset during
1113
1114
// disconnect. SO_LINGER should be set by default on the socket
1114
1115
0 commit comments