1 2 /* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7 #include <nxt_main.h> 8 9 10 static void nxt_mem_pool_file_cleanup_handler(nxt_task_t *task, void *data); 11 12 13 nxt_mem_pool_cleanup_t * nxt_mem_pool_file_cleanup(nxt_mem_pool_t * mp,nxt_file_t * file)14nxt_mem_pool_file_cleanup(nxt_mem_pool_t *mp, nxt_file_t *file) 15 { 16 nxt_mem_pool_cleanup_t *mpcl; 17 18 mpcl = nxt_mem_pool_cleanup(mp, 0); 19 20 if (nxt_fast_path(mpcl != NULL)) { 21 mpcl->handler = nxt_mem_pool_file_cleanup_handler; 22 mpcl->data = file; 23 } 24 25 return mpcl; 26 } 27 28 29 static void nxt_mem_pool_file_cleanup_handler(nxt_task_t * task,void * data)30nxt_mem_pool_file_cleanup_handler(nxt_task_t *task, void *data) 31 { 32 nxt_file_t *file; 33 34 file = data; 35 36 if (file->fd != NXT_FILE_INVALID) { 37 nxt_file_close(task, file); 38 } 39 } 40