Selaa lähdekoodia

Fix/remove some TODO marks

bel2125 7 vuotta sitten
vanhempi
commit
36a8b13f7b
2 muutettua tiedostoa jossa 19 lisäystä ja 21 poistoa
  1. 17 8
      src/civetweb.c
  2. 2 13
      src/mod_lua.inl

+ 17 - 8
src/civetweb.c

@@ -1402,6 +1402,9 @@ struct mg_workerTLS {
 	HANDLE pthread_cond_helper_mutex;
 	struct mg_workerTLS *next_waiting_thread;
 #endif
+#if defined(MG_LEGACY_INTERFACE)
+	char txtbuf[4];
+#endif
 };
 
 
@@ -3490,12 +3493,20 @@ mg_get_request_info(const struct mg_connection *conn)
 	}
 #if 1 /* TODO: deal with legacy */
 	if (conn->connection_type == CONNECTION_TYPE_RESPONSE) {
-		static char txt[16];
+		char txt[16];
+		struct mg_workerTLS *tls =
+		    (struct mg_workerTLS *)pthread_getspecific(sTlsKey);
+
 		sprintf(txt, "%03i", conn->response_info.status_code);
+		if (strlen(txt) == 3) {
+			memcpy(tls->txtbuf, txt, 4);
+		} else {
+			strcpy(tls->txtbuf, "ERR");
+		}
 
 		((struct mg_connection *)conn)->request_info.local_uri =
 		    ((struct mg_connection *)conn)->request_info.request_uri =
-		        txt; /* TODO: not thread safe */
+		        tls->txtbuf; /* use thread safe buffer */
 
 		((struct mg_connection *)conn)->request_info.num_headers =
 		    conn->response_info.num_headers;
@@ -5337,7 +5348,7 @@ mg_stat(const struct mg_connection *conn,
 		filep->size = tmp_file.stat.size;
 		filep->last_modified = time(NULL);
 		filep->location = 2;
-		/* TODO: for 1.10: restructure how files in memory are handled */
+		/* TODO: remove legacy "files in memory" feature */
 
 		return 1;
 	}
@@ -14173,7 +14184,7 @@ sslize(struct mg_connection *conn,
 	ret = SSL_set_fd(conn->ssl, conn->client.sock);
 	if (ret != 1) {
 		err = SSL_get_error(conn->ssl, ret);
-		(void)err; /* TODO: set some error message */
+		mg_cry(conn, "SSL error %i, destroying SSL context", err);
 		SSL_free(conn->ssl);
 		conn->ssl = NULL;
 /* Avoid CRYPTO_cleanup_all_ex_data(); See discussion:
@@ -14207,8 +14218,7 @@ sslize(struct mg_connection *conn,
 			} else if (err == SSL_ERROR_SYSCALL) {
 				/* This is an IO error. Look at errno. */
 				err = errno;
-				/* TODO: set some error message */
-				(void)err;
+				mg_cry(conn, "SSL syscall error %i", err);
 				break;
 
 			} else {
@@ -15640,8 +15650,7 @@ mg_connect_client_impl(const struct mg_client_options *client_options,
 #endif
 
 	if (0 != set_non_blocking_mode(sock)) {
-		/* TODO: handle error */
-		;
+		mg_cry(conn, "Cannot set non-blocking mode for client");
 	}
 
 	return conn;

+ 2 - 13
src/mod_lua.inl

@@ -762,7 +762,7 @@ lsp_get_var(lua_State *L)
 			/* Variable found: return value to Lua */
 			lua_pushstring(L, dst);
 		} else {
-			/* Variable not found (TODO (mid): may be string too long) */
+			/* Variable not found */
 			lua_pushnil(L);
 		}
 		mg_free(dst);
@@ -1695,16 +1695,6 @@ civetweb_open_lua_libs(lua_State *L)
 		luaopen_lfs(L);
 	}
 #endif
-#ifdef USE_LUA_BINARY
-	{
-		/* TODO (low): Test if this could be used as a replacement for bit32.
-		 * Check again with Lua 5.3 later. */
-		extern int luaopen_binary(lua_State *);
-
-		luaL_requiref(L, "binary", luaopen_binary, 1);
-		lua_pop(L, 1);
-	}
-#endif
 }
 
 
@@ -2105,8 +2095,7 @@ lua_websocket_new(const char *script, struct mg_connection *conn)
 		}
 		/* init ws list element */
 		ws = &(*shared_websock_list)->ws;
-		ws->script =
-		    mg_strdup_ctx(script, conn->phys_ctx); /* TODO (low): handle OOM */
+		ws->script = mg_strdup_ctx(script, conn->phys_ctx);
 		if (!ws->script) {
 			conn->must_close = 1;
 			mg_unlock_context(conn->phys_ctx);