Bug 18361

Summary: [MFC] [PATCH] Fix for queue-ordering problem in lpr/lpd/lpq
Product: Base System Reporter: Garance A Drosehn <gad>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: gad
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Garance A Drosehn 2000-05-03 05:10:01 UTC
	If a single task rapidly sends many separate jobs to a printer
	queue, the jobs will not necessarily print in the order they
	were sent.  The problem is that if the jobs are sent fast enough,
	then several consecutive jobs will have the same last-modification
	time on their control files.  In this situation, lpd/lpq will print
	those jobs in a random order (depending on what other files are in
	the queue).  The order of a given set of jobs can even change as
	later jobs are added to the queue.

Fix: Fix the compar() routine in lpr/common_source/common.c to sort
	based on job-id (which is part of the control-file filename)
	when the last-modification time of two cf files is the same.
	Here is a patch which does this:
How-To-Repeat: 
	You usually need a lot of jobs in the queue to notice the problem,
	and you need to send them rapidly.  I used a shell loop:
		lpc stop lp
		for ii in 1 2 3 4 5 6 7 8 9 10  ; do
		   lpr /tmp/lpf1 ; lpr /tmp/lpf_2 ; lpr /tmp/lpf3_3
		   lpr /tmp/lpf44_4 ; lpr /tmp/lpf555_5 ; lpr /tmp/lp--
		done
	where /tmp/lpf1, /tmp/lpf_2, /tmp/lpf3_3, /tmp/lpf44_4,
	/tmp/lpf555_5, and /tmp/lp-- (with two trailing minus signs)
	are just very tiny dummy-files.  By chosing gradually-longer
	filenames, it's easier to see what's happening in lpq.  So,
	do the above, and then 'lpq' to see if the jobs are listed
	in the same order they were sent.
Comment 1 l.iania 2000-05-03 11:46:26 UTC
Yes I think it works fine now.

Do you think that the limit of 1000 requests is adeguate?

Best regards
Comment 2 Garrett Wollman freebsd_committer freebsd_triage 2000-05-03 15:56:44 UTC
State Changed
From-To: open->suspended

Patch applied (with style fixes) in rev. 1.13; awaiting MFC. 
Comment 3 nbm freebsd_committer freebsd_triage 2000-08-06 18:12:46 UTC
State Changed
From-To: suspended->closed

ps MFC'd this in rev 1.12.2.1