summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_mem_pool_cleanup.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
commit16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch)
treee6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_mem_pool_cleanup.c
downloadunit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz
unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2
Initial version.
Diffstat (limited to 'src/nxt_mem_pool_cleanup.c')
-rw-r--r--src/nxt_mem_pool_cleanup.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/nxt_mem_pool_cleanup.c b/src/nxt_mem_pool_cleanup.c
new file mode 100644
index 00000000..febfc959
--- /dev/null
+++ b/src/nxt_mem_pool_cleanup.c
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#include <nxt_main.h>
+
+
+static void nxt_mem_pool_file_cleanup_handler(void *data);
+
+
+nxt_mem_pool_cleanup_t *
+nxt_mem_pool_file_cleanup(nxt_mem_pool_t *mp, nxt_file_t *file)
+{
+ nxt_mem_pool_cleanup_t *mpcl;
+
+ mpcl = nxt_mem_pool_cleanup(mp, 0);
+
+ if (nxt_fast_path(mpcl != NULL)) {
+ mpcl->handler = nxt_mem_pool_file_cleanup_handler;
+ mpcl->data = file;
+ }
+
+ return mpcl;
+}
+
+
+static void
+nxt_mem_pool_file_cleanup_handler(void *data)
+{
+ nxt_file_t *file;
+
+ file = data;
+
+ if (file->fd != NXT_FILE_INVALID) {
+ nxt_file_close(file);
+ }
+}