.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mail::SpamAssassin::AsyncLoop 3pm" .TH Mail::SpamAssassin::AsyncLoop 3pm "2021-05-30" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::SpamAssassin::AsyncLoop \- scanner asynchronous event loop .SH "DESCRIPTION" .IX Header "DESCRIPTION" An asynchronous event loop used for long-running operations, performed \*(L"in the background\*(R" during the \fBMail::SpamAssassin::check()\fR scan operation, such as \s-1DNS\s0 blocklist lookups. .SH "METHODS" .IX Header "METHODS" .ie n .IP "$ent = $async\->start_lookup($ent, $master_deadline)" 4 .el .IP "\f(CW$ent\fR = \f(CW$async\fR\->start_lookup($ent, \f(CW$master_deadline\fR)" 4 .IX Item "$ent = $async->start_lookup($ent, $master_deadline)" Register the start of a long-running asynchronous lookup operation. \&\f(CW$ent\fR is a hash reference containing the following items: .RS 4 .IP "key (required)" 4 .IX Item "key (required)" A key string, unique to this lookup. This is what is reported in debug messages, used as the key for \f(CW\*(C`get_lookup()\*(C'\fR, etc. .IP "id (required)" 4 .IX Item "id (required)" An \s-1ID\s0 string, also unique to this lookup. Typically, this is the \s-1DNS\s0 packet \s-1ID\s0 as returned by DnsResolver's \f(CW\*(C`bgsend\*(C'\fR method. Sadly, the Net::DNS architecture forces us to keep a separate \s-1ID\s0 string for this task instead of reusing \f(CW\*(C`key\*(C'\fR \*(-- if you are not using \s-1DNS\s0 lookups through DnsResolver, it should be \s-1OK\s0 to just reuse \f(CW\*(C`key\*(C'\fR. .IP "type (required)" 4 .IX Item "type (required)" A string, typically one word, used to describe the type of lookup in log messages, such as \f(CW\*(C`DNSBL\*(C'\fR, \f(CW\*(C`MX\*(C'\fR, \f(CW\*(C`TXT\*(C'\fR. .IP "zone (optional)" 4 .IX Item "zone (optional)" A zone specification (typically a \s-1DNS\s0 zone name \- e.g. host, domain, or \s-1RBL\s0) which may be used as a key to look up per-zone settings. No semantics on this parameter is imposed by this module. Currently used to fetch by-zone timeouts. .IP "timeout_initial (optional)" 4 .IX Item "timeout_initial (optional)" An initial value of elapsed time for which we are willing to wait for a response (time in seconds, floating point value is allowed). When elapsed time since a query started exceeds the timeout value and there are no other queries to wait for, the query is aborted. The actual timeout value ranges from timeout_initial and gradually approaches timeout_min (see next parameter) as the number of already completed queries approaches the number of all queries started. .Sp If a caller does not explicitly provide this parameter or its value is undefined, a default initial timeout value is settable by a configuration variable rbl_timeout. .Sp If a value of the timeout_initial parameter is below timeout_min, the initial timeout is set to timeout_min. .IP "timeout_min (optional)" 4 .IX Item "timeout_min (optional)" A lower bound (in seconds) to which the actual timeout approaches as the number of queries completed approaches the number of all queries started. Defaults to 0.2 * timeout_initial. .RE .RS 4 .Sp \&\f(CW$ent\fR is returned by this method, with its contents augmented by additional information. .RE .ie n .IP "$ent = $async\->bgsend_and_start_lookup($domain, $type, $class, $ent, $cb, %options)" 4 .el .IP "\f(CW$ent\fR = \f(CW$async\fR\->bgsend_and_start_lookup($domain, \f(CW$type\fR, \f(CW$class\fR, \f(CW$ent\fR, \f(CW$cb\fR, \f(CW%options\fR)" 4 .IX Item "$ent = $async->bgsend_and_start_lookup($domain, $type, $class, $ent, $cb, %options)" A common idiom: calls \f(CW\*(C`bgsend\*(C'\fR, followed by a call to \f(CW\*(C`start_lookup\*(C'\fR, returning the argument \f(CW$ent\fR object as modified by \f(CW\*(C`start_lookup\*(C'\fR and filled-in with a query \s-1ID.\s0 .ie n .IP "$ent = $async\->get_lookup($key)" 4 .el .IP "\f(CW$ent\fR = \f(CW$async\fR\->get_lookup($key)" 4 .IX Item "$ent = $async->get_lookup($key)" Retrieve the pending-lookup object for the given key \f(CW$key\fR. .Sp If the lookup is complete, this will return \f(CW\*(C`undef\*(C'\fR. .Sp Note that a lookup is still considered \*(L"pending\*(R" until \f(CW\*(C`complete_lookups()\*(C'\fR is called, even if it has been reported as complete via \f(CW\*(C`set_response_packet()\*(C'\fR. .ie n .IP "$async\->\fBlog_lookups_timing()\fR" 4 .el .IP "\f(CW$async\fR\->\fBlog_lookups_timing()\fR" 4 .IX Item "$async->log_lookups_timing()" Log sorted timing for all completed lookups. .ie n .IP "$alldone = $async\->\fBcomplete_lookups()\fR" 4 .el .IP "\f(CW$alldone\fR = \f(CW$async\fR\->\fBcomplete_lookups()\fR" 4 .IX Item "$alldone = $async->complete_lookups()" Perform a poll of the pending lookups, to see if any are completed. Callbacks on completed queries will be called from \fBpoll_responses()\fR. .Sp If there are no lookups remaining, or if too much time has elapsed since any results were returned, \f(CW1\fR is returned, otherwise \f(CW0\fR. .ie n .IP "$async\->\fBabort_remaining_lookups()\fR" 4 .el .IP "\f(CW$async\fR\->\fBabort_remaining_lookups()\fR" 4 .IX Item "$async->abort_remaining_lookups()" Abort any remaining lookups. .ie n .IP "$async\->set_response_packet($id, $pkt, $key, $timestamp)" 4 .el .IP "\f(CW$async\fR\->set_response_packet($id, \f(CW$pkt\fR, \f(CW$key\fR, \f(CW$timestamp\fR)" 4 .IX Item "$async->set_response_packet($id, $pkt, $key, $timestamp)" Register a \*(L"response packet\*(R" for a given query. \f(CW$id\fR is the \s-1ID\s0 for the query, and must match the \f(CW\*(C`id\*(C'\fR supplied in \f(CW\*(C`start_lookup()\*(C'\fR. \f(CW$pkt\fR is the packet object for the response. A parameter \f(CW$key\fR identifies an entry in a hash %{$self\->{pending_lookups}} where the object which spawned this query can be found, and through which further information about the query is accessible. .Sp \&\f(CW$pkt\fR may be undef, indicating that no response packet is available, but a query has completed (e.g. was aborted or dismissed) and is no longer \*(L"pending\*(R". .Sp The \s-1DNS\s0 resolver's response packet \f(CW$pkt\fR will be made available to a callback subroutine through its argument as well as in \f(CW\*(C`$ent\-. .ie n .IP "$async\->report_id_complete($id,$key,$key,$timestamp)" 4 .el .IP "\f(CW$async\fR\->report_id_complete($id,$key,$key,$timestamp)" 4 .IX Item "$async->report_id_complete($id,$key,$key,$timestamp)" Legacy. Equivalent to \f(CW$self\fR\->set_response_packet($id,undef,$key,$timestamp), i.e. providing undef as a response packet. Register that a query has completed and is no longer \*(L"pending\*(R". \f(CW$id\fR is the \s-1ID\s0 for the query, and must match the \f(CW\*(C`id\*(C'\fR supplied in \f(CW\*(C`start_lookup()\*(C'\fR. .Sp One or the other of \f(CW\*(C`set_response_packet()\*(C'\fR or \f(CW\*(C`report_id_complete()\*(C'\fR should be called, but not both. .ie n .IP "$time = $async\->\fBlast_poll_responses_time()\fR" 4 .el .IP "\f(CW$time\fR = \f(CW$async\fR\->\fBlast_poll_responses_time()\fR" 4 .IX Item "$time = $async->last_poll_responses_time()" Get the time of the last call to \f(CW\*(C`poll_responses()\*(C'\fR (which is called from \f(CW\*(C`complete_lookups()\*(C'\fR. If \f(CW\*(C`poll_responses()\*(C'\fR was never called or \&\f(CW\*(C`abort_remaining_lookups()\*(C'\fR has been called \f(CW\*(C`last_poll_responses_time()\*(C'\fR will return undef.