From 01ca93e6d731dae90d2797eb8c63f8ab650d9ed8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Feb 2001 01:30:39 +0000 Subject: Fixed file descriptor leak in error conditions on print close. NT sends "delete on close" to cancel a print job copied from the command line. Cope with this. Jeremy. --- source/printing/printfsp.c | 8 ++++++++ source/printing/printing.c | 2 ++ 2 files changed, 10 insertions(+) (limited to 'source/printing') diff --git a/source/printing/printfsp.c b/source/printing/printfsp.c index f9042075425..efb97be9194 100644 --- a/source/printing/printfsp.c +++ b/source/printing/printfsp.c @@ -82,6 +82,14 @@ print a file - called on closing the file ****************************************************************************/ void print_fsp_end(files_struct *fsp, BOOL normal_close) { + if (fsp->share_mode == FILE_DELETE_ON_CLOSE) { + /* + * Truncate the job. print_job_end will take + * care of deleting it for us. JRA. + */ + sys_ftruncate(fsp->fd, 0); + } + print_job_end(fsp->print_jobid, normal_close); if (fsp->fsp_name) { diff --git a/source/printing/printing.c b/source/printing/printing.c index 1aa8ced5a5d..ba01a827fbc 100644 --- a/source/printing/printing.c +++ b/source/printing/printing.c @@ -986,6 +986,8 @@ BOOL print_job_end(int jobid, BOOL normal_close) * Not a normal close or we couldn't stat the job file, * so something has gone wrong. Cleanup. */ + close(pjob->fd); + pjob->fd = -1; goto fail; } -- cgit