David, I hope you do not mind if I cc: this back to linux-usb-devel.

Let me discuss the subject a little bit. By definition, write(2)
may return an error, I agree. However, it is customary for a driver
to perform a certain level of recovery. For instance, tapes and
disks retry writes a given number of times. On the other hand,
serial ports do not retry. It all depends on what an application
expects.

In our case, I think (and I may be mistaken), lpd filters abort
when writes to printer return errors. So, an out of paper or a jam
condition do not result in an error from write. Instead, a requestor
thread blocks until the problem is cleared. An operator may choose
to remove the print job, in that case a signal kills the writing
process.

Given that, it looks natural that the write() never gives up.
Thus, the problem is that the implementation loops in kernel
without sleeping and prevents any recovery.

-- Pete

> Date: Sun, 08 Apr 2001 07:31:25 -0700
> From: David Brownell <[EMAIL PROTECTED]>
> To: Peter Zaitcev <[EMAIL PROTECTED]>

> By definition, it's OK for write() to return an error!
> 
> ----- Original Message ----- 
> From: "Pete Zaitcev" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; 
><[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Saturday, April 07, 2001 9:11 PM
> Subject: [linux-usb-devel] Patch to drivers/usb/printer.c
> 
> > I got assigned a bug report:
> >  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=34551
> > Basically, when user's process loops it does not allow
> > khubd to run. I found that write() never returns an error,
> > and did not know if it was safe to change that behaviour.
> > So, here it is, the best band-aid I could do.
> > 
> > -- Pete
> > 
> > --- linux-2.4.3/drivers/usb/printer.c Fri Mar  2 17:50:22 2001
> > +++ linux-2.4.3-p3/drivers/usb/printer.c Sat Apr  7 21:04:14 2001
> > @@ -357,13 +357,17 @@
> >   if (usblp->writeurb.status != -EINPROGRESS)
> >   err("usblp%d: error %d writing to printer",
> >   usblp->minor, usblp->writeurb.status);
> > - err = usblp->writeurb.status;
> > - continue;
> >   }
> >   else {
> >   err = usblp_check_status(usblp, err);
> > - continue;
> >   }
> > + if (writecount)
> > + return writecount;
> > + schedule_timeout(50);
> > + set_current_state(TASK_RUNNING);
> > + if (signal_pending(current))
> > + return -EINTR;
> > + continue;
> >   }
> >  
> >   writecount += usblp->writeurb.transfer_buffer_length;

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to