Problem in sanei_scsi.c

From: Simon Munton (simon@munton.demon.co.uk)
Date: Thu May 25 2000 - 11:14:19 PDT

  • Next message: William (Andy) Smith: "Re: Correct Network Scanner Syntax? (a question)"

    Hi,

    I've found a problem in the issue() function in sanei_scsi.c, that results
    in the queue in sg filling up, and prevents any more scsi commands being
    issued until the device is closed.

    There is a test on line 1690 which can erroneously try to reissue a scsi
    command:
        if (rp == fdp->sane_qhead && errno == EAGAIN)

    The first time through the enclosing while loop, rp == fdp->sane_qhead. But
    if the write() call issuing the command was successful, errno is left
    unchanged, and if errno happens to contain EAGAIN, then the command is
    issued again, and again... until the command queue in sg is full.

    One solution would be to set errno to 0 at the start of the while loop:

    $ diff -c sanei_scsi.c.orig sanei_scsi.c
    *** sanei_scsi.c.orig Sun Mar 05 13:45:20 2000
    --- sanei_scsi.c Thu May 18 19:18:44 2000
    ***************
    *** 1636,1641 ****
    --- 1636,1642 ----
            retries = 20;
            while (retries)
              {
    + errno = 0;
      #ifdef SG_IO
                if (sg_version < 30000)
                  {

    Regards

    Simon Munton

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Thu May 25 2000 - 11:11:15 PDT