Re: [Libusbx-devel] [libusbx] Task: Release 1.0.17 (#126)

2013-09-06 Thread Hans de Goede
1.0.17 has been tagged and uploaded, the release announcement will go out 
shortly, closing.

---
Reply to this email directly or view it on GitHub:
https://github.com/libusbx/libusbx/issues/126#issuecomment-23931026
--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] [libusbx] Task: Release 1.0.17 (#126)

2013-09-06 Thread Hans de Goede
Closed #126.

---
Reply to this email directly or view it on GitHub:
https://github.com/libusbx/libusbx/issues/126
--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


[Libusbx-devel] Announcing libusbx-1.0.17 final

2013-09-06 Thread Hans de Goede
Hi All,

I'm very happy to announce libusbx-1.0.17.

2013-09-06: v1.0.17
* Hotplug callbacks now always get passed a libusb_context, even if it is
   the default context. Previously NULL would be passed for the default context,
   but since the first context created is the default context, and most apps
   use only 1 context, this meant that apps explicitly creating a context would
   still get passed NULL
* Android: Add .mk files to build with the Android NDK
* Darwin: Add Xcode project
* Darwin: Fix crash on unplug (#121)
* Linux: Fix hang (deadlock) on libusb_exit
* Linux: Fix libusbx build failure with --disable-udev (#124)
* Linux: Fix libusb_get_device_list() hang with --disable-udev (#130)
* OpenBSD: Update OpenBSD backend with support for control transfers to
   non-ugen(4) devices and make get_configuration() no longer generate I/O.
   Note that using this libusbx version on OpenBSD requires using
   OpenBSD 5.3-current or later. Users of older OpenBSD versions are advised
   to stay with the libusb shipped with OpenBSD (mpi)
* Windows: fix libusb_dll_2010.vcxproj link errors (#129)
* Various other bug fixes and improvements
The (#xx) numbers are libusbx issue numbers, see ie:
https://github.com/libusbx/libusbx/issues/121

You can download the 1.0.17 sources tarbal here:
http://downloads.sourceforge.net/libusbx/libusbx-1.0.17.tar.bz2

Windows binaries should become available on sourceforge in a couple of
days.

Regards,

Hans

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] Reverting atexit call of libusb_exit from libusb-compat ?

2013-09-06 Thread Hans de Goede
Hi,

On 09/05/2013 03:14 AM, Xiaofan Chen wrote:
> On Thu, Sep 5, 2013 at 3:26 AM, Hans de Goede  wrote:
>> Hi,
>>
>> As discussed in much detail here:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1003193
>>
>> Calling libusb_exit from atexit from libusb-compat-0.1.5 causes
>> some apps to break.
>>
>> The app in question is the scanimage app from sane-backends, which
>> uses atexit for cleanup itself.
>>
>> So what happens is the libusb-compat atexit handler runs first, and
>> then the scanimage atexit cleanup code runs, and tries to cleanly
>> shutdown the scanner (which may require communicating to it).
>> ...
>> I consider this behavior with some old apps a way bigger problem then the
>> memory / resource leak we had before, therefor I suggest reverting the
>> atexit changes to libusb-compat.
>>
>
> I agree.
>
> On the other hand, maybe we then have to document this limitation
> of libusb-compat.

You mean simply document that atexit is used and apps must not make any calls
from atexit because there are no ordering guarantees? Or you mean revert
the patch and then document the resource leak ?

Also what do others think? Pete ? Nathan ?

> BTW, do we need to replicate the libusb.org libusb-compat tickets in
> libusbx github? Only Ticket 110 and 32 need to be copied as other
> tickets have been closed.
>   http://www.libusb.org/report/10
>
> If yes, then I will copy the two tickets and add "Compat" in the
> beginning of the description to distinguish them from libusbx tickets.

I think we should not count on libusb.org trac being available for ever,
so yes cloning open issues seems like a good idea.

About adding a "Compat: " header to the description, wouldn't it be
better to simply enable issue tracking on:
https://github.com/libusbx/libusb-compat-0.1

Here:
https://github.com/libusbx/libusb-compat-0.1/settings

Instead, and then file issues for it here:
https://github.com/libusbx/libusb-compat-0.1/issues

?

Regards,

Hans


>
>
>

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] Announcing libusbx-1.0.17 final

2013-09-06 Thread Pete Batard
On 2013.09.06 11:31, Hans de Goede wrote:
> I'm very happy to announce libusbx-1.0.17.

Good job!

The Windows binaries have now been uploaded as well, and the freecode 
announcement should follow today.

Regards,

/Pete

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] Announcing libusbx-1.0.17 final

2013-09-06 Thread Toby Gray
On 06/09/13 12:19, Pete Batard wrote:
> On 2013.09.06 11:31, Hans de Goede wrote:
>> I'm very happy to announce libusbx-1.0.17.
> Good job!
>
> The Windows binaries have now been uploaded as well, and the freecode
> announcement should follow today.
>

Windows CE binaries have now been uploaded too.

Regards,

Toby

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


[Libusbx-devel] [PATCH 3/3] Make usbi_get_device_by_session_id return a ref to the found device

2013-09-06 Thread Hans de Goede
Signed-off-by: Hans de Goede 
---
 libusb/core.c   |  2 +-
 libusb/libusbi.h|  4 ++--
 libusb/os/darwin_usb.c  |  6 +-
 libusb/os/linux_usbfs.c |  5 -
 libusb/os/netbsd_usb.c  |  4 +---
 libusb/os/openbsd_usb.c |  4 +---
 libusb/os/wince_usb.c   |  1 -
 libusb/os/windows_usb.c | 26 +++---
 libusb/version_nano.h   |  2 +-
 9 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/libusb/core.c b/libusb/core.c
index e816284..72faac4 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -620,7 +620,7 @@ struct libusb_device *usbi_get_device_by_session_id(struct 
libusb_context *ctx,
usbi_mutex_lock(&ctx->usb_devs_lock);
list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device)
if (dev->session_data == session_id) {
-   ret = dev;
+   ret = libusb_ref_device(dev);
break;
}
usbi_mutex_unlock(&ctx->usb_devs_lock);
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index bc608b9..a4d74f6 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -534,8 +534,8 @@ struct usbi_os_backend {
 *
 * After computing a session ID for a device, call
 * usbi_get_device_by_session_id(). This function checks if libusbx 
already
-* knows about the device, and if so, it provides you with a 
libusb_device
-* structure for it.
+* knows about the device, and if so, it provides you with a reference
+* to a libusb_device structure for it.
 *
 * If usbi_get_device_by_session_id() returns NULL, it is time to 
allocate
 * a new device structure for the device. Call usbi_alloc_device() to
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 889c62a..d0350fb 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -293,6 +293,7 @@ static void darwin_devices_detached (void *ptr, 
io_iterator_t rem_devices) {
 /* signal the core that this device has been disconnected. the core 
will tear down this device
when the reference count reaches 0 */
 usbi_disconnect_device(dev);
+usb_unref_device(dev);
   }
 }
 
@@ -864,11 +865,6 @@ static int process_new_device (struct libusb_context *ctx, 
io_service_t service)
 dev->bus_number = cached_device->location >> 24;
 dev->device_address = cached_device->address;
 
-/* need to add a reference to the parent device */
-if (dev->parent_dev) {
-  libusb_ref_device(dev->parent_dev);
-}
-
 (*(priv->dev->device))->GetDeviceSpeed (priv->dev->device, &devSpeed);
 
 switch (devSpeed) {
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 142fa2b..f8defb8 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1048,9 +1048,11 @@ int linux_enumerate_device(struct libusb_context *ctx,
usbi_dbg("busnum %d devaddr %d session_id %ld", busnum, devaddr,
session_id);
 
-   if (usbi_get_device_by_session_id(ctx, session_id)) {
+   dev = usbi_get_device_by_session_id(ctx, session_id);
+   if (dev) {
/* device already exists in the context */
usbi_dbg("session_id %ld already exists", session_id);
+   libusb_unref_device(dev);
return LIBUSB_SUCCESS;
}
 
@@ -1101,6 +1103,7 @@ void linux_device_disconnected(uint8_t busnum, uint8_t 
devaddr, const char *sys_
dev = usbi_get_device_by_session_id (ctx, session_id);
if (NULL != dev) {
usbi_disconnect_device (dev);
+   libusb_unref_device(dev);
} else {
usbi_dbg("device not found for session %x", session_id);
}
diff --git a/libusb/os/netbsd_usb.c b/libusb/os/netbsd_usb.c
index 1e8d602..1da9e1e 100644
--- a/libusb/os/netbsd_usb.c
+++ b/libusb/os/netbsd_usb.c
@@ -161,9 +161,7 @@ netbsd_get_device_list(struct libusb_context * ctx,
session_id = (di.udi_bus << 8 | di.udi_addr);
dev = usbi_get_device_by_session_id(ctx, session_id);
 
-   if (dev) {
-   dev = libusb_ref_device(dev);
-   } else {
+   if (dev == NULL) {
dev = usbi_alloc_device(ctx, session_id);
if (dev == NULL)
return (LIBUSB_ERROR_NO_MEM);
diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index e1be242..01934ef 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -186,9 +186,7 @@ obsd_get_device_list(struct libusb_context * ctx,
session_id = (di.udi_bus << 8 | di.udi_addr);
dev = usbi_get_device_by_session_id(ctx, session_id);
 
-   if (dev) {
-   dev = libusb_ref_device(dev);
-   } else {
+

[Libusbx-devel] [PATCH 1/3] openbsd: Fix usbi_sanitize_device error handling

2013-09-06 Thread Hans de Goede
If usbi_sanitize_device fails we need to continue from the beginning of
the loop, rather then going on with the device we've just free-ed.

Signed-off-by: Hans de Goede 
---
 libusb/os/openbsd_usb.c | 4 +++-
 libusb/version_nano.h   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index 2997e53..84c339e 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -215,8 +215,10 @@ obsd_get_device_list(struct libusb_context * ctx,
continue;
}
 
-   if (usbi_sanitize_device(dev))
+   if (usbi_sanitize_device(dev)) {
libusb_unref_device(dev);
+   continue;
+   }
}
 
ddd = discovered_devs_append(*discdevs, dev);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index dfa5664..1aa4bd5 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10830
+#define LIBUSB_NANO 10832
-- 
1.8.3.1


--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


[Libusbx-devel] [RFC 0/3] Make usbi_get_device_by_session_id return a ref to the found device

2013-09-06 Thread Hans de Goede
Hi All,

As discussed here is a patch making usbi_get_device_by_session_id return a ref
to the found device, which considering the usb_devs locking seems to be the
sane thing to do. For some backends this also leads to simpler code.

Most of the changes are pretty straight forward, only the windows backend
changes were a bit tricky, I'm pretty sure I got it right, but this part could
certainly use a review.

Regards,

Hans

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


[Libusbx-devel] [PATCH 2/3] openbsd: Fix a memleak

2013-09-06 Thread Hans de Goede
discovered_devs_append takes a reference to the past in dev, so we must
release our own reference.

Signed-off-by: Hans de Goede 
---
 libusb/os/openbsd_usb.c | 5 -
 libusb/version_nano.h   | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index 84c339e..e1be242 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -186,7 +186,9 @@ obsd_get_device_list(struct libusb_context * ctx,
session_id = (di.udi_bus << 8 | di.udi_addr);
dev = usbi_get_device_by_session_id(ctx, session_id);
 
-   if (dev == NULL) {
+   if (dev) {
+   dev = libusb_ref_device(dev);
+   } else {
dev = usbi_alloc_device(ctx, session_id);
if (dev == NULL) {
close(fd);
@@ -226,6 +228,7 @@ obsd_get_device_list(struct libusb_context * ctx,
close(fd);
return (LIBUSB_ERROR_NO_MEM);
}
+   libusb_unref_device(dev);
 
*discdevs = ddd;
devices[addr] = 1;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 1aa4bd5..d8a3c31 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10832
+#define LIBUSB_NANO 10833
-- 
1.8.3.1


--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel


Re: [Libusbx-devel] Reverting atexit call of libusb_exit from libusb-compat ?

2013-09-06 Thread Nathan Hjelm

On Sep 6, 2013, at 4:58 AM, Hans de Goede  wrote:

> Hi,
> 
> On 09/05/2013 03:14 AM, Xiaofan Chen wrote:
>> On Thu, Sep 5, 2013 at 3:26 AM, Hans de Goede  wrote:
>>> Hi,
>>> 
>>> As discussed in much detail here:
>>> https://bugzilla.redhat.com/show_bug.cgi?id=1003193
>>> 
>>> Calling libusb_exit from atexit from libusb-compat-0.1.5 causes
>>> some apps to break.
>>> 
>>> The app in question is the scanimage app from sane-backends, which
>>> uses atexit for cleanup itself.
>>> 
>>> So what happens is the libusb-compat atexit handler runs first, and
>>> then the scanimage atexit cleanup code runs, and tries to cleanly
>>> shutdown the scanner (which may require communicating to it).
>>> ...
>>> I consider this behavior with some old apps a way bigger problem then the
>>> memory / resource leak we had before, therefor I suggest reverting the
>>> atexit changes to libusb-compat.
>>> 
>> 
>> I agree.
>> 
>> On the other hand, maybe we then have to document this limitation
>> of libusb-compat.
> 
> You mean simply document that atexit is used and apps must not make any calls
> from atexit because there are no ordering guarantees? Or you mean revert
> the patch and then document the resource leak ?
> 
> Also what do others think? Pete ? Nathan ?

I don’t like re-introducing a leak but it looks unavoidable in this case. There 
may be similar issues with the atexit function used by the darwin backend. I 
will take a look and see what I can do there.

-Nathan
--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
___
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel