perl.ipc.dirqueue http://www.nntp.perl.org/group/perl.ipc.dirqueue/ ... Copyright 1998-2008 perl.org Sun, 20 Jul 2008 11:05:54 +0000 ask@perl.org released version 1.0 of IPC::DirQueue by jm Hi --<br/><br/>Version 1.0 of IPC::DirQueue is now released, and should be showing<br/>up on CPAN rsn. Changes since 0.09:<br/><br/>- worker_still_working() is broken; it always claimed that the worker was<br/> no longer running. Fix thanks to Brian Duggan &lt;bduggan at mutatu dot<br/> org&gt;<br/><br/>- use buffered print instead of unbuffered syswrite() when creating data<br/> files using enqueue_sub()<br/><br/>- fix code to match POD documentation regarding the range of chars<br/> permitted in metadata during enqueueing, thanks to Brian Grossman for<br/> report<br/><br/>- update POD docs: visit_all_jobs() does not return a value. thanks to<br/> Simon on AnnoCPAN:<br/> http://annocpan.org/%7eJMASON/IPC-DirQueue-0.09/lib/IPC/DirQueue.pm#note_1570<br/><br/><br/>[the 1.0 version bump is just because -- no good reason. ;)<br/>this isn&#39;t really more stable than any other version!]<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2008/04/msg29.html Fri, 18 Apr 2008 08:45:05 +0000 released version 0.09 of IPC::DirQueue by jm Hi --<br/><br/>Version 0.09 of IPC::DirQueue is now released, and should be showing<br/>up on CPAN rsn. Changes since 0.08:<br/><br/>------------------------------------------------------------------------<br/>r8418 | jmason | 2006-12-21 19:00:03 +0000 (Thu, 21 Dec 2006) | 1 line<br/><br/>add IPC::DirQueue::Job::get_data() API, to access queued job data directly<br/>as a string instead of as a filename, thanks to Collin Winter &lt;collinw at<br/>gmail.com&gt;<br/><br/>------------------------------------------------------------------------<br/>r8379 | jmason | 2006-12-11 20:32:13 +0000 (Mon, 11 Dec 2006) | 1 line<br/><br/>fix documentation; it was unclear for beginners as to how job data got<br/>into and out of IPC::DirQueue, and that reading/writing files is required<br/><br/>------------------------------------------------------------------------<br/>r8103 | jmason | 2006-11-24 14:27:37 +0000 (Fri, 24 Nov 2006) | 1 line<br/><br/>fix platform-specific tests: must use &#39;use constant&#39; in the conditional<br/>variables, otherwise the tests appear to be failing on win32 platforms<br/>when in fact we&#39;re just trying to skip them (see<br/>http://www.nntp.perl.org/group/perl.cpan.testers/377405 for example)<br/><br/><br/>(by the way, IPC::DirQueue users might be interested in this account<br/>of how qpsmtpd and IPC::DirQueue powers the traps.SpamAssassin.org<br/>spamtraps: http://taint.org/2007/04/17/132339a.html )<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/04/msg28.html Fri, 27 Apr 2007 13:40:48 +0000 Re: cancelling queued items by jm <br/>Brian Duggan writes:<br/>&gt; On Wednesday, March 21, Justin Mason wrote: <br/>&gt; &gt; It sounds pretty good -- just one thing -- how is a caller supposed to get<br/>&gt; &gt; the datapath? Presumably they don&#39;t construct it themselves...<br/>&gt; <br/>&gt; &gt;&gt;From the $job object (obtainable by sending a callback<br/>&gt; to visit_all_jobs()). Though actually, it looks like using<br/>&gt; $job-&gt;{pathqueue} instead of the datapath might be easier,<br/>&gt; so that pickup_queued_job() doesn&#39;t have to read the<br/>&gt; queuefile (to find out the datapath).<br/>&gt; <br/>&gt; &gt; that&#39;s ok, that suggestion is a one-liner. Having said that -- a test case<br/>&gt; &gt; &quot;t&quot; script would rock though :)<br/>&gt; <br/>&gt; Okay, I&#39;ve attached one.<br/><br/>Cool. That makes the idea pretty clear, too. I had to move a little<br/>stuff around to make it more efficient, but it works fine; I also copied<br/>the test script for fanout and ordered queue modes, too. Checked in:<br/><br/>: jm 516...; svn commit -m &quot;added support to pickup a queued item by its data path, thanks to Brian Duggan &lt;bduggan at matatu.org&gt;&quot;<br/>Sending MANIFEST<br/>Sending lib/IPC/DirQueue.pm<br/>Adding t/60pickup_path_basic.t<br/>Adding t/60pickup_path_fanout.t<br/>Adding t/60pickup_path_ordered.t<br/>Transmitting file data .....<br/>Committed revision 9297.<br/><br/>&gt; thanks!<br/>&gt; Brian<br/>&gt; <br/>&gt; ps On a separate note, I noticed that read_control_file() is always<br/>&gt; called with two arguments, but the second argument is ignored. Is<br/>&gt; this perhaps an alternative to saying &#39;local *IN&#39; in read_control_file()?<br/><br/>oops! bug ;) Thanks for spotting this. fixed:<br/><br/>: jm 745...; svn commit -m &quot;read_control_file() was always opening the control file for read twice, redundantly; fixed&quot; lib/IPC/DirQueue.pm<br/>Sending lib/IPC/DirQueue.pm<br/>Transmitting file data .<br/>Committed revision 9296.<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg27.html Thu, 22 Mar 2007 12:32:29 +0000 Re: cancelling queued items by Brian Duggan On Wednesday, March 21, Justin Mason wrote: <br/>&gt; It sounds pretty good -- just one thing -- how is a caller supposed to get<br/>&gt; the datapath? Presumably they don&#39;t construct it themselves...<br/><br/>From the $job object (obtainable by sending a callback<br/>to visit_all_jobs()). Though actually, it looks like using<br/>$job-&gt;{pathqueue} instead of the datapath might be easier,<br/>so that pickup_queued_job() doesn&#39;t have to read the<br/>queuefile (to find out the datapath).<br/><br/>&gt; that&#39;s ok, that suggestion is a one-liner. Having said that -- a test case<br/>&gt; &quot;t&quot; script would rock though :)<br/><br/>Okay, I&#39;ve attached one.<br/><br/>thanks!<br/>Brian<br/><br/>ps On a separate note, I noticed that read_control_file() is always<br/>called with two arguments, but the second argument is ignored. Is<br/>this perhaps an alternative to saying &#39;local *IN&#39; in read_control_file()?<br/> <br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg26.html Wed, 21 Mar 2007 17:35:12 +0000 Re: cancelling queued items by jm Brian Duggan writes:<br/>&gt; Hello,<br/>&gt; <br/>&gt; I&#39;m using IPC::DirQueue -- very nice module, thanks.<br/>&gt; <br/>&gt; I wanted the ability to cancel not-yet-active items from <br/>&gt; anywhere in the queue (a la lprm), and was trying<br/>&gt; to think of a safe way to do it. It occurred to me<br/>&gt; that one easy modification to IPC::DirQueue that would<br/>&gt; allow this would be to have pickup_queued_job() take<br/>&gt; an optional parameter which is the name of the data path,<br/>&gt; and then just add something like<br/>&gt; <br/>&gt; next if exists($args{datapath}) &amp;&amp;<br/>&gt; $nextfile ne $args{datapath};<br/>&gt; <br/>&gt; to the while loop. <br/>&gt; <br/>&gt; Any chance this could be incorporated? Or is there<br/>&gt; already another safe way to cancel an item?<br/><br/>It sounds pretty good -- just one thing -- how is a caller supposed to get<br/>the datapath? Presumably they don&#39;t construct it themselves...<br/><br/>&gt; thanks<br/>&gt; Brian<br/>&gt; <br/>&gt; (p.s. happy to send a patch if you prefer)<br/><br/>that&#39;s ok, that suggestion is a one-liner. Having said that -- a test case<br/>&quot;t&quot; script would rock though :)<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg25.html Wed, 21 Mar 2007 08:50:52 +0000 Re: usage question by Thomas J Pinkl On Mon, Mar 05, 2007 at 11:28:03AM -0500, Thomas J Pinkl wrote:<br/>&gt; Justin, here&#39;s a patch which adds an optional &quot;readonly&quot; parameter <br/>&gt; to visit_all_jobs(). If the parameter isn&#39;t passed, then it defaults <br/>&gt; to true, thus maintaining backward compatibility. The patch <br/>&gt; includes changes to the POD as well. It&#39;s against the current SVN <br/>&gt; source.<br/><br/>Perhaps I whipped this up too quickly. The read-only flag works, as <br/>far as it goes, but jobs are not considered &quot;active&quot; when read-only <br/>is false. <br/><br/>If I understand the code correctly, then I&#39;ll also have to do <br/>something to make the job &quot;active&quot; from within visit_all_jobs(). <br/><br/>Is that correct?<br/><br/>-- <br/>Thomas J. Pinkl | T: 215-442-9300<br/>Senior Systems Architect | 800-444-1427<br/>Health Business Systems, Inc | F: 215-442-7555<br/>An SXC Company | <br/>738 Louis Drive | http://www.hbsrx.com/<br/>Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg24.html Mon, 05 Mar 2007 09:06:57 +0000 Re: usage question by Thomas J Pinkl On Mon, Mar 05, 2007 at 11:24:07AM +0000, Justin Mason wrote:<br/>&gt; Alternatively, I&#39;d be happy to apply a patch that implements<br/>&gt; a version of visit_all_jobs() which allows writes somehow, or<br/>&gt; a way to access a job returned by visit_all_jobs() and render<br/>&gt; it writable.<br/><br/>Justin, here&#39;s a patch which adds an optional &quot;readonly&quot; parameter <br/>to visit_all_jobs(). If the parameter isn&#39;t passed, then it defaults <br/>to true, thus maintaining backward compatibility. The patch <br/>includes changes to the POD as well. It&#39;s against the current SVN <br/>source.<br/><br/>-- <br/>Thomas J. Pinkl | T: 215-442-9300<br/>Senior Systems Architect | 800-444-1427<br/>Health Business Systems, Inc | F: 215-442-7555<br/>An SXC Company | <br/>738 Louis Drive | http://www.hbsrx.com/<br/>Warminster, PA 18974 | http://www.sxc.com/<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg23.html Mon, 05 Mar 2007 08:28:23 +0000 Re: usage question by jm <br/>hi Thomas --<br/><br/>an interesting use-case I hadn&#39;t considered! ;) The problem is that<br/>when the queue is accessed in ordered mode, it&#39;s simply a lexical<br/>sort by filename; and when accessed in unordered mode, it&#39;s simply<br/>the OS-based ordering rather than in any way &quot;random&quot;.<br/><br/>What about re-queueing the deferred jobs? ie.<br/><br/> my $dq = IPC::DirQueue-&gt;new( \%dq_opts );<br/> while (1) {<br/> my $job = $dq-&gt;pickup_queued_job();<br/> last if (! $job);<br/> <br/> my $rc = &amp;process_job( $job );<br/> if (!$rc) {<br/> $job-&gt;enqueue_file($job-&gt;get_data_path());<br/> }<br/> $job-&gt;finish();<br/> }<br/><br/>in other words, if a job is to be deferred, take it off the queue<br/>and re-queue it under a new name.<br/><br/>Alternatively, I&#39;d be happy to apply a patch that implements<br/>a version of visit_all_jobs() which allows writes somehow, or<br/>a way to access a job returned by visit_all_jobs() and render<br/>it writable.<br/><br/>--j.<br/><br/>Thomas J Pinkl writes:<br/>&gt; I&#39;m attempting to use IPC::DirQueue 0.08 for a project where messages <br/>&gt; are queued for later processing. However, when dequeuing these <br/>&gt; messages, it will be possible that a message cannot be processed <br/>&gt; immediately, but could be processed later. <br/>&gt; <br/>&gt; I thought I&#39;d be able to use IPC::DirQueue like this: <br/>&gt; <br/>&gt; my $dq = IPC::DirQueue-&gt;new( \%dq_opts );<br/>&gt; while (1) {<br/>&gt; my $job = $dq-&gt;pickup_queued_job();<br/>&gt; last if (! $job);<br/>&gt; <br/>&gt; my $rc = &amp;process_job( $job );<br/>&gt; if ($rc) {<br/>&gt; $job-&gt;finish();<br/>&gt; } else {<br/>&gt; $job-&gt;return_to_queue();<br/>&gt; }<br/>&gt; }<br/>&gt; <br/>&gt; But if, say, the first job is returned to the queue, then a subsequent <br/>&gt; call to pickup_queued_job() returns that same job. Turning the loop <br/>&gt; above into an infinite loop (absent an external event which suddenly <br/>&gt; causes process_job() to return true). <br/>&gt; <br/>&gt; I&#39;ve read through the IPC::DirQueue and IPC::DirQueue::Job pod pages, <br/>&gt; but I&#39;m not seeing any way to iterate through the queue the way that I <br/>&gt; need. The closest method I can see is visit_all_jobs(), but that only <br/>&gt; provides read-only Job objects. I suppose I could play with the <br/>&gt; read-only flag within the callback function, but that doesn&#39;t seem <br/>&gt; right.<br/>&gt; <br/>&gt; Does anyone have any suggestions?<br/>&gt; <br/>&gt; -- <br/>&gt; Thomas J. Pinkl | T: 215-442-9300<br/>&gt; Senior Systems Architect | 800-444-1427<br/>&gt; Health Business Systems, Inc | F: 215-442-7555<br/>&gt; An SXC Company | <br/>&gt; 738 Louis Drive | http://www.hbsrx.com/<br/>&gt; Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg22.html Mon, 05 Mar 2007 03:25:14 +0000 usage question by Thomas J Pinkl I&#39;m attempting to use IPC::DirQueue 0.08 for a project where messages <br/>are queued for later processing. However, when dequeuing these <br/>messages, it will be possible that a message cannot be processed <br/>immediately, but could be processed later. <br/><br/>I thought I&#39;d be able to use IPC::DirQueue like this: <br/><br/> my $dq = IPC::DirQueue-&gt;new( \%dq_opts );<br/> while (1) {<br/> my $job = $dq-&gt;pickup_queued_job();<br/> last if (! $job);<br/><br/> my $rc = &amp;process_job( $job );<br/> if ($rc) {<br/> $job-&gt;finish();<br/> } else {<br/> $job-&gt;return_to_queue();<br/> }<br/> }<br/><br/>But if, say, the first job is returned to the queue, then a subsequent <br/>call to pickup_queued_job() returns that same job. Turning the loop <br/>above into an infinite loop (absent an external event which suddenly <br/>causes process_job() to return true). <br/><br/>I&#39;ve read through the IPC::DirQueue and IPC::DirQueue::Job pod pages, <br/>but I&#39;m not seeing any way to iterate through the queue the way that I <br/>need. The closest method I can see is visit_all_jobs(), but that only <br/>provides read-only Job objects. I suppose I could play with the <br/>read-only flag within the callback function, but that doesn&#39;t seem <br/>right.<br/><br/>Does anyone have any suggestions?<br/><br/>-- <br/>Thomas J. Pinkl | T: 215-442-9300<br/>Senior Systems Architect | 800-444-1427<br/>Health Business Systems, Inc | F: 215-442-7555<br/>An SXC Company | <br/>738 Louis Drive | http://www.hbsrx.com/<br/>Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/03/msg21.html Sat, 03 Mar 2007 08:37:09 +0000 Re: getting: Illegal octal digit '8' by Thomas J Pinkl On Tue, Jan 16, 2007 at 07:04:44PM +0000, Justin Mason wrote:<br/>&gt; Are you providing values for data_file_mode or queue_file_mode in<br/>&gt; the constructor?<br/><br/>Yes, both are being set.<br/><br/>&gt; It&#39;s worth noting that they should be formatted as octal-formatted<br/>&gt; *strings*, not numbers. e.g. &#39;0666&#39;, not 0666. Could that be it?<br/><br/>Ah. I&#39;ll try that. Thank you.<br/><br/>-- <br/>Thomas J. Pinkl | T: 215-442-9300<br/>Senior Systems Architect | 800-444-1427<br/>Health Business Systems, Inc | F: 215-442-7555<br/>An SXC Company | <br/>738 Louis Drive | http://www.hbsrx.com/<br/>Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg20.html Tue, 16 Jan 2007 11:23:32 +0000 Re: getting: Illegal octal digit '8' by jm <br/>Thomas J Pinkl writes:<br/>&gt; I&#39;ve just started using IPC::DirQueue 0.08. Thanks to the author(s) <br/>&gt; for a module that appears to deliver exactly what I need. <br/><br/>You&#39;re welcome! ;)<br/><br/>&gt; I received these warnings: <br/>&gt; <br/>&gt; Illegal octal digit &#39;8&#39; ignored at \<br/>&gt; /usr/lib/perl5/site_perl/5.6.1/IPC/DirQueue.pm line 146.<br/>&gt; Illegal octal digit &#39;8&#39; ignored at \<br/>&gt; /usr/lib/perl5/site_perl/5.6.1/IPC/DirQueue.pm line 148.<br/>&gt; <br/>&gt; which corresponds to this section of code: <br/>&gt; <br/>&gt; $self-&gt;{data_file_mode} ||= &#39;0666&#39;;<br/>&gt; $self-&gt;{data_file_mode} = oct ($self-&gt;{data_file_mode});<br/>&gt; $self-&gt;{queue_file_mode} ||= &#39;0666&#39;;<br/>&gt; $self-&gt;{queue_file_mode} = oct ($self-&gt;{queue_file_mode});<br/>&gt; <br/>&gt; in sub new(). Lines 146 and 148 are the ones that use &#39;oct&#39;.<br/><br/>Are you providing values for data_file_mode or queue_file_mode in<br/>the constructor?<br/><br/>It&#39;s worth noting that they should be formatted as octal-formatted<br/>*strings*, not numbers. e.g. &#39;0666&#39;, not 0666. Could that be it?<br/><br/>--j.<br/><br/>&gt; The fix would appear to be:<br/>&gt; <br/>&gt; 146: $self-&gt;{data_file_mode} = oct sprintf &quot;0%o&quot;,$self-&gt;{data_file_mode};<br/>&gt; <br/>&gt; 148: $self-&gt;{queue_file_mode} = oct sprintf &quot;0%o&quot;,$self-&gt;{queue_file_mode};<br/>&gt; <br/>&gt; Can anyone else confirm this?<br/>&gt; <br/>&gt; --<br/>&gt; Thomas J. Pinkl | T: 215-442-9300<br/>&gt; Senior Systems Architect | 800-444-1427<br/>&gt; Health Business Systems, Inc | F: 215-442-7555<br/>&gt; An SXC Company | <br/>&gt; 738 Louis Drive | http://www.hbsrx.com/<br/>&gt; Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg19.html Tue, 16 Jan 2007 11:05:15 +0000 getting: Illegal octal digit '8' by Thomas J Pinkl I&#39;ve just started using IPC::DirQueue 0.08. Thanks to the author(s) <br/>for a module that appears to deliver exactly what I need. <br/><br/>I received these warnings: <br/><br/> Illegal octal digit &#39;8&#39; ignored at \<br/> /usr/lib/perl5/site_perl/5.6.1/IPC/DirQueue.pm line 146.<br/> Illegal octal digit &#39;8&#39; ignored at \<br/> /usr/lib/perl5/site_perl/5.6.1/IPC/DirQueue.pm line 148.<br/><br/>which corresponds to this section of code: <br/><br/> $self-&gt;{data_file_mode} ||= &#39;0666&#39;;<br/> $self-&gt;{data_file_mode} = oct ($self-&gt;{data_file_mode});<br/> $self-&gt;{queue_file_mode} ||= &#39;0666&#39;;<br/> $self-&gt;{queue_file_mode} = oct ($self-&gt;{queue_file_mode});<br/><br/>in sub new(). Lines 146 and 148 are the ones that use &#39;oct&#39;.<br/><br/>The fix would appear to be:<br/><br/> 146: $self-&gt;{data_file_mode} = oct sprintf &quot;0%o&quot;,$self-&gt;{data_file_mode};<br/><br/> 148: $self-&gt;{queue_file_mode} = oct sprintf &quot;0%o&quot;,$self-&gt;{queue_file_mode};<br/><br/>Can anyone else confirm this?<br/><br/>--<br/>Thomas J. Pinkl | T: 215-442-9300<br/>Senior Systems Architect | 800-444-1427<br/>Health Business Systems, Inc | F: 215-442-7555<br/>An SXC Company | <br/>738 Louis Drive | http://www.hbsrx.com/<br/>Warminster, PA 18974 | http://www.sxc.com/<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg18.html Tue, 16 Jan 2007 10:41:08 +0000 Re: [PATCH] Advanced tagging and filtering by jm <br/>hey, btw -- something&#39;s up with the latest version, at least; when<br/>I apply the patches and make test, it hangs in t/10enq_string as soon<br/>as pickup_queued_job() is called. SVN trunk works fine, as does<br/>the first patch, but as soon as the second patch is applied this<br/>happens.<br/><br/>Here&#39;s the current rev of the combined patch against SVN:<br/>http://taint.org/x/2007/filter.patch<br/><br/>That contains your two patches, my documentation changes, and a &quot;warn&quot; in<br/>the test script to illustrate this hang.<br/><br/>--j.<br/><br/>Malte S. Stretz writes:<br/>&gt; On Wednesday 03 January 2007 16:38 CET Justin Mason wrote:<br/>&gt; &gt; backwards compatibility is not a problem here, so go ahead and<br/>&gt; &gt; add the tag in addition to the hash.<br/>&gt; &gt;<br/>&gt; &gt; I think the best location is just before the hash, e.g.<br/>&gt; &gt;<br/>&gt; &gt; 50.20040909232529941258.TAG.HASH[.PID.RAND]<br/>&gt; &gt;<br/>&gt; &gt; (vs the simple<br/>&gt; &gt;<br/>&gt; &gt; 50.20040909232529941258.HASH[.PID.RAND]<br/>&gt; &gt;<br/>&gt; &gt; when tags are not in use.)<br/>&gt; &gt;<br/>&gt; &gt; &gt; Actually, when people start to filter the files based on their name,<br/>&gt; &gt; &gt; the format must not change anymore in future. Maybe the filter should<br/>&gt; &gt; &gt; apply to the tag only...<br/>&gt; &gt;<br/>&gt; &gt; Yes, I think that&#39;s a good idea... people shouldn&#39;t have to worry about<br/>&gt; &gt; the rest of the filename changing.<br/>&gt; <br/>&gt; Ok, attached is a patch on top of the last one which changes the code as you <br/>&gt; described it above. Additionally there&#39;s a revamped test.<br/>&gt; <br/>&gt; While I was hunting another totally stupid bug, I found out that I actually <br/>&gt; forgot to add the $filter in the second call to pickup_job in wait_for_job. <br/>&gt; Gave some nasty surprises. And visit_all_jobs now supports $filter, too.<br/>&gt; <br/>&gt; The syntax for $filter has changed a bit: If it is a string, it must be <br/>&gt; equal the tag, if it is a RE created with qr// it is matched as a RE.<br/>&gt; <br/>&gt; Can you update the QUEUE DIRECTORY STRUCTURE section for me? Your English <br/>&gt; is a lot better than mine :)<br/>&gt; <br/>&gt; Cheers,<br/>&gt; Malte<br/>&gt; part 3 text/x-diff 7472<br/>&gt; --- DirQueue.pm.patch1 2006-12-30 01:27:31.000000000 +0100<br/>&gt; +++ DirQueue.pm 2007-01-03 21:08:17.000000000 +0100<br/>&gt; @@ -173,8 +173,10 @@<br/>&gt; $self-&gt;{ordered} = 1;<br/>&gt; }<br/>&gt; <br/>&gt; - $self-&gt;{tag} ||= hash_string_to_filename($self-&gt;gethostname().$$);<br/>&gt; - $self-&gt;{tag_sub} ||= sub { return $self-&gt;{tag}; };<br/>&gt; + $self-&gt;{hash} ||= hash_string_to_filename($self-&gt;gethostname().$$);<br/>&gt; + if (defined $self-&gt;{tag}) {<br/>&gt; + $self-&gt;{tag_sub} ||= sub { return $self-&gt;{tag}; };<br/>&gt; + }<br/>&gt; $self-&gt;{tag_max_length} ||= 128;<br/>&gt; if (!defined $self-&gt;{tag_warn}) {<br/>&gt; $self-&gt;{tag_warn} = 1;<br/>&gt; @@ -456,9 +458,10 @@<br/>&gt; <br/>&gt; Pick up the next job in the queue, so that it can be processed.<br/>&gt; <br/>&gt; -The parameter C&lt;$filter&gt; can be used to specify a regular expression which<br/>&gt; -is matched against the queued filename. All files which don&#39;t match will be <br/>&gt; -skipped.<br/>&gt; +The parameter C&lt;$filter&gt; can be used to specify either a string or a regular <br/>&gt; +expression (with qr//) which is compared (the the first case) or matched <br/>&gt; +(in the latter case) against the tag part of the queued filename. All files <br/>&gt; +which don&#39;t match will be skipped.<br/>&gt; <br/>&gt; If no job is available for processing, either because the queue is<br/>&gt; empty or because other worker processes are already working on<br/>&gt; @@ -709,7 +712,7 @@<br/>&gt; while (time == $qdirlaststat) {<br/>&gt; Time::HiRes::usleep ($pollintvl);<br/>&gt; dbg &quot;wait_for_queued_job: spinning until time != stat $qdirlaststat&quot;;<br/>&gt; - my $job = $self-&gt;pickup_queued_job();<br/>&gt; + my $job = $self-&gt;pickup_queued_job($filter);<br/>&gt; if ($job) { return $job; }<br/>&gt; }<br/>&gt; <br/>&gt; @@ -739,7 +742,7 @@<br/>&gt; <br/>&gt; ###########################################################################<br/>&gt; <br/>&gt; -=item $job = $dq-&gt;visit_all_jobs($visitor, $visitcontext);<br/>&gt; +=item $job = $dq-&gt;visit_all_jobs($visitor, $visitcontext, $filter);<br/>&gt; <br/>&gt; Visit all the jobs in the queue, in a read-only mode. Used to list<br/>&gt; the entire queue.<br/>&gt; @@ -759,15 +762,17 @@<br/>&gt; &#39;active_host&#39;: the hostname on which the job is active<br/>&gt; &#39;active_pid&#39;: the process ID of the process which picked up the job<br/>&gt; <br/>&gt; +The jobs can be filtered with C&lt;$filter&gt; as in C&lt;pickup_queued_job()&gt;.<br/>&gt; +<br/>&gt; =cut<br/>&gt; <br/>&gt; sub visit_all_jobs {<br/>&gt; - my ($self, $visitor, $visitcontext) = @_;<br/>&gt; + my ($self, $visitor, $visitcontext, $filter) = @_;<br/>&gt; <br/>&gt; my $pathqueuedir = $self-&gt;q_subdir(&#39;queue&#39;);<br/>&gt; my $pathactivedir = $self-&gt;q_subdir(&#39;active&#39;);<br/>&gt; <br/>&gt; - my $iter = $self-&gt;queue_iter_start($pathqueuedir);<br/>&gt; + my $iter = $self-&gt;queue_iter_start($pathqueuedir, $filter);<br/>&gt; <br/>&gt; my $nextfile;<br/>&gt; while (1) {<br/>&gt; @@ -1118,30 +1123,39 @@<br/>&gt; <br/>&gt; my @gmt = gmtime ($job-&gt;{time_submitted_secs});<br/>&gt; <br/>&gt; - # NN.20040718140300MMMM.tag[.rand]<br/>&gt; + # NN.20040718140300MMMM[.tag].hash[.rand]<br/>&gt; #<br/>&gt; # NN = priority, default 50<br/>&gt; # MMMM = microseconds from Time::HiRes::gettimeofday()<br/>&gt; - # tag = some base64-ish string, default hash(hostname.$$)<br/>&gt; + # hash = hash(hostname.$$)<br/>&gt; + # tag = some base64-ish string<br/>&gt; # hostname = current hostname<br/>&gt; <br/>&gt; - my $base = sprintf (&quot;%02d.%04d%02d%02d%02d%02d%02d%06d.&quot;,<br/>&gt; + my $file = sprintf (&quot;%02d.%04d%02d%02d%02d%02d%02d%06d&quot;,<br/>&gt; $job-&gt;{pri},<br/>&gt; $gmt[5]+1900, $gmt[4]+1, $gmt[3], $gmt[2], $gmt[1], $gmt[0],<br/>&gt; $job-&gt;{time_submitted_msecs});<br/>&gt; <br/>&gt; + # add tag (including leading dot, only if wanted) and hash<br/>&gt; + $file .= $self-&gt;get_q_filename_tag($job).&quot;.&quot;.$self-&gt;{hash};<br/>&gt; +<br/>&gt; # normally, this isn&#39;t used. but if there&#39;s a collision,<br/>&gt; # all retries after that will do this; in this case, the<br/>&gt; # extra anti-collision stuff is useful<br/>&gt; - my $extra = $addextra ? &quot;.&quot;.$$.&quot;.&quot;.$self-&gt;get_random_int() : &quot;&quot;;<br/>&gt; + if ($addextra) {<br/>&gt; + $file .= &quot;.&quot;.$$.&quot;.&quot;.$self-&gt;get_random_int();<br/>&gt; + }<br/>&gt; <br/>&gt; - return $base.$self-&gt;get_q_filename_tag($job, $base, $extra).$extra;<br/>&gt; + return $file;<br/>&gt; }<br/>&gt; <br/>&gt; sub get_q_filename_tag {<br/>&gt; - my($self, $job, $base, $extra) = @_;<br/>&gt; - # create a (new?) tag<br/>&gt; - my $str = $self-&gt;{tag_sub}-&gt;($job, $base, $extra) || &#39;&#39;;<br/>&gt; + my($self, $job) = @_;<br/>&gt; + # return an empty string if there&#39;s nothing to do<br/>&gt; + return &#39;&#39; unless defined $self-&gt;{tag_sub};<br/>&gt; + # create a (new?) tag, possibly empty<br/>&gt; + my $str = $self-&gt;{tag_sub}-&gt;($job);<br/>&gt; + return &#39;&#39; unless defined $str;<br/>&gt; # weed out all dangerous chars<br/>&gt; my $tag = filter_unsafe_chars($str);<br/>&gt; # limit the length<br/>&gt; @@ -1150,7 +1164,7 @@<br/>&gt; if ($self-&gt;{tag_warn} &amp;&amp; $tag ne $str) {<br/>&gt; warn &quot;IPC::DirQueue: the tag was filtered\n&quot;;<br/>&gt; }<br/>&gt; - return $tag;<br/>&gt; + return &quot;.$tag&quot;;<br/>&gt; }<br/>&gt; <br/>&gt; sub hash_string_to_filename {<br/>&gt; @@ -1242,23 +1256,37 @@<br/>&gt; <br/>&gt; sub queue_iter_start {<br/>&gt; my ($self, $pathqueuedir, $filter, $type) = @_;<br/>&gt; - <br/>&gt; - $filter ||= qr/^/;<br/>&gt; +<br/>&gt; + $filter = qr// unless defined $filter;<br/>&gt; dbg (&quot;queue iter: filter $filter in $pathqueuedir&quot;);<br/>&gt; unless (ref $filter eq &#39;CODE&#39;) {<br/>&gt; # we need to copy $filter here else the closure will get annoyed<br/>&gt; - my $f = $filter;<br/>&gt; + my $re = $filter;<br/>&gt; + unless (ref ($re) eq &#39;Regexp&#39;) {<br/>&gt; + $re = quotemeta($re);<br/>&gt; + $re = qr/^${re}$/;<br/>&gt; + }<br/>&gt; $filter = sub {<br/>&gt; - if (wantarray) { # grep is picky about list context<br/>&gt; - return grep { /^\d/ &amp;&amp; /$f/ } @_;<br/>&gt; - }<br/>&gt; - else {<br/>&gt; - $_ = shift;<br/>&gt; - return unless defined;<br/>&gt; - return unless /^\d/;<br/>&gt; - return unless /$f/;<br/>&gt; - return $_;<br/>&gt; + # we can&#39;t use grep because it is picky about <br/>&gt; + # list context and this sub can be called for<br/>&gt; + # single files and grep would return the count<br/>&gt; + # in those cases<br/>&gt; + my @r;<br/>&gt; + while (@_) {<br/>&gt; + my $f = shift;<br/>&gt; + next unless defined $f;<br/>&gt; + next unless $f =~ /^\d/;<br/>&gt; + # we&#39;ve got to go split here to make the ^<br/>&gt; + # and $ anchors work <br/>&gt; + my @f = split(/\./, $f);<br/>&gt; + # does this file have a tag (ie. even number<br/>&gt; + # of elements)?<br/>&gt; + next if scalar (@f) % 2;<br/>&gt; + # apply the tag<br/>&gt; + next unless $f[2] =~ $re;<br/>&gt; + push(@r, $f);<br/>&gt; }<br/>&gt; + return wantarray ? @r : $r[0];<br/>&gt; };<br/>&gt; }<br/>&gt; <br/>&gt; @@ -1358,11 +1386,11 @@<br/>&gt; @files = sort $iter-&gt;{filter}-&gt;(readdir(DIR));<br/>&gt; closedir DIR;<br/>&gt; }<br/>&gt; - <br/>&gt; +<br/>&gt; if (scalar @files &lt;= 0) {<br/>&gt; return if $self-&gt;queuedir_is_bad($iter-&gt;{dir});<br/>&gt; }<br/>&gt; - <br/>&gt; +<br/>&gt; $iter-&gt;{type} = &#39;files&#39;;<br/>&gt; $iter-&gt;{files} = \@files;<br/>&gt; return $iter;<br/>&gt; @@ -1555,8 +1583,7 @@<br/>&gt; <br/>&gt; The filename format is as follows:<br/>&gt; <br/>&gt; - 50.20040909232529941258.TAG[.PID.RAND]<br/>&gt; - | base |tag | extra |<br/>&gt; + 50.20040909232529941258[.TAG].HASH[.PID.RAND]<br/>&gt; <br/>&gt; The first two digits (C&lt;50&gt;) are the priority of the job. Lower priority<br/>&gt; numbers are run first. C&lt;20040909232529&gt; is the current date and time when the<br/>&gt; @@ -1568,10 +1595,8 @@<br/>&gt; possible to set this manually with the C&lt;tag&gt; parameter of the constructor, or even<br/>&gt; to have it generated dynamically by the routine set with C&lt;tag_sub&gt;.<br/>&gt; <br/>&gt; -The sub routine is called with the parameters C&lt;$job&gt;, C&lt;$base&gt; and C&lt;$extra&gt;. The<br/>&gt; -first is the job currently enqueued and thus allows access to the metadata. The <br/>&gt; -latter two parameters correspond to the already known parts of the filename as<br/>&gt; -shown above (including the dots).<br/>&gt; +The sub routine is called with a single parameter C&lt;$job&gt;. This is the job <br/>&gt; +currently enqueued and thus allows access to the metadata.<br/>&gt; <br/>&gt; Note that only characters from the set [A-Za-z0-9+_] are allowed and the length<br/>&gt; of the string is limited to 128 characters. If any of these restrictions are<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg17.html Thu, 04 Jan 2007 05:34:52 +0000 Re: [PATCH] Advanced tagging and filtering by Malte S. Stretz On Wednesday 03 January 2007 16:38 CET Justin Mason wrote:<br/>&gt; backwards compatibility is not a problem here, so go ahead and<br/>&gt; add the tag in addition to the hash.<br/>&gt;<br/>&gt; I think the best location is just before the hash, e.g.<br/>&gt;<br/>&gt; 50.20040909232529941258.TAG.HASH[.PID.RAND]<br/>&gt;<br/>&gt; (vs the simple<br/>&gt;<br/>&gt; 50.20040909232529941258.HASH[.PID.RAND]<br/>&gt;<br/>&gt; when tags are not in use.)<br/>&gt;<br/>&gt; &gt; Actually, when people start to filter the files based on their name,<br/>&gt; &gt; the format must not change anymore in future. Maybe the filter should<br/>&gt; &gt; apply to the tag only...<br/>&gt;<br/>&gt; Yes, I think that&#39;s a good idea... people shouldn&#39;t have to worry about<br/>&gt; the rest of the filename changing.<br/><br/>Ok, attached is a patch on top of the last one which changes the code as you <br/>described it above. Additionally there&#39;s a revamped test.<br/><br/>While I was hunting another totally stupid bug, I found out that I actually <br/>forgot to add the $filter in the second call to pickup_job in wait_for_job. <br/>Gave some nasty surprises. And visit_all_jobs now supports $filter, too.<br/><br/>The syntax for $filter has changed a bit: If it is a string, it must be <br/>equal the tag, if it is a RE created with qr// it is matched as a RE.<br/><br/>Can you update the QUEUE DIRECTORY STRUCTURE section for me? Your English <br/>is a lot better than mine :)<br/><br/>Cheers,<br/>Malte<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg16.html Wed, 03 Jan 2007 12:16:38 +0000 Re: [PATCH] Advanced tagging and filtering by jm <br/>Malte S. Stretz writes:<br/>&gt; On Wednesday 03 January 2007 13:02 CET Justin Mason wrote:<br/>&gt; &gt; hi Malte!<br/>&gt; &gt;<br/>&gt; &gt; Thanks for this, it looks very useful indeed. One tweak, though:<br/>&gt; &gt; &gt; b) Makes the TAG part of the filename configurable. Ah, yeah, TAG was<br/>&gt; &gt; &gt; called HASH before :) I added the parameters tag (static tag), tag_sub<br/>&gt; &gt; &gt; (callback to generate a dynamic tag) and two more (tag_max_length and<br/>&gt; &gt; &gt; tag_warn, cf. inline doc).<br/>&gt; &gt;<br/>&gt; &gt; I would prefer to *add* the TAG part *as well as* the HASH stuff.<br/>&gt; &gt; The hash is useful, since it avoids collisions -- TAG doesn&#39;t make<br/>&gt; &gt; that guarantee (nor should it have to).<br/>&gt; &gt;<br/>&gt; &gt; That should be OK, right?<br/>&gt; <br/>&gt; Yeah, that was my original plan. But I wanted to keep the filename format <br/>&gt; backwards compatible. Not sure if thats really needed, I also wasn&#39;t sure <br/>&gt; if I should add the tag in the front, the end or in between. In the end I <br/>&gt; went for compatibility and assumed that in most cases the tags will still <br/>&gt; be quite unique -- at least in the producer/consumer case where you&#39;ve got <br/>&gt; most probably some kind of pid in there they will be at least as unique as <br/>&gt; the current hostname/pid based ones. And if not, we&#39;ve got the timestamp <br/>&gt; plus the additional really random part at the end :)<br/><br/>backwards compatibility is not a problem here, so go ahead and<br/>add the tag in addition to the hash.<br/><br/>I think the best location is just before the hash, e.g.<br/><br/> 50.20040909232529941258.TAG.HASH[.PID.RAND]<br/><br/>(vs the simple<br/><br/> 50.20040909232529941258.HASH[.PID.RAND]<br/><br/>when tags are not in use.)<br/><br/>&gt; Actually, when people start to filter the files based on their name, the <br/>&gt; format must not change anymore in future. Maybe the filter should apply to <br/>&gt; the tag only...<br/><br/>Yes, I think that&#39;s a good idea... people shouldn&#39;t have to worry about<br/>the rest of the filename changing.<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg15.html Wed, 03 Jan 2007 07:39:31 +0000 Re: [PATCH] Advanced tagging and filtering by Malte S. Stretz On Wednesday 03 January 2007 13:02 CET Justin Mason wrote:<br/>&gt; hi Malte!<br/>&gt;<br/>&gt; Thanks for this, it looks very useful indeed. One tweak, though:<br/>&gt; &gt; b) Makes the TAG part of the filename configurable. Ah, yeah, TAG was<br/>&gt; &gt; called HASH before :) I added the parameters tag (static tag), tag_sub<br/>&gt; &gt; (callback to generate a dynamic tag) and two more (tag_max_length and<br/>&gt; &gt; tag_warn, cf. inline doc).<br/>&gt;<br/>&gt; I would prefer to *add* the TAG part *as well as* the HASH stuff.<br/>&gt; The hash is useful, since it avoids collisions -- TAG doesn&#39;t make<br/>&gt; that guarantee (nor should it have to).<br/>&gt;<br/>&gt; That should be OK, right?<br/><br/>Yeah, that was my original plan. But I wanted to keep the filename format <br/>backwards compatible. Not sure if thats really needed, I also wasn&#39;t sure <br/>if I should add the tag in the front, the end or in between. In the end I <br/>went for compatibility and assumed that in most cases the tags will still <br/>be quite unique -- at least in the producer/consumer case where you&#39;ve got <br/>most probably some kind of pid in there they will be at least as unique as <br/>the current hostname/pid based ones. And if not, we&#39;ve got the timestamp <br/>plus the additional really random part at the end :)<br/><br/>Actually, when people start to filter the files based on their name, the <br/>format must not change anymore in future. Maybe the filter should apply to <br/>the tag only...<br/><br/>Cheers,<br/>Malte<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg14.html Wed, 03 Jan 2007 07:28:22 +0000 Re: [PATCH] Advanced tagging and filtering by jm <br/>hi Malte!<br/><br/>Thanks for this, it looks very useful indeed. One tweak, though:<br/><br/>&gt; b) Makes the TAG part of the filename configurable. Ah, yeah, TAG was <br/>&gt; called HASH before :) I added the parameters tag (static tag), tag_sub <br/>&gt; (callback to generate a dynamic tag) and two more (tag_max_length and <br/>&gt; tag_warn, cf. inline doc).<br/><br/>I would prefer to *add* the TAG part *as well as* the HASH stuff.<br/>The hash is useful, since it avoids collisions -- TAG doesn&#39;t make<br/>that guarantee (nor should it have to).<br/><br/>That should be OK, right?<br/><br/>otherwise, all looks good...<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2007/01/msg13.html Wed, 03 Jan 2007 06:13:42 +0000 [PATCH] Advanced tagging and filtering by Malte S. Stretz Hi Justin,<br/><br/>I was looking for a nice IPC module on CPAN and what did I find? Yet <br/>another Perl Module created by you :)<br/><br/>Unfortunately was IPC::DirQueue really slow in one of the cases I tried to <br/>use it for. Thats why I wrote the attached patch. But first: What do I <br/>need?<br/><br/>I have a server which has a tcpdump running, listening for UDP packets, and <br/>where you can connect via TCP to request notifications about some kind of <br/>packets. The notifications are based on ids which are inside the UDP <br/>packets. (This is actually used to do some UDP hole punching as a <br/>University project.)<br/><br/>So we&#39;ve got two parallel queues, one for the incoming requests and one for <br/>the outgoing replies. On the one side we can have n processes pushing <br/>requests into the incoming queue and waiting for replies on the outgoing <br/>one. On the other side is just a single consumer/producer, which parses <br/>the tcpdump output, looks wether there&#39;s a request for the id in the <br/>incoming queue and if so, puts a reply into the outgoing queue which is <br/>then sent via TCP to the user.<br/><br/>That worked pretty well but at some point I got an almost-deadlock: If one <br/>of the clients pushes loads of requests into the incoming queue, it can <br/>overwhelm the consumer which can happen to look at all those new packets <br/>first before it sees the request it was actually looking for. Additionally <br/>is there quite some overhead because each time the metadata has to be read <br/>first before I can identify the owner.<br/><br/>Actually the following simple code can have the effect I described above:<br/> use IPC::DirQueue;<br/> my $dq = IPC::DirQueue-&gt;new({ dir =&gt; &#39;dq&#39; });<br/> $dq-&gt;enqueue_string(&quot;foo!&quot;, {id =&gt; &#39;foo&#39;});<br/> $dq-&gt;enqueue_string(&quot;bar!&quot;, {id =&gt; &#39;bar&#39;});<br/> while (1) {<br/> my $job = $dq-&gt;wait_for_queued_job(0, 0.1);<br/> my $id = $job-&gt;{metadata}-&gt;{id};<br/> #print $id;<br/> if ($id eq &#39;foo&#39;) {<br/> my $data = $job-&gt;get_data();<br/> $job-&gt;finish();<br/> print $data;<br/> }<br/> else {<br/> $job-&gt;return_to_queue();<br/> }<br/> }<br/>If started often enough, at some point we will have loads of bars which <br/>block the foos. Just uncomment the print $id and the app will scream bar <br/>all the time but never foo. Hmmm... I guess there&#39;s actually another bug <br/>hidden because sometimes I see no foo at all; maybe the dir iterator is <br/>reset or something.<br/><br/>Whatever, I actually went to increase the speed for applications like this. <br/>The attached patch does the following:<br/><br/>a) Adds a parameter file_mode to the constructor; doesn&#39;t really increase <br/>speed but I guess in most cases one wants to change both modes and this way <br/>its less code :)<br/><br/>b) Makes the TAG part of the filename configurable. Ah, yeah, TAG was <br/>called HASH before :) I added the parameters tag (static tag), tag_sub <br/>(callback to generate a dynamic tag) and two more (tag_max_length and <br/>tag_warn, cf. inline doc).<br/><br/>c) Adds $filter parameter to wait_for_queued_job() and pickup_queued_job(). <br/>These accept a regular expression which is matched against the queue file <br/>name. I don&#39;t really like the position of the $filter parameter in the <br/>wait method, I&#39;d prefer to have it as the first parameter and experimented <br/>with a &#39;ref $_[1] eq Regexp&#39; to keep it backwards compatible but then just <br/>went the simple way and put it to the end :)<br/><br/>d) The actual filtering stuff is done in the iterators. I guess I did <br/>quite some refactoring/rewriting there. The most important thing is the <br/>$iter-&gt;{filter} code, that I made the iterator more or less independent <br/>from the $self object and thus could use it to rewrite the fanout stuff to <br/>use a recursive (unordered) iterator, thus reducing code duplication.<br/><br/>The tests all work (again) and I attached another one for the stuff I did.<br/><br/>So, with the patch, change the code above into the following and its fast <br/>as... dunno, but something really fast :)<br/> use IPC::DirQueue;<br/> my $dq = IPC::DirQueue-&gt;new({ dir =&gt; &#39;dq&#39;, tag_sub =&gt; sub {<br/> return $_[0]-&gt;{metadata}-&gt;{id};<br/> }});<br/> $dq-&gt;enqueue_string(&quot;foo!&quot;, {id =&gt; &#39;foo&#39;});<br/> $dq-&gt;enqueue_string(&quot;bar!&quot;, {id =&gt; &#39;bar&#39;});<br/> while (1) {<br/> my $job = $dq-&gt;wait_for_queued_job(0, 0.1, qr/\.foo(\..*|)$/);<br/> my $id = $job-&gt;{metadata}-&gt;{id};<br/> #print $id;<br/> my $data = $job-&gt;get_data();<br/> print $data;<br/> $job-&gt;finish();<br/> }<br/><br/>Cheers,<br/>Malte<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/12/msg12.html Fri, 29 Dec 2006 12:51:56 +0000 Re: released version 0.08 of IPC::DirQueue by jm <br/>ha -- that&#39;s version 0.08, not &quot;x.xx&quot; ;)<br/><br/>--j.<br/><br/>Justin Mason writes:<br/>&gt; Hi --<br/>&gt; <br/>&gt; Version 0.08 of IPC::DirQueue is now released, and should be showing<br/>&gt; up on CPAN rsn. Changes since 0.07:<br/>&gt; <br/>&gt; ------------------------------------------------------------------------<br/>&gt; r8093 | jmason | 2006-11-21 13:04:53 +0000 (Tue, 21 Nov 2006) | 1 line<br/>&gt; <br/>&gt; add t/12_no_dir.t, to test for bug 21312 (no queue directory causes die())<br/>&gt; ------------------------------------------------------------------------<br/>&gt; r6840 | jmason | 2006-09-04 11:18:38 +0100 (Mon, 04 Sep 2006) | 1 line<br/>&gt; <br/>&gt; calling visit_all_jobs() with a nonexistent queue directory triggered some broken err<br/>&gt; or-handling code, resulting in a die(); fixed. thanks to Keith Amling, http://rt.cpa<br/>&gt; n.org/Public/Bug/Display.html?id=21312<br/>&gt; ------------------------------------------------------------------------<br/>&gt; r6839 | jmason | 2006-09-04 11:16:10 +0100 (Mon, 04 Sep 2006) | 1 line<br/>&gt; <br/>&gt; documentation clarification on queue structure; some of the grammar was poor<br/>&gt; ------------------------------------------------------------------------<br/>&gt; r6694 | jmason | 2006-07-24 14:10:27 +0100 (Mon, 24 Jul 2006) | 1 line<br/>&gt; <br/>&gt; adding CHANGES file to svn<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/11/msg11.html Tue, 21 Nov 2006 06:21:10 +0000 released version x.xx of IPC::DirQueue by jm Hi --<br/><br/>Version 0.08 of IPC::DirQueue is now released, and should be showing<br/>up on CPAN rsn. Changes since 0.07:<br/><br/>------------------------------------------------------------------------<br/>r8093 | jmason | 2006-11-21 13:04:53 +0000 (Tue, 21 Nov 2006) | 1 line<br/><br/>add t/12_no_dir.t, to test for bug 21312 (no queue directory causes die())<br/>------------------------------------------------------------------------<br/>r6840 | jmason | 2006-09-04 11:18:38 +0100 (Mon, 04 Sep 2006) | 1 line<br/><br/>calling visit_all_jobs() with a nonexistent queue directory triggered some broken err<br/>or-handling code, resulting in a die(); fixed. thanks to Keith Amling, http://rt.cpa<br/>n.org/Public/Bug/Display.html?id=21312<br/>------------------------------------------------------------------------<br/>r6839 | jmason | 2006-09-04 11:16:10 +0100 (Mon, 04 Sep 2006) | 1 line<br/><br/>documentation clarification on queue structure; some of the grammar was poor<br/>------------------------------------------------------------------------<br/>r6694 | jmason | 2006-07-24 14:10:27 +0100 (Mon, 24 Jul 2006) | 1 line<br/><br/>adding CHANGES file to svn<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/11/msg10.html Tue, 21 Nov 2006 05:51:32 +0000 Re: Changing metadata inside of a job runner by jm <br/>Duncan Hill writes:<br/>&gt; I&#39;m looking at your IPC::DirQueue module as a solution to my current <br/>&gt; home-grown queue runner, and have a few questions that a brief check of the <br/>&gt; module doesn&#39;t answer.<br/>&gt; <br/>&gt; 1) Can the metadata be written to from a job runner? There&#39;s no function for <br/>&gt; this, but there&#39;s nothing obvious saying &#39;don&#39;t do that&#39;.<br/>&gt; 2) If not, would you consider this feature?<br/>&gt; <br/>&gt; Essentially, the code I&#39;m fitting dq into talks to an SQL database a lot. If <br/>&gt; a log file encounters a failure being parsed, I&#39;d like to be able to tag the <br/>&gt; metadata with a &#39;don&#39;t touch, leper&#39; flag so that other queue runners don&#39;t <br/>&gt; try to handle it when it gets returned to the queue. Without the ability to <br/>&gt; change the metadata, all I can do is crank the priority down, and have a <br/>&gt; specialised runner that only picks up low priority items and moves them out <br/>&gt; of the main queue (which would work I suppose).<br/><br/>hi --<br/><br/>Unfortunately not :( Right now, the metadata is written to only<br/>once, at enqueue time, and only read thereafter.<br/><br/>It&#39;d make a good patch, though ;)<br/><br/>--j.<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/05/msg9.html Wed, 10 May 2006 14:46:50 +0000 CPAN Upload: J/JM/JMASON/IPC-DirQueue-0.07.tar.gz (fwd) by Justin Mason <br/>changes:<br/><br/>- support running the tests with a perl that isn&#39;t /usr/bin/perl, e.g.<br/> after running &#39;/usr/local/perl561/bin/perl Makefile.PL; make; make test&#39;<br/><br/>- The utime() idiom being used to touch files and directories was only<br/> added in perl 5.7.2. Add backwards-compat code to deal with the 5.6.x<br/> callers<br/><br/>- oops, indexd t scripts required POE, so the tests failed if that module<br/> wasn&#39;t installed. make them optional and not run if POE isn&#39;t installed<br/><br/>--j.<br/><br/>------- Forwarded Message<br/><br/>Date: Mon, 10 Apr 2006 22:30:27 +0200<br/>From: PAUSE &lt;upload@pause.perl.org&gt;<br/>To: &quot;Justin Mason&quot; &lt;jm-cpan@jmason.org&gt;<br/>Subject: CPAN Upload: J/JM/JMASON/IPC-DirQueue-0.07.tar.gz<br/><br/>The uploaded file<br/><br/> IPC-DirQueue-0.07.tar.gz<br/><br/>has entered CPAN as<br/><br/> file: $CPAN/authors/id/J/JM/JMASON/IPC-DirQueue-0.07.tar.gz<br/> size: 25658 bytes<br/> md5: 2b8ffecc3ab15c4610c459fd3c038434<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/04/msg8.html Mon, 10 Apr 2006 13:34:21 +0000 IPC::DirQueue 0.06 released by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/><br/>hey all --<br/><br/>I&#39;ve just uploaded v0.06 of IPC::DirQueue. This has a few interesting<br/>changes; lemme quote CHANGES on the big ones:<br/><br/> - API CHANGE: invalid metadata in an enqueued job will now causes die()<br/> to be called, instead of silent ignore.<br/><br/> - add dq-indexd, an optional, experimental central server to maintain DQ<br/> indexes, instead of using readdir() filesystem APIs. It requires POE<br/><br/> - fix race condition in wait_for_queued_job() that can result in missing<br/> jobs enqueued inside the same 1-second window. This would only<br/> manifest if no further files were enqueued to the same dir.<br/><br/> - make the 600-second active-lock timeout configurable; document it<br/> better; and reconcile code behaviour with what the documentation<br/> says it does re behaviour when a stale lock occurs on a task<br/> supposedly active on a remote system. (The code was changed to<br/> match the documentation.)<br/><br/> - fixed a long-running bug; left-over control files in &#39;active&#39;. Turns<br/> out these were a side effect of qproc A completing a task before qproc<br/> B even started creating a lockfile; in that case, qproc B would get a<br/> lock on the now-complete task, then find that the queue control file<br/> was nonexistent and give up, attempting to remove the &#39;active&#39; file,<br/> but instead unlinking the now-already-unlinked temporary filename, and<br/> leaving the real &#39;active&#39; file behind. Totally harmless, fixed<br/> anyway.<br/><br/> - support Reiserfs and XFS queue dirs, which do not update directory<br/> mtimes when a file is creating within them.<br/><br/> - patch from Anton Berezin &lt;tobez.at.tobez.org&gt;: return reference of<br/> sorted files list internally, and use built-in sort instead of a {<br/> $a cmp $b } callback. Both are good for speed of ordered<br/> dequeuing<br/><br/><br/>It&#39;s filtering through CPAN now. I wouldn&#39;t recommend using dq-indexd<br/>for anything serious just yet -- it&#39;s still experimental! -- but the<br/>rest of those features are solid, and the fix for the &quot;leftover control<br/>files&quot; bug is welcome. ;)<br/><br/>for what it&#39;s worth, here&#39;s some dq-indexd benchmarks from a mixed<br/>ethernet/wireless (home) network, in case you all are curious ;) --<br/><br/>LOCAL TIMINGS:<br/><br/> 85changing_indexd.t<br/> real 0m53.525s user 0m5.228s sys 0m0.446s<br/> real 0m53.452s user 0m5.113s sys 0m0.536s<br/> real 0m53.437s user 0m5.411s sys 0m0.454s<br/><br/> 85changing_ordered.t<br/> real 0m52.359s user 0m0.350s sys 0m0.121s<br/> real 0m52.432s user 0m0.352s sys 0m0.104s<br/> real 0m51.588s user 0m0.256s sys 0m0.077s<br/><br/> 85changing_basic.t<br/> real 0m52.314s user 0m0.143s sys 0m0.043s<br/> real 0m51.337s user 0m0.346s sys 0m0.106s<br/> real 0m52.480s user 0m0.345s sys 0m0.122s<br/><br/><br/>REMOTE TIMINGS:<br/><br/> 85changing_indexd.t<br/> real 3m07.718s user 0m3.191s sys 0m1.065s<br/> real 3m06.452s user 0m3.881s sys 0m1.324s<br/> real 3m09.563s user 0m3.532s sys 0m1.244s<br/><br/> 85changing_ordered.t<br/> real 3m21.705s user 0m0.646s sys 0m0.836s<br/> real 3m31.031s user 0m0.630s sys 0m1.002s<br/> real 3m26.674s user 0m0.645s sys 0m1.027s<br/><br/> 85changing_basic.t<br/> real 3m46.062s user 0m0.585s sys 0m0.764s<br/> real 3m40.202s user 0m0.465s sys 0m0.609s<br/> real 3m49.065s user 0m0.558s sys 0m0.854s<br/><br/><br/>cheers,<br/><br/>- --j.<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.4.1 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFDwx+rMJF5cimLx9ARAkphAJ4xSceOTjc/6q55vlrgvXCt0EKOrACfXYXk<br/>inMnkoDQb2XRo7k7m6XrGfw=<br/>=TGm3<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/01/msg7.html Mon, 09 Jan 2006 18:47:11 +0000 Re: [PATCH] speed up ordered dequeueing in IPC-DirQueue 0.05 by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/>(cc&#39;d mailing list)<br/><br/>Anton Berezin writes:<br/>&gt; Justin,<br/>&gt; <br/>&gt; On Thu, Dec 29, 2005 at 02:18:06PM +0100, Anton Berezin wrote:<br/>&gt; <br/>&gt; &gt; I don&#39;t think it is possibly to do much with the algorithm as such,<br/>&gt; &gt; since the sorting needs to be done, and the results cannot really be<br/>&gt; &gt; cached if we want the ordered queue to be really ordered, but I found a<br/>&gt; &gt; definite thing to improve.<br/>&gt; <br/>&gt; On the further thought, even the existing ordered method does not<br/>&gt; provide us with an absolute guarantee that the things are going to be<br/>&gt; processed in order, since there is a race between readdir and newer<br/>&gt; enqueue operations. So it is possible to somewhat relax it even further<br/>&gt; and achieve a really good speed up for some, but not all, cases.<br/>&gt; <br/>&gt; The idea is to keep a last_enqueued file in the queue dir. We are only<br/>&gt; interested in its mtime. Then, on a dequeue operation, we cache the<br/>&gt; result of readdir and only re-read the file list if the cached file list<br/>&gt; is empty or if the mtime of last_enqueued file has changed.<br/>&gt; <br/>&gt; This obviously won&#39;t help much if there are a lot of concurrent enqueue<br/>&gt; operations, but for the case &quot;first enqueue a bunch of jobs, then launch<br/>&gt; several processors, then repeat after some time&quot; it helps absolutely<br/>&gt; tremendously.<br/><br/>Hi Anton --<br/><br/>many thanks for this work! The patches are welcome.<br/><br/>I&#39;ve applied the ordered-dequeueing speedup patch from the previous mail<br/>- -- with a few changes to match latest SVN (see below). It&#39;s in as r2353.<br/>I never thought the interpreter-level code path would have such a large<br/>effect on execution speed; I was assuming it&#39;d all be system calls, which<br/>*should* be a lot slower. Looks like I was wrong. ;)<br/><br/>However, regarding the patch from *this* mail, it&#39;s important to note that<br/>the underlying code changed in SVN at the start of December; r2255 added a<br/>&quot;last-enqueue&quot; flag file, initially at least. I then realised that the<br/>queue directory *itself* can be used for this purpose, in a<br/>backwards-compatible way, so now it just adds similar semantics to the<br/>directory inode itself.<br/><br/>I found that this change was necessitated to support Reiserfs and<br/>XFS-hosted queue directories, since those filesystems didn&#39;t modify the<br/>mtime of a directory when changes were made within it, as ext3 did. (I<br/>was assuming that this was a POSIX requirement; again, looks like I was<br/>wrong. ;)<br/><br/>There were then several more changes since then to SVN trunk, made to fix<br/>important bugs (including another race condition) and add new,<br/>experimental functionality.<br/><br/>This patch looks very useful -- I&#39;d be happy to add it, as a patch against<br/>current SVN, if that&#39;d be possible. Also, it may be worthwhile making it<br/>the ordered default, assuming I can&#39;t think of a good reason why not ;)<br/>Right now though, it doesn&#39;t apply cleanly to SVN.<br/><br/>by the way there is a mailing list; &lt;ipc-dirqueue-subscribe@perl.org&gt; to<br/>subscribe. it might be worth sending future patches there so other users can<br/>comment on them too.<br/><br/>- --j.<br/><br/>&gt; I did not think it was a good idea to modify the default &quot;ordered&quot;<br/>&gt; behavior, so my patch makes &quot;ordered&quot; options to be a tri-value, with<br/>&gt; &quot;2&quot; denoting this &quot;approximately ordered&quot; way of doing things.<br/>&gt; <br/>&gt; The result of the same tests as yesterday, with ordered =&gt; 2 is<br/>&gt; <br/>&gt; tobez@heechee ~/_&gt; time perl eq 10000 <br/>&gt; perl eq 10000 1.73s user 1.90s system 44% cpu 8.180 total<br/>&gt; tobez@heechee ~/_&gt; time perl deq 10000<br/>&gt; perl deq 10000 1.39s user 2.12s system 94% cpu 3.726 total<br/>&gt; <br/>&gt; This represents a 30-fold improvement for the dequeueing case in<br/>&gt; comparison to the yesterdays &quot;optimized&quot; version.<br/>&gt; <br/>&gt; Below is the patch which also incorporates my previous changes.<br/>&gt; <br/>&gt; --- DirQueue.pm.orig Thu Dec 29 14:14:10 2005<br/>&gt; +++ DirQueue.pm Fri Dec 30 12:53:41 2005<br/>&gt; @@ -101,10 +101,12 @@ The C&lt;chmod&gt;-style file mode for queue c<br/>&gt; specified as a string with a leading 0. It will be affected by the<br/>&gt; current process C&lt;umask&gt;.<br/>&gt; <br/>&gt; -=item ordered =&gt; { 0 | 1 } (default: 1)<br/>&gt; +=item ordered =&gt; { 0 | 1 | 2 } (default: 1)<br/>&gt; <br/>&gt; Whether the jobs should be processed in order of submission, or<br/>&gt; -in no particular order.<br/>&gt; +in no particular order. The special value of 2 denotes &quot;approximately<br/>&gt; +ordered&quot;, which does not make as strong guarantees about processing<br/>&gt; +order as simply ordered queue, but is much faster in a number of cases.<br/>&gt; <br/>&gt; =item buf_size =&gt; $number (default: 65536)<br/>&gt; <br/>&gt; @@ -344,6 +346,7 @@ sub enqueue_backend {<br/>&gt; goto failure;<br/>&gt; }<br/>&gt; <br/>&gt; + $self-&gt;touch_last_enqueued() if $self-&gt;{ordered} == 2;<br/>&gt; # my $pathqueue_created = 1; # not required, we&#39;re done!<br/>&gt; return 1;<br/>&gt; <br/>&gt; @@ -360,6 +363,17 @@ failure:<br/>&gt; return;<br/>&gt; }<br/>&gt; <br/>&gt; +sub touch_last_enqueued<br/>&gt; +{<br/>&gt; + my ($self) = @_;<br/>&gt; + my $last_enqueued_file = $self-&gt;q_dir().SLASH.&quot;last_enqueued&quot;;<br/>&gt; + if (sysopen(LAST, $last_enqueued_file, O_WRONLY|O_CREAT, 0666)) {<br/>&gt; + my $s = &quot;X&quot;;<br/>&gt; + syswrite(LAST, $s, 1);<br/>&gt; + close LAST;<br/>&gt; + }<br/>&gt; +}<br/>&gt; +<br/>&gt; ###########################################################################<br/>&gt; <br/>&gt; =item $job = $dq-&gt;pickup_queued_job();<br/>&gt; @@ -384,12 +398,12 @@ sub pickup_queued_job {<br/>&gt; $self-&gt;ensure_dir_exists ($pathactivedir);<br/>&gt; <br/>&gt; my $ordered = $self-&gt;{ordered};<br/>&gt; - my @files;<br/>&gt; + my $files;<br/>&gt; my $dirfh;<br/>&gt; <br/>&gt; if ($ordered) {<br/>&gt; - @files = $self-&gt;get_dir_filelist_sorted($pathqueuedir);<br/>&gt; - if (scalar @files &lt;= 0) {<br/>&gt; + $files = $self-&gt;get_dir_filelist_sorted($pathqueuedir);<br/>&gt; + if (@$files &lt;= 0) {<br/>&gt; return if $self-&gt;queuedir_is_bad($pathqueuedir);<br/>&gt; }<br/>&gt; } else {<br/>&gt; @@ -406,7 +420,7 @@ sub pickup_queued_job {<br/>&gt; my $pathtmpactive;<br/>&gt; <br/>&gt; if ($ordered) {<br/>&gt; - $nextfile = shift @files;<br/>&gt; + $nextfile = shift @$files;<br/>&gt; } else {<br/>&gt; $nextfile = readdir($dirfh);<br/>&gt; }<br/>&gt; @@ -638,12 +652,12 @@ sub visit_all_jobs {<br/>&gt; my $pathactivedir = $self-&gt;q_subdir(&#39;active&#39;);<br/>&gt; <br/>&gt; my $ordered = $self-&gt;{ordered};<br/>&gt; - my @files;<br/>&gt; + my $files;<br/>&gt; my $dirfh;<br/>&gt; <br/>&gt; if ($ordered) {<br/>&gt; - @files = $self-&gt;get_dir_filelist_sorted($pathqueuedir);<br/>&gt; - if (scalar @files &lt;= 0) {<br/>&gt; + $files = $self-&gt;get_dir_filelist_sorted($pathqueuedir);<br/>&gt; + if (@$files &lt;= 0) {<br/>&gt; return if $self-&gt;queuedir_is_bad($pathqueuedir);<br/>&gt; }<br/>&gt; } else {<br/>&gt; @@ -658,7 +672,7 @@ sub visit_all_jobs {<br/>&gt; my $nextfile;<br/>&gt; while (1) {<br/>&gt; if ($ordered) {<br/>&gt; - $nextfile = shift @files;<br/>&gt; + $nextfile = shift @$files;<br/>&gt; } else {<br/>&gt; $nextfile = readdir($dirfh);<br/>&gt; }<br/>&gt; @@ -728,14 +742,30 @@ sub finish_job {<br/>&gt; <br/>&gt; sub get_dir_filelist_sorted {<br/>&gt; my ($self, $dir) = @_;<br/>&gt; + my $last_enqueued_file = $self-&gt;q_dir().SLASH.&quot;last_enqueued&quot;;<br/>&gt; +<br/>&gt; + if ($self-&gt;{ordered} == 2 &amp;&amp; $self-&gt;{filelist_sorted}{$dir}) {<br/>&gt; + my $mtime = (stat($last_enqueued_file))[9];<br/>&gt; + return $self-&gt;{filelist_sorted}{$dir}<br/>&gt; + if defined $mtime &amp;&amp; defined $self-&gt;{filelist_sorted_mtime}{$dir} &amp;&amp;<br/>&gt; + $mtime &lt;= $self-&gt;{filelist_sorted_mtime}{$dir} &amp;&amp;<br/>&gt; + @{$self-&gt;{filelist_sorted}{$dir}};<br/>&gt; + }<br/>&gt; <br/>&gt; if (!opendir (DIR, $dir)) {<br/>&gt; return (); # no dir? nothing queued<br/>&gt; }<br/>&gt; # have to read the lot, to sort them.<br/>&gt; - my @files = sort { $a cmp $b } grep { /^\d/ } readdir(DIR);<br/>&gt; + my @files = sort grep { /^\d/ } readdir(DIR);<br/>&gt; closedir DIR;<br/>&gt; - return @files;<br/>&gt; +<br/>&gt; + if ($self-&gt;{ordered} == 2) {<br/>&gt; + $self-&gt;{filelist_sorted_mtime}{$dir} = (stat($last_enqueued_file))[9];<br/>&gt; + $self-&gt;{filelist_sorted}{$dir} = \@files;<br/>&gt; + return $self-&gt;{filelist_sorted}{$dir};<br/>&gt; + } else {<br/>&gt; + return \@files;<br/>&gt; + }<br/>&gt; }<br/>&gt; <br/>&gt; ###########################################################################<br/>&gt; @@ -998,7 +1028,7 @@ sub new_q_filename {<br/>&gt; $job-&gt;{pri},<br/>&gt; $gmt[5]+1900, $gmt[4]+1, $gmt[3], $gmt[2], $gmt[1], $gmt[0],<br/>&gt; $job-&gt;{time_submitted_msecs},<br/>&gt; - hash_string_to_filename ($self-&gt;gethostname().$$));<br/>&gt; + hash_string_to_filename ($self-&gt;gethostname().$$.$self-&gt;get_random_int()));<br/>&gt; <br/>&gt; # normally, this isn&#39;t used. but if there&#39;s a collision,<br/>&gt; # all retries after that will do this; in this case, the<br/>&gt; <br/>&gt; \Anton.<br/>&gt; -- <br/>&gt; An undefined problem has an infinite number of solutions.<br/>&gt; -- Robert A. Humphrey<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.4.1 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFDvdyhMJF5cimLx9ARAgM4AJ0bCfFNHsx9SjdGYXLtzOjhPW9MeQCgguxc<br/>Ng8JAoBN7/thHp5CBgpSIIU=<br/>=l6su<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2006/01/msg6.html Thu, 05 Jan 2006 18:59:39 +0000 CPAN Upload: J/JM/JMASON/IPC-DirQueue-0.05.tar.gz (fwd) by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/><br/>IPC::DirQueue version 0.05 is released! Here&#39;s the key new features:<br/><br/> - new API: added enqueue_sub() API, to enqueue data from a closure.<br/><br/> - bug: more paranoid link_into_dir_no_retry implementation, hopefully<br/> will fix a bug that leaves tmp active files lying around.<br/><br/> - bug: skip fork()-requiring tests on win32.<br/><br/>should be showing up on<br/>http://www.cpan.org/modules/by-authors/id/J/JM/JMASON/ rsn...<br/><br/>- --j.<br/><br/><br/>- ------- Forwarded Message<br/>&gt; Date: Fri, 22 Apr 2005 22:05:22 +0200<br/>&gt; From: PAUSE &lt;upload@pause.perl.org&gt;<br/>&gt; To: &quot;Justin Mason&quot; &lt;jm-cpan@jmason.org&gt;<br/>&gt; Subject: CPAN Upload: J/JM/JMASON/IPC-DirQueue-0.05.tar.gz<br/>&gt; <br/>&gt; The uploaded file<br/>&gt; <br/>&gt; IPC-DirQueue-0.05.tar.gz<br/>&gt; <br/>&gt; has entered CPAN as<br/>&gt; <br/>&gt; file: $CPAN/authors/id/J/JM/JMASON/IPC-DirQueue-0.05.tar.gz<br/>&gt; size: 16861 bytes<br/>&gt; md5: 4ceb6ae1882c5412c3daed7e30f04f3a<br/>&gt; <br/>&gt; No action is required on your part<br/>&gt; Request entered by: JMASON (Justin Mason)<br/>&gt; Request entered on: Fri, 22 Apr 2005 20:03:17 GMT<br/>&gt; Request completed: Fri, 22 Apr 2005 20:05:22 GMT<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.2.5 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFCaVstMJF5cimLx9ARAu4hAKCVooT93bvn4JGmQW3qO93OaGTRhQCcCcjs<br/>+gvXBYoxsCcTHVaJdWNtvfI=<br/>=+2G+<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2005/04/msg5.html Fri, 22 Apr 2005 13:16:16 +0000 qpsmtpd queue plugin? by David Sparks Greetings,<br/><br/>I&#39;ve been investigating using this module with qpsmtpd. Does such a <br/>plugin already exist?<br/><br/>I hacked together a quick proof of concept to test performance of the <br/>methods and found roughly:<br/><br/>$dq-&gt;enqueue_file: 2600 msg/min<br/>$dq-&gt;enqueue_string: 2900 msg/min<br/><br/>Note these are qpsmtpd #s and the queue dir lives on a NFS mounted <br/>volume so it isn&#39;t showing IPC::DirQueue performance.<br/><br/>It also seems that when using the enqueue_file method the original file <br/>still exists and has to be rm&#39;d separately? Is this expected? My <br/>assumption (love em) was that the original file would be re-linked into <br/>the queue.<br/><br/>Cheers,<br/><br/>ds<br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2005/04/msg4.html Thu, 21 Apr 2005 00:21:55 +0000 Re: how to "kill" a job by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/><br/>Bruce Robertson writes:<br/>&gt; Is there such an API point?<br/>&gt; If not, do you have something under development?<br/>&gt; Else, any pointers on how to do it?<br/><br/>There isn&#39;t yet such a thing, no, and I haven&#39;t planned it. (yet)<br/><br/>Kill an as-yet unprocessed job would be easy -- simply an unlink.<br/>But if the job is active, it&#39;d be quite a bit harder; it&#39;s easy in the<br/>LPR-style of queueing, because that has (a) a central server and (b) each<br/>job is a separate process, so a kill(3) of the process can be used to kill<br/>the job, but in DQ, there&#39;s no separate process per job -- one process<br/>can deal with many jobs sequentially.<br/><br/>I would say the cleanest way to do it would be to arrange that dq servers<br/>can provide a new constructor switch indicating a signal that should<br/>be delivered if a job kill is to be requested; if that switch isn&#39;t<br/>present, killing an active job isn&#39;t supported.<br/><br/>The DQ server code would then write that to a flag file in the queue<br/>directory, so that DQ clients (ie. a new &quot;dq-kill&quot; script) can be aware<br/>that the server(s) support this.<br/><br/>The server code should then implement a signal handler for that signal;<br/>that handler will check to see if it is currently processing a killed job<br/>(ie. if the data file has been unlinked before it&#39;s complete), and give up<br/>the remainder of the job&#39;s processing if it is. <br/><br/>(alternatively, the server could just ignore the signal, if it&#39;s not an<br/>issue for that server&#39;s design, e.g. if the jobs are very lightweight, and<br/>completing processing of a killed job will not cause problems.)<br/><br/>If that constructor switch was not specified, I think it would be unsafe<br/>to assume that DQ kill is supported by that queue; we can&#39;t go unlinking<br/>active jobs without some kind of &quot;this is supported&quot; negotiation, as a<br/>disappearing job file may cause a die() in server code that wasn&#39;t aware<br/>this was likely to happen.<br/><br/>- --j.<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.2.5 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFCAZN6MJF5cimLx9ARAr5NAJ0XaiEfTu55tve/g2gmuylLfwrK7wCdF2yF<br/>dLOlbsvNhHl50TfJYtzwJfA=<br/>=jxvb<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2005/02/msg3.html Wed, 02 Feb 2005 18:59:14 +0000 IPC::DirQueue 0.04 released by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/><br/>Hi Jeffrey --<br/><br/>as the (so far) only known dq user, thought you might like to<br/>know about a few DQ bits and pieces. I&#39;ve cc&#39;d the all-new mailing<br/>list, for any other users out there ;)<br/><br/>First off, there&#39;s a new release -- changes:<br/><br/> - bug: dqserver should run forever when --njobs is 0, or unset; instead,<br/> it was exiting immediately. Patch from Jeffrey Wescott &lt;jeff .<br/> binaryfeed . org&gt;.<br/> - bug: tracked down a mysterious condition that resulted in unused files<br/> being left in the active dir.<br/> - added debugging (so far only enableable by setting a package global<br/> var)<br/> - updated documentation on the directory structure used<br/> - added note to POD about mailing list<br/><br/>Download from CPAN, once the mirrors update.<br/><br/>Next, the SVN repository lives here:<br/> http://svn.perl.org/modules/ipc-dirqueue/<br/><br/>and there&#39;s a mailing list -- mail ipc-dirqueue-subscribe .at. perl.org to<br/>subscribe.<br/><br/>(thanks to Ask and Robert @perl.org who are now providing free SVN<br/>repos and list hosting for CPAN modules!)<br/><br/>- --j.<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.2.5 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFB7bZAMJF5cimLx9ARAvKiAKCdnfTuBhqyjXcaalJ/arsRykMGeACgoyZu<br/>Cu+G9JasWZC6KzF9TrN9SVo=<br/>=pUoq<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2005/01/msg2.html Tue, 18 Jan 2005 17:22:32 +0000 Re: bug in IPC-DirQueue 0.03? by jm -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/><br/>Hi Jeffrey --<br/><br/>thanks for that patch -- it&#39;s applied to svn now. I should really<br/>do a new release RSN...<br/><br/>- --j.<br/><br/>Jeffrey Wescott writes:<br/>&gt; A patch for the bug described below ... I may send you another patch <br/>&gt; for a -q option (quiet).<br/>&gt; <br/>&gt; --------------------------------&gt;8 snip, snip<br/>&gt; Index: dq-server<br/>&gt; ==================================================================RCS file: /usr/local/cvsroot/IPC-DirQueue/dq-server,v<br/>&gt; retrieving revision 1.1.1.1<br/>&gt; diff -u -r1.1.1.1 dq-server<br/>&gt; --- dq-server 11 Jan 2005 21:55:01 -0000 1.1.1.1<br/>&gt; +++ dq-server 11 Jan 2005 23:56:21 -0000<br/>&gt; @@ -56,10 +56,11 @@<br/>&gt; ) or usage();<br/>&gt; $dir or usage();<br/>&gt; <br/>&gt; +my $jobsleft = $njobs;<br/>&gt; my $dq = IPC::DirQueue-&gt;new({ dir =&gt; $dir });<br/>&gt; <br/>&gt; while (1) {<br/>&gt; - last if ($njobs-- &lt;= 0);<br/>&gt; + $njobs &amp;&amp; last if ($jobsleft-- &lt;= 0);<br/>&gt; <br/>&gt; my $job = $dq-&gt;wait_for_queued_job();<br/>&gt; if (!$job) { next; }<br/>&gt; --------------------------------&gt;8 snip, snip<br/>&gt; <br/>&gt; ++jeffrey<br/>&gt; <br/>&gt; On Jan 11, 2005, at 15:48, Jeffrey Wescott wrote:<br/>&gt; <br/>&gt; &gt; The dq-server command claims in the documentation that not specifying <br/>&gt; &gt; --njobs or specifying --njobs 0 should mean that the server will run <br/>&gt; &gt; forever (i.e. -- process an unlimited number of jobs). However, if <br/>&gt; &gt; you don&#39;t specify --njobs or specify --njobs 0, it just quits.<br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.2.5 (GNU/Linux)<br/>Comment: Exmh CVS<br/><br/>iD8DBQFB5dxiMJF5cimLx9ARAskvAKCcDqmjF5fv4H7CccGoYk9zMUKK9QCeLDOt<br/>k3L2s9sElVjlOKyrO08l6Go=<br/>=gjXV<br/>-----END PGP SIGNATURE-----<br/><br/> http://www.nntp.perl.org/group/perl.ipc.dirqueue/2005/01/msg1.html Thu, 13 Jan 2005 02:55:59 +0000