Bugzilla – Attachment 113029 Details for
Bug 26854
stage-marc-import.pl does not properly fork
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26854: Close STDERR when forking stage-marc-import.pl
Bug-26854-Close-STDERR-when-forking-stage-marc-imp.patch (text/plain), 2.37 KB, created by
David Nind
on 2020-11-05 04:45:04 UTC
(
hide
)
Description:
Bug 26854: Close STDERR when forking stage-marc-import.pl
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-11-05 04:45:04 UTC
Size:
2.37 KB
patch
obsolete
>From f4356b88c4f6a2b0b3301ac5facbace1e4312995 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Thu, 29 Oct 2020 04:24:31 +0000 >Subject: [PATCH] Bug 26854: Close STDERR when forking stage-marc-import.pl > >We need to close STDERR when forking stage-marc-import.pl, >or else the CGI session with Apache httpd does not properly >finish. This leads to unexpected behaviour across different httpd >versions, operating systems, etc. > >This patch closes the STDERR file handle when forking a child >process to do MARC imports, and it re-opens STDERR to a log file >in the logdir directory to catch any import errors. > >Test plan: >1. Apply the patch >2. Go to http://localhost:8081/cgi-bin/koha/tools/stage-marc-import.pl >3. Upload a MARC file with a large number of records (e.g. 30,000 records) >4. Open F12 dev tools >5. Click on "Network" tab >6. Clear all existing network logs >7. Click "Stage for import" >8. After ~30 seconds, the request to stage-marc-import.pl should return a 200 code >9. Immediately, calls to background-job-progress.pl should start, and the "Job progress" >bar should update at a maximum rate of every .5 seconds >(or more realistically 1-2 seconds) > >Signed-off-by: David Nind <david@davidnind.com> >--- > tools/stage-marc-import.pl | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > >diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl >index 0ea436351f..a5094b4616 100755 >--- a/tools/stage-marc-import.pl >+++ b/tools/stage-marc-import.pl >@@ -122,10 +122,15 @@ if ($completedJobID) { > exit 0; > } elsif (defined $pid) { > # child >- # close STDOUT to signal to Apache that >- # we're now running in the background >+ # close STDOUT/STDERR to signal to end CGI session with Apache >+ # Otherwise, the AJAX request to this script won't return properly > close STDOUT; >- # close STDERR; # there is no good reason to close STDERR >+ close STDERR; >+ my $logdir = C4::Context->config('logdir'); >+ if ($logdir && -d $logdir){ >+ my $logfile = sprintf("%s/%s",$logdir,'background-jobs.log'); >+ open(STDERR, '>>', $logfile); >+ } > } else { > # fork failed, so exit immediately > warn "fork failed while attempting to run tools/stage-marc-import.pl as a background job: $!"; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26854
:
112655
|
113029
|
113656
|
113819