[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-11 Thread stef
Hello,

you can test easily the patch with the following program run with 
SANE_DEBUG_SANEI_USB=6 :

#include stdlib.h
#include string.h
#include check.h

/* sane includes for the sanei functions called */
#include ../include/sane/sane.h
#include ../include/sane/saneopts.h
#include ../include/sane/sanei.h
#include ../include/sane/sanei_usb.h

int main(int argc, char **argv)
{
while(1)
{
sanei_usb_init();
printf(=\n);
sleep(2);
}
}

gcc -ggdb usb_init_test.c -I../include -o 
usb_init_test -L../sanei -lsanei -lusb

Then plug/replug scanners to check that the device list remains 
consistent.

Regards,
Stef



[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-11 Thread m. allan noah
there is a prog that does just this in the sane experimental tree.
Stef- I'm gonna look at your patch this afternoon, and see if i can
add missing device removal to it as well. If it works, I'll commit it,
cause it looks like the right fix.

allan

On Thu, Dec 11, 2008 at 12:39 AM, stef stef.dev at free.fr wrote:
Hello,

you can test easily the patch with the following program run with
 SANE_DEBUG_SANEI_USB=6 :

 #include stdlib.h
 #include string.h
 #include check.h

 /* sane includes for the sanei functions called */
 #include ../include/sane/sane.h
 #include ../include/sane/saneopts.h
 #include ../include/sane/sanei.h
 #include ../include/sane/sanei_usb.h

 int main(int argc, char **argv)
 {
while(1)
{
sanei_usb_init();
printf(=\n);
sleep(2);
}
 }

 gcc -ggdb usb_init_test.c -I../include -o
 usb_init_test -L../sanei -lsanei -lusb

Then plug/replug scanners to check that the device list remains 
 consistent.

 Regards,
Stef

 --
 sane-devel mailing list: sane-devel at lists.alioth.debian.org
 http://lists.alioth.debian.org/mailman/listinfo/sane-devel
 Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-request at lists.alioth.debian.org




-- 
The truth is an offense, but not a sin



[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-11 Thread m. allan noah
Well, this patch prevents removed scanners from being removed from the
global list, so if you unplug and replug the scanner 100 times, you
run out of device indexes, and frontend will see 99 non-existent
scanners. However, if we add removal code, then there is the
possibility that we might drop a device that is busy cause it is
opened by another process. I suppose that is ok, and no different than
how things are now...

allan



[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-07 Thread stef
Hello,

here's a patch to improve sanei_usb_init() behavior. It works by using 
an 
internal function to store device instead of writing them directly in the 
devices array. This function first checks if the device doesn't exist yet 
using the equals() function, and then add it if it is new. The array of 
devices is initialized only once at start. This way, sanei_usb_init() can be 
called repeatedly without messing existing entries, even if new devices are 
plugged in.
This patch doesn't handle device unplugging, but we could easily detect 
them 
by flagging all devices at sanei_usb_init() start, then clear it each time we 
try to add the same device again. At the end, only unplugged devices would 
still be flagged.

Regards,
Stef
-- next part --
A non-text attachment was scrubbed...
Name: usb_init.patch
Type: text/x-diff
Size: 8241 bytes
Desc: not available
Url : 
http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20081207/4353c672/attachment-0001.patch
 


[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-07 Thread Julien BLACHE
stef stef.dev at free.fr wrote:

 140c140,141
  /* total number of devices that can be opened at the same time */
 ---
 /** 
  * total number of devices that can be opened at the same time */
 143c144,145
  /* per-device information, using the functions' parameters dn as index */
 ---

diff -u, please.

JB.

-- 
Julien BLACHE   http://www.jblache.org 
jb at jblache.org  GPG KeyID 0xF5D65169



[sane-devel] [patch][RFC] sanei_usb_init improvement

2008-12-07 Thread m. allan noah
enjoy.

allan

On Sun, Dec 7, 2008 at 5:04 AM, Julien BLACHE jb at jblache.org wrote:
 stef stef.dev at free.fr wrote:

 140c140,141
  /* total number of devices that can be opened at the same time */
 ---
 /**
  * total number of devices that can be opened at the same time */
 143c144,145
  /* per-device information, using the functions' parameters dn as index */
 ---

 diff -u, please.

 JB.

 --
 Julien BLACHE   http://www.jblache.org
 jb at jblache.org  GPG KeyID 0xF5D65169

 --
 sane-devel mailing list: sane-devel at lists.alioth.debian.org
 http://lists.alioth.debian.org/mailman/listinfo/sane-devel
 Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-request at lists.alioth.debian.org




-- 
The truth is an offense, but not a sin
-- next part --
A non-text attachment was scrubbed...
Name: usb_init_u.patch
Type: application/octet-stream
Size: 11758 bytes
Desc: not available
Url : 
http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20081207/0a8ffb61/attachment.obj