Commit 037fdbcc authored by Sergey Lyubka's avatar Sergey Lyubka

Ignoring chdir() return value. Resetting mg_conn in close_local_endpoint()

parent 5d2ac4e0
...@@ -952,9 +952,9 @@ static pid_t start_process(const char *interp, const char *cmd, const char *env, ...@@ -952,9 +952,9 @@ static pid_t start_process(const char *interp, const char *cmd, const char *env,
(void) env; (void) env;
if (pid == 0) { if (pid == 0) {
chdir(dir); (void) chdir(dir);
dup2(sock, 0); (void) dup2(sock, 0);
dup2(sock, 1); (void) dup2(sock, 1);
closesocket(sock); closesocket(sock);
// After exec, all signal handlers are restored to their default values, // After exec, all signal handlers are restored to their default values,
...@@ -3692,6 +3692,7 @@ static void log_access(const struct connection *conn, const char *path) { ...@@ -3692,6 +3692,7 @@ static void log_access(const struct connection *conn, const char *path) {
#endif #endif
static void close_local_endpoint(struct connection *conn) { static void close_local_endpoint(struct connection *conn) {
struct mg_connection *c = &conn->mg_conn;
// Must be done before free() // Must be done before free()
int keep_alive = should_keep_alive(&conn->mg_conn) && int keep_alive = should_keep_alive(&conn->mg_conn) &&
(conn->endpoint_type == EP_FILE || conn->endpoint_type == EP_USER); (conn->endpoint_type == EP_FILE || conn->endpoint_type == EP_USER);
...@@ -3705,8 +3706,8 @@ static void close_local_endpoint(struct connection *conn) { ...@@ -3705,8 +3706,8 @@ static void close_local_endpoint(struct connection *conn) {
} }
#ifndef MONGOOSE_NO_LOGGING #ifndef MONGOOSE_NO_LOGGING
if (conn->mg_conn.status_code > 0 && conn->endpoint_type != EP_CLIENT && if (c->status_code > 0 && conn->endpoint_type != EP_CLIENT &&
conn->mg_conn.status_code != 400) { c->status_code != 400) {
log_access(conn, conn->server->config_options[ACCESS_LOG_FILE]); log_access(conn, conn->server->config_options[ACCESS_LOG_FILE]);
} }
#endif #endif
...@@ -3714,8 +3715,9 @@ static void close_local_endpoint(struct connection *conn) { ...@@ -3714,8 +3715,9 @@ static void close_local_endpoint(struct connection *conn) {
// Gobble possible POST data sent to the URI handler // Gobble possible POST data sent to the URI handler
discard_leading_iobuf_bytes(&conn->local_iobuf, conn->mg_conn.content_len); discard_leading_iobuf_bytes(&conn->local_iobuf, conn->mg_conn.content_len);
conn->endpoint_type = EP_NONE; conn->endpoint_type = EP_NONE;
conn->flags = conn->mg_conn.status_code = 0; conn->cl = conn->num_bytes_sent = conn->request_len = conn->flags = 0;
conn->cl = conn->num_bytes_sent = conn->request_len = 0; c->request_method = c->uri = c->http_version = c->query_string = NULL;
c->num_headers = c->status_code = c->is_websocket = c->content_len = 0;
free(conn->request); free(conn->request);
conn->request = NULL; conn->request = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment