Thanks ikegami but I'm still not quite understanding this but I certainly appreciate your help. In your example you've used $x for the "workaround". I don't understand why I have to do this. Perhaps it would be easier if I posted the exact code (comments labelled MJE I added):
sub queue_job { my ($betdb, $q, $job) = @_; my $key; $job->{jobid} = new_job_id($betdb); # MJE - obviously this can be undef but in the case in # question it is usually set my $clientref = $job->{clientref} if (exists($job->{clientref})); # # Insert info about this job in the audit file. # NOTE: This will fail if we've seen this client_reference before +as # client_reference is unique and it would indicate a client has su +bmitted # the same job twice e.g. posted the same job twice. # my $caught = try { my $repost = $clientref ? 0 : undef; $betdb->execProc( $p_run_or_queue_job, {DieOnError => 1, Comment => 'queue_job'}, $job->{jobid}, $clientref, $job->{sessionid}, $job->{name}, {clob => $json->objToData($job)}, $repost, 1); 0; } catch { my $ev = $_; if (($betdb->getDBh())->err == 1) { # constraint violation eval { $betdb->callPkgProc( {DieOnError => 1, Comment => 'run_now'}, BET::DB::SYN_PKG_BETDB, 'p_invalidJobRequest', $job->{jobid}, $clientref, $job->{sessionid}, $job->{name}, $json->objToData($job->{args}), R_DIE, "Job already seen"); 1; } or $log->warn("Failed to mark job already seen - $@"); $job->{joberr} = 'Already seen this job'; $job->{jobnative} = c_JOB_ALREADY_SEEN; $log->warn(sub {'JOB ALREADY POSTED ' . Dumper($job)}); } else { $log->logwarn("Failed to insert into job_audit, $ev"); } 1; }; return if $caught; my @now = gmtime(time()); $job->{jobqed} = sprintf "%d/%d/%d %02d:%02d:%02d", $now[3], $now[4]+1, $now[5]+1900, $now[2], $now[1], $now[0]; push @{$q->{jobs}}, $job; $q->{queued}->{$key} = $job->{jobid} if ($key); $log->debug("Queued job " . $job->{jobid}); $total_jobs_on_all_queues++; return $job->{jobid}; }
$clientref if the scalar which 5.10.1 complains about.
In reply to Re^6: panic: attempt to copy freed scalar a7b9650 to ad20598
by mje
in thread panic: attempt to copy freed scalar a7b9650 to ad20598
by mje
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |