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