summaryrefslogtreecommitdiff
path: root/libusb/hotplug.c
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@google.com>2021-07-20 09:31:06 -0600
committerNathan Hjelm <hjelmn@cs.unm.edu>2021-07-21 10:03:59 -0600
commit6cae9c6dbd74c0840848f343dd605c5ddcef1ad1 (patch)
tree05ab9c50bbafcf66d00f866f99a31126aa2866a3 /libusb/hotplug.c
parentb0fd4d873e224bbb1985971834d31d956080c7a4 (diff)
downloadlibusb-6cae9c6dbd74c0840848f343dd605c5ddcef1ad1.tar.gz
core: update usbi_dbg to take the context as an argument
This commit fixes a performance issue caused by the disconnection of the first context allocated from the default context. usbi_dbg now takes the explicit context instead of relying on the default context (which may not exist) in most cases. All call sites have been updated to pass the context or explicitly pass NULL if the context is not available. We should actively discourage using NULL as the context in the future and patch all call sites to always pass the context. Fixes #951 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Diffstat (limited to 'libusb/hotplug.c')
-rw-r--r--libusb/hotplug.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index 52ce626..4bb2d4e 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
/*
* Hotplug functions for libusb
- * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
+ * Copyright © 2012-2021 Nathan Hjelm <hjelmn@mac.com>
* Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
*
* This library is free software; you can redistribute it and/or
@@ -307,7 +307,7 @@ void usbi_hotplug_process(struct libusb_context *ctx, struct list_head *hotplug_
/* free any callbacks that have unregistered */
for_each_hotplug_cb_safe(ctx, hotplug_cb, next_cb) {
if (hotplug_cb->flags & USBI_HOTPLUG_NEEDS_FREE) {
- usbi_dbg("freeing hotplug cb %p with handle %d",
+ usbi_dbg(ctx, "freeing hotplug cb %p with handle %d",
hotplug_cb, hotplug_cb->handle);
list_del(&hotplug_cb->list);
free(hotplug_cb);
@@ -374,7 +374,7 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
- usbi_dbg("new hotplug cb %p with handle %d", hotplug_cb, hotplug_cb->handle);
+ usbi_dbg(ctx, "new hotplug cb %p with handle %d", hotplug_cb, hotplug_cb->handle);
if ((flags & LIBUSB_HOTPLUG_ENUMERATE) && (events & LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED)) {
ssize_t i, len;
@@ -411,7 +411,7 @@ void API_EXPORTED libusb_hotplug_deregister_callback(libusb_context *ctx,
if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG))
return;
- usbi_dbg("deregister hotplug cb %d", callback_handle);
+ usbi_dbg(ctx, "deregister hotplug cb %d", callback_handle);
ctx = usbi_get_context(ctx);
@@ -449,7 +449,7 @@ void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx,
if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG))
return NULL;
- usbi_dbg("get hotplug cb %d user data", callback_handle);
+ usbi_dbg(ctx, "get hotplug cb %d user data", callback_handle);
ctx = usbi_get_context(ctx);