@cryptotaxi247 / netdata-1 / commits / 980e3aac5

do not delay freeing zlib memory

Costa Tsaousis (ktsaou) committed May 31, 2016 at 13:48 UTC 980e3aac58c743ab9988be9e4ca69171ecbcfbbe
1 file changed +7 -8
src/web_client.c
+7 -8
@@ -189,7 +189,7 @@ void web_client_reset(struct web_client *w)
189 if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY)) {
190 if(w->ifd != w->ofd) {
191 debug(D_WEB_CLIENT, "%llu: Closing filecopy input file descriptor %d.", w->id, w->ifd);
192 - close(w->ifd);
192 + if(w->ifd != -1) close(w->ifd);
193 w->ifd = w->ofd;
194 }
195 }
@@ -233,8 +233,7 @@ void web_client_reset(struct web_client *w)
233 #endif // NETDATA_WITH_ZLIB
234 }
235
236 -struct web_client *web_client_free(struct web_client *w)
237 -{
236 +struct web_client *web_client_free(struct web_client *w) {
237 struct web_client *n = w->next;
238 if(w == web_clients) web_clients = n;
239
@@ -245,7 +244,7 @@ struct web_client *web_client_free(struct web_client *w)
244 deflateEnd(&w->response.zstream);
245 }
246 #endif // NETDATA_WITH_ZLIB
248 -
247 +
248 if(w->prev) w->prev->next = w->next;
249 if(w->next) w->next->prev = w->prev;
250 if(w->response.header_output) buffer_free(w->response.header_output);
@@ -260,8 +259,7 @@ struct web_client *web_client_free(struct web_client *w)
259 return(n);
260 }
261
263 -uid_t web_files_uid(void)
264 -{
262 +uid_t web_files_uid(void) {
263 static char *web_owner = NULL;
264 static uid_t owner_uid = 0;
265
@@ -288,8 +286,7 @@ uid_t web_files_uid(void)
286 return(owner_uid);
287 }
288
291 -gid_t web_files_gid(void)
292 -{
289 +gid_t web_files_gid(void) {
290 static char *web_group = NULL;
291 static gid_t owner_gid = 0;
292
@@ -2214,6 +2211,8 @@ void *web_client_main(void *ptr)
2211 }
2212 }
2213
2214 + web_client_reset(w);
2215 +
2216 log_access("%llu: %s port %s disconnected from thread task id %d", w->id, w->client_ip, w->client_port, gettid());
2217 debug(D_WEB_CLIENT, "%llu: done...", w->id);
2218