소스 검색

mg_init_library: return the features initialized

bel2125 8 년 전
부모
커밋
c9115f59d0
1개의 변경된 파일13개의 추가작업 그리고 16개의 파일을 삭제
  1. 13 16
      src/civetweb.c

+ 13 - 16
src/civetweb.c

@@ -15603,30 +15603,27 @@ mg_get_system_info(char *buffer, int buflen)
 static int mg_init_library_called = 0;
 static int mg_ssl_initialized = 0;
 
+
 /* Initialize this library. This function does not need to be thread safe. */
 unsigned
 mg_init_library(unsigned features)
 {
 	char ebuf[128];
 
-	if (features & 2) {
-		if (mg_check_feature(2)) {
-			if (!mg_ssl_initialized) {
-				if (initialize_ssl(ebuf, sizeof(ebuf))) {
-					mg_ssl_initialized = 1;
-				} else {
-					(void)ebuf;
-					/* TODO: print error */
-					return 0;
-				}
+	unsigned features_to_init = mg_check_feature(features & 0xFFu);
+	unsigned features_inited = features_to_init;
+
+	if (features_to_init & 2) {
+		if (!mg_ssl_initialized) {
+			if (initialize_ssl(ebuf, sizeof(ebuf))) {
+				mg_ssl_initialized = 1;
 			} else {
-				/* ssl already initialized */
+				(void)ebuf;
+				/* TODO: print error */
+				features_inited &= ~2;
 			}
 		} else {
-			(void)ebuf;
-			/* Cannot initialize SSL, if it is not configured */
-			/* TODO: print error */
-			return 0;
+			/* ssl already initialized */
 		}
 	}
 
@@ -15641,7 +15638,7 @@ mg_init_library(unsigned features)
 		mg_init_library_called++;
 	}
 
-	return mg_check_feature(features & 0xFFu);
+	return features_inited;
 }