Browse Source

Merge commit 'c632697' into bfgminer-3.5.x

Luke Dashjr 12 years ago
parent
commit
86fd342f52
2 changed files with 13 additions and 4 deletions
  1. 0 4
      api.c
  2. 13 0
      miner.c

+ 0 - 4
api.c

@@ -4050,10 +4050,6 @@ void api(int api_thr_id)
 		}
 		}
 	}
 	}
 
 
-	/* This should be done before curl in needed
-	 * to ensure curl has already called WSAStartup() in windows */
-	cgsleep_ms(opt_log_interval*1000);
-
 	*apisock = socket(AF_INET, SOCK_STREAM, 0);
 	*apisock = socket(AF_INET, SOCK_STREAM, 0);
 	if (*apisock == INVSOCK) {
 	if (*apisock == INVSOCK) {
 		applog(LOG_ERR, "API1 initialisation failed (%s)%s", SOCKERRMSG, UNAVAILABLE);
 		applog(LOG_ERR, "API1 initialisation failed (%s)%s", SOCKERRMSG, UNAVAILABLE);

+ 13 - 0
miner.c

@@ -9784,6 +9784,10 @@ void _bfg_clean_up(void)
 		free(cpus);
 		free(cpus);
 
 
 	curl_global_cleanup();
 	curl_global_cleanup();
+	
+#ifdef WIN32
+	WSACleanup();
+#endif
 }
 }
 
 
 void _quit(int status)
 void _quit(int status)
@@ -10439,6 +10443,15 @@ int main(int argc, char *argv[])
 	setup_pthread_cancel_workaround();
 	setup_pthread_cancel_workaround();
 #endif
 #endif
 
 
+#ifdef WIN32
+	{
+		WSADATA wsa;
+		i = WSAStartup(MAKEWORD(2, 2), &wsa);
+		if (i)
+			quit(1, "Failed to initialise Winsock: %s", bfg_strerror(i, BST_SOCKET));
+	}
+#endif
+	
 	/* This dangerous functions tramples random dynamically allocated
 	/* This dangerous functions tramples random dynamically allocated
 	 * variables so do it before anything at all */
 	 * variables so do it before anything at all */
 	if (unlikely(curl_global_init(CURL_GLOBAL_ALL)))
 	if (unlikely(curl_global_init(CURL_GLOBAL_ALL)))