浏览代码

ctx may be NULL (should obey the comment)

xtne6f 6 年之前
父节点
当前提交
5d6dea363d
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/civetweb.c

+ 2 - 1
src/civetweb.c

@@ -8924,6 +8924,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 		struct mg_pollfd pfd[1];
 		struct mg_pollfd pfd[1];
 		int pollres;
 		int pollres;
 		int ms_wait = 10000; /* 10 second timeout */
 		int ms_wait = 10000; /* 10 second timeout */
+		int nonstop = 0;
 
 
 		/* For a non-blocking socket, the connect sequence is:
 		/* For a non-blocking socket, the connect sequence is:
 		 * 1) call connect (will not block)
 		 * 1) call connect (will not block)
@@ -8932,7 +8933,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
 		 */
 		 */
 		pfd[0].fd = *sock;
 		pfd[0].fd = *sock;
 		pfd[0].events = POLLOUT;
 		pfd[0].events = POLLOUT;
-		pollres = mg_poll(pfd, 1, (int)(ms_wait), &(ctx->stop_flag));
+		pollres = mg_poll(pfd, 1, ms_wait, ctx ? &(ctx->stop_flag) : &nonstop);
 
 
 		if (pollres != 1) {
 		if (pollres != 1) {
 			/* Not connected */
 			/* Not connected */