Procházet zdrojové kódy

Merge pull request #1332 from DL6ER/fix/socket_optional_v6

Tolerate socket creation error if port is optional
bel2125 před 2 měsíci
rodič
revize
ae67592f6e
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  1. 8 0
      src/civetweb.c

+ 8 - 0
src/civetweb.c

@@ -16154,6 +16154,10 @@ set_ports_option(struct mg_context *phys_ctx)
 			mg_cry_ctx_internal(phys_ctx,
 			                    "cannot create socket (entry %i)",
 			                    portsTotal);
+			if (so.is_optional) {
+				portsOk++; /* it's okay if we couldn't create a socket,
+						this port is optional anyway */
+			}
 			continue;
 		}
 
@@ -16239,6 +16243,10 @@ set_ports_option(struct mg_context *phys_ctx)
 #else
 			mg_cry_ctx_internal(phys_ctx, "%s", "IPv6 not available");
 			closesocket(so.sock);
+			if (so.is_optional) {
+				portsOk++; /* it's okay if we couldn't set the socket option,
+				              this port is optional anyway */
+			}
 			so.sock = INVALID_SOCKET;
 			continue;
 #endif