* PATCHES: Device discovery of the "bluetooth" CUPS backend does not work
@ 2009-08-26 17:59 Till Kamppeter
2009-08-26 18:14 ` Marcel Holtmann
0 siblings, 1 reply; 10+ messages in thread
From: Till Kamppeter @ 2009-08-26 17:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mario Limonciello
[-- Attachment #1: Type: text/plain, Size: 1554 bytes --]
Hi,
I am using Bluez 4.48 in Ubuntu Karmic. First thank you for applying my
patches. The bluetooth backend works perfectly now with CUPS 1.3.x and
older. On the new CUPS 1.4.x a new problem appeared: The new CUPS does
device discovery only for a given time frame requested by the client
(printer setup tool, "lpinfo" command). CUPS's default for
CUPS-1.3.x-ish requests without timeout specification seems to be 10
seconds. CUPS startys all backends at once in the beginning (in
parallel) and kills every backend which remains running at the end of
the timeout. It accepts output from the backends whenever it occurs not
only when the backend finishes, so a backend can search for printers
infinitely long if it outputs every found device immediately. Then all
printers found during CUPS' timeout are taken into account.
The bluetooth backend o 4.48 asks the Bluetooth daemon for printers and
collects results for 10 seconds and after that it output them. This
takes a total of 10.5 sec and so CUPS kills the backend right before it
answers (at least with the 10-second default timeout), resulting in
Bluetooth printers never being discovered by CUPS.
I have fixed this now with the attached patch, by making each new
printer added to the list being output immediately. Note that the list
structure cannot be removed from cups/main.c as otherwise we would get
duplicate listings.
Can you please apply this patch to Bluez so that Bluez gets ready for
the new CUPS 1.4.x generation? Thanks.
Till
http://www.openprinting.org/
[-- Attachment #2: 10_bluetooth-cups-backend-report-printers-immediately.patch --]
[-- Type: text/x-patch, Size: 2704 bytes --]
diff -Nur -x '*.orig' -x '*~' bluez-4.48/cups/main.c bluez-4.48.new/cups/main.c
--- bluez-4.48/cups/main.c 2009-08-16 20:43:34.000000000 +0200
+++ bluez-4.48.new/cups/main.c 2009-08-26 19:05:31.000000000 +0200
@@ -185,6 +185,27 @@
return id;
}
+static void print_printer_details(const char *name, const char *bdaddr, const char *id)
+{
+ char *uri, *escaped;
+
+ escaped = g_strdelimit(g_strdup(name), "\"", '\'');
+ uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c",
+ bdaddr[0], bdaddr[1],
+ bdaddr[3], bdaddr[4],
+ bdaddr[6], bdaddr[7],
+ bdaddr[9], bdaddr[10],
+ bdaddr[12], bdaddr[13],
+ bdaddr[15], bdaddr[16]);
+ printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped);
+ if (id != NULL)
+ printf(" \"%s\"\n", id);
+ else
+ printf("\n");
+ g_free(escaped);
+ g_free(uri);
+}
+
static void add_device_to_list(const char *name, const char *bdaddr, const char *id)
{
struct cups_device *device;
@@ -212,27 +233,7 @@
device->id = g_strdup(id);
device_list = g_slist_prepend(device_list, device);
-}
-
-static void print_printer_details(const char *name, const char *bdaddr, const char *id)
-{
- char *uri, *escaped;
-
- escaped = g_strdelimit(g_strdup(name), "\"", '\'');
- uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c",
- bdaddr[0], bdaddr[1],
- bdaddr[3], bdaddr[4],
- bdaddr[6], bdaddr[7],
- bdaddr[9], bdaddr[10],
- bdaddr[12], bdaddr[13],
- bdaddr[15], bdaddr[16]);
- printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped);
- if (id != NULL)
- printf(" \"%s\"\n", id);
- else
- printf("\n");
- g_free(escaped);
- g_free(uri);
+ print_printer_details(device->name, device->bdaddr, device->id);
}
static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr)
@@ -384,23 +385,6 @@
static void discovery_completed(void)
{
- GSList *l;
-
- for (l = device_list; l != NULL; l = l->next) {
- struct cups_device *device = (struct cups_device *) l->data;
-
- if (device->name == NULL)
- device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-');
- /* Give another try to getting an ID for the device */
- if (device->id == NULL)
- remote_device_found(NULL, device->bdaddr, device->name);
- print_printer_details(device->name, device->bdaddr, device->id);
- g_free(device->name);
- g_free(device->bdaddr);
- g_free(device->id);
- g_free(device);
- }
-
g_slist_free(device_list);
device_list = NULL;
@@ -638,6 +622,9 @@
/* Make sure status messages are not buffered */
setbuf(stderr, NULL);
+ /* Make sure output is not buffered */
+ setbuf(stdout, NULL);
+
/* Ignore SIGPIPE signals */
#ifdef HAVE_SIGSET
sigset(SIGPIPE, SIG_IGN);
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: PATCHES: Device discovery of the "bluetooth" CUPS backend does not work 2009-08-26 17:59 PATCHES: Device discovery of the "bluetooth" CUPS backend does not work Till Kamppeter @ 2009-08-26 18:14 ` Marcel Holtmann 2009-08-26 19:12 ` Till Kamppeter 0 siblings, 1 reply; 10+ messages in thread From: Marcel Holtmann @ 2009-08-26 18:14 UTC (permalink / raw) To: Till Kamppeter; +Cc: linux-bluetooth, Mario Limonciello Hi Till, > I am using Bluez 4.48 in Ubuntu Karmic. First thank you for applying my > patches. The bluetooth backend works perfectly now with CUPS 1.3.x and > older. On the new CUPS 1.4.x a new problem appeared: The new CUPS does > device discovery only for a given time frame requested by the client > (printer setup tool, "lpinfo" command). CUPS's default for > CUPS-1.3.x-ish requests without timeout specification seems to be 10 > seconds. CUPS startys all backends at once in the beginning (in > parallel) and kills every backend which remains running at the end of > the timeout. It accepts output from the backends whenever it occurs not > only when the backend finishes, so a backend can search for printers > infinitely long if it outputs every found device immediately. Then all > printers found during CUPS' timeout are taken into account. > > The bluetooth backend o 4.48 asks the Bluetooth daemon for printers and > collects results for 10 seconds and after that it output them. This > takes a total of 10.5 sec and so CUPS kills the backend right before it > answers (at least with the 10-second default timeout), resulting in > Bluetooth printers never being discovered by CUPS. > > I have fixed this now with the attached patch, by making each new > printer added to the list being output immediately. Note that the list > structure cannot be removed from cups/main.c as otherwise we would get > duplicate listings. > > Can you please apply this patch to Bluez so that Bluez gets ready for > the new CUPS 1.4.x generation? Thanks. send a patch created with git format-patch so we can apply them properly without me having to modify the commit message manually. Regards Marcel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PATCHES: Device discovery of the "bluetooth" CUPS backend does not work 2009-08-26 18:14 ` Marcel Holtmann @ 2009-08-26 19:12 ` Till Kamppeter 2009-08-27 2:35 ` Marcel Holtmann 0 siblings, 1 reply; 10+ messages in thread From: Till Kamppeter @ 2009-08-26 19:12 UTC (permalink / raw) To: Marcel Holtmann; +Cc: linux-bluetooth, Mario Limonciello [-- Attachment #1: Type: text/plain, Size: 1866 bytes --] Thank you for the quick answer. Patch in GIT format attached. Till Marcel Holtmann wrote: > Hi Till, > >> I am using Bluez 4.48 in Ubuntu Karmic. First thank you for applying my >> patches. The bluetooth backend works perfectly now with CUPS 1.3.x and >> older. On the new CUPS 1.4.x a new problem appeared: The new CUPS does >> device discovery only for a given time frame requested by the client >> (printer setup tool, "lpinfo" command). CUPS's default for >> CUPS-1.3.x-ish requests without timeout specification seems to be 10 >> seconds. CUPS startys all backends at once in the beginning (in >> parallel) and kills every backend which remains running at the end of >> the timeout. It accepts output from the backends whenever it occurs not >> only when the backend finishes, so a backend can search for printers >> infinitely long if it outputs every found device immediately. Then all >> printers found during CUPS' timeout are taken into account. >> >> The bluetooth backend o 4.48 asks the Bluetooth daemon for printers and >> collects results for 10 seconds and after that it output them. This >> takes a total of 10.5 sec and so CUPS kills the backend right before it >> answers (at least with the 10-second default timeout), resulting in >> Bluetooth printers never being discovered by CUPS. >> >> I have fixed this now with the attached patch, by making each new >> printer added to the list being output immediately. Note that the list >> structure cannot be removed from cups/main.c as otherwise we would get >> duplicate listings. >> >> Can you please apply this patch to Bluez so that Bluez gets ready for >> the new CUPS 1.4.x generation? Thanks. > > send a patch created with git format-patch so we can apply them properly > without me having to modify the commit message manually. > > Regards > > Marcel > > > [-- Attachment #2: 0001-Make-discovery-mode-of-bluetooth-CUPS-backend-work-w.patch --] [-- Type: text/x-patch, Size: 3603 bytes --] >From e9f4b0053ca32a17dfff7d19adb521952c45cf61 Mon Sep 17 00:00:00 2001 From: Till Kamppeter <till.kamppeter@gmail.com> Date: Wed, 26 Aug 2009 21:05:43 +0200 Subject: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0. --- ChangeLog | 2 + cups/main.c | 63 +++++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d06f494..6c170f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +ver 4.51: + Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0. ver 4.50: Fix issue with missing manual pages in distribution. Fix issue with the configuration and state directories. diff --git a/cups/main.c b/cups/main.c index da757b0..1bbc78c 100644 --- a/cups/main.c +++ b/cups/main.c @@ -185,6 +185,27 @@ static char *device_get_ieee1284_id(const char *adapter, const char *device) return id; } +static void print_printer_details(const char *name, const char *bdaddr, const char *id) +{ + char *uri, *escaped; + + escaped = g_strdelimit(g_strdup(name), "\"", '\''); + uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", + bdaddr[0], bdaddr[1], + bdaddr[3], bdaddr[4], + bdaddr[6], bdaddr[7], + bdaddr[9], bdaddr[10], + bdaddr[12], bdaddr[13], + bdaddr[15], bdaddr[16]); + printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); + if (id != NULL) + printf(" \"%s\"\n", id); + else + printf("\n"); + g_free(escaped); + g_free(uri); +} + static void add_device_to_list(const char *name, const char *bdaddr, const char *id) { struct cups_device *device; @@ -212,27 +233,7 @@ static void add_device_to_list(const char *name, const char *bdaddr, const char device->id = g_strdup(id); device_list = g_slist_prepend(device_list, device); -} - -static void print_printer_details(const char *name, const char *bdaddr, const char *id) -{ - char *uri, *escaped; - - escaped = g_strdelimit(g_strdup(name), "\"", '\''); - uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", - bdaddr[0], bdaddr[1], - bdaddr[3], bdaddr[4], - bdaddr[6], bdaddr[7], - bdaddr[9], bdaddr[10], - bdaddr[12], bdaddr[13], - bdaddr[15], bdaddr[16]); - printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); - if (id != NULL) - printf(" \"%s\"\n", id); - else - printf("\n"); - g_free(escaped); - g_free(uri); + print_printer_details(device->name, device->bdaddr, device->id); } static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr) @@ -384,23 +385,6 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c static void discovery_completed(void) { - GSList *l; - - for (l = device_list; l != NULL; l = l->next) { - struct cups_device *device = (struct cups_device *) l->data; - - if (device->name == NULL) - device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-'); - /* Give another try to getting an ID for the device */ - if (device->id == NULL) - remote_device_found(NULL, device->bdaddr, device->name); - print_printer_details(device->name, device->bdaddr, device->id); - g_free(device->name); - g_free(device->bdaddr); - g_free(device->id); - g_free(device); - } - g_slist_free(device_list); device_list = NULL; @@ -638,6 +622,9 @@ int main(int argc, char *argv[]) /* Make sure status messages are not buffered */ setbuf(stderr, NULL); + /* Make sure output is not buffered */ + setbuf(stdout, NULL); + /* Ignore SIGPIPE signals */ #ifdef HAVE_SIGSET sigset(SIGPIPE, SIG_IGN); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: PATCHES: Device discovery of the "bluetooth" CUPS backend does not work 2009-08-26 19:12 ` Till Kamppeter @ 2009-08-27 2:35 ` Marcel Holtmann 2009-08-27 9:33 ` [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 Till Kamppeter 0 siblings, 1 reply; 10+ messages in thread From: Marcel Holtmann @ 2009-08-27 2:35 UTC (permalink / raw) To: Till Kamppeter; +Cc: linux-bluetooth, Mario Limonciello Hi Till, please stop top posting. This is a proper open source mailing list and we do proper inline quoting. > Thank you for the quick answer. > > Patch in GIT format attached. So you have time to write a lengthy email with an explanation what is going on, but the commit message is empty. Please fix the commit message since that is where it should be. Especially since you wrote it already anyway. Regards Marcel ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-27 2:35 ` Marcel Holtmann @ 2009-08-27 9:33 ` Till Kamppeter 2009-08-27 19:21 ` Marcel Holtmann 2009-09-01 16:13 ` Bastien Nocera 0 siblings, 2 replies; 10+ messages in thread From: Till Kamppeter @ 2009-08-27 9:33 UTC (permalink / raw) To: linux-bluetooth; +Cc: Marcel Holtmann, Mario Limonciello The new CUPS 1.4.x does device discovery only for a given time frame requested by the client (printer setup tool, "lpinfo" command). CUPS's default for CUPS-1.3.x-ish requests without timeout specification seems to be 10 seconds. CUPS starts all backends at once in the beginning (in parallel) and kills every backend which remains running at the end of the timeout. It accepts output from the backends whenever it occurs not only when the backend finishes, so a backend can search for printers infinitely long if it outputs every found device immediately. Then all printers found during CUPS' timeout are taken into account. The bluetooth backend of 4.48 asks the Bluetooth daemon for printers and collects results for 10 seconds and after that it outputs them. This takes a total of 10.5 sec and so CUPS kills the backend right before it answers (at least with the 10-second default timeout), resulting in Bluetooth printers never being discovered by CUPS. This change fixes it by making each new printer added to the list being output immediately. Note that the list structure cannot be removed from cups/main.c as otherwise we would get duplicate listings. Also important is the addition of unbuffered output on stdout. --- ChangeLog | 2 + cups/main.c | 63 +++++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d06f494..6c170f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +ver 4.51: + Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0. ver 4.50: Fix issue with missing manual pages in distribution. Fix issue with the configuration and state directories. diff --git a/cups/main.c b/cups/main.c index da757b0..1bbc78c 100644 --- a/cups/main.c +++ b/cups/main.c @@ -185,6 +185,27 @@ static char *device_get_ieee1284_id(const char *adapter, const char *device) return id; } +static void print_printer_details(const char *name, const char *bdaddr, const char *id) +{ + char *uri, *escaped; + + escaped = g_strdelimit(g_strdup(name), "\"", '\''); + uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", + bdaddr[0], bdaddr[1], + bdaddr[3], bdaddr[4], + bdaddr[6], bdaddr[7], + bdaddr[9], bdaddr[10], + bdaddr[12], bdaddr[13], + bdaddr[15], bdaddr[16]); + printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); + if (id != NULL) + printf(" \"%s\"\n", id); + else + printf("\n"); + g_free(escaped); + g_free(uri); +} + static void add_device_to_list(const char *name, const char *bdaddr, const char *id) { struct cups_device *device; @@ -212,27 +233,7 @@ static void add_device_to_list(const char *name, const char *bdaddr, const char device->id = g_strdup(id); device_list = g_slist_prepend(device_list, device); -} - -static void print_printer_details(const char *name, const char *bdaddr, const char *id) -{ - char *uri, *escaped; - - escaped = g_strdelimit(g_strdup(name), "\"", '\''); - uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", - bdaddr[0], bdaddr[1], - bdaddr[3], bdaddr[4], - bdaddr[6], bdaddr[7], - bdaddr[9], bdaddr[10], - bdaddr[12], bdaddr[13], - bdaddr[15], bdaddr[16]); - printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); - if (id != NULL) - printf(" \"%s\"\n", id); - else - printf("\n"); - g_free(escaped); - g_free(uri); + print_printer_details(device->name, device->bdaddr, device->id); } static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr) @@ -384,23 +385,6 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c static void discovery_completed(void) { - GSList *l; - - for (l = device_list; l != NULL; l = l->next) { - struct cups_device *device = (struct cups_device *) l->data; - - if (device->name == NULL) - device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-'); - /* Give another try to getting an ID for the device */ - if (device->id == NULL) - remote_device_found(NULL, device->bdaddr, device->name); - print_printer_details(device->name, device->bdaddr, device->id); - g_free(device->name); - g_free(device->bdaddr); - g_free(device->id); - g_free(device); - } - g_slist_free(device_list); device_list = NULL; @@ -638,6 +622,9 @@ int main(int argc, char *argv[]) /* Make sure status messages are not buffered */ setbuf(stderr, NULL); + /* Make sure output is not buffered */ + setbuf(stdout, NULL); + /* Ignore SIGPIPE signals */ #ifdef HAVE_SIGSET sigset(SIGPIPE, SIG_IGN); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-27 9:33 ` [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 Till Kamppeter @ 2009-08-27 19:21 ` Marcel Holtmann 2009-08-28 2:39 ` Mario Limonciello 2009-08-28 2:40 ` Mario Limonciello 2009-09-01 16:13 ` Bastien Nocera 1 sibling, 2 replies; 10+ messages in thread From: Marcel Holtmann @ 2009-08-27 19:21 UTC (permalink / raw) To: Till Kamppeter; +Cc: linux-bluetooth, Mario Limonciello Hi Till, > The new CUPS 1.4.x does device discovery only for a given time frame > requested by the client (printer setup tool, "lpinfo" command). CUPS's > default for CUPS-1.3.x-ish requests without timeout specification > seems to be 10 seconds. CUPS starts all backends at once in the > beginning (in parallel) and kills every backend which remains running > at the end of the timeout. It accepts output from the backends > whenever it occurs not only when the backend finishes, so a backend > can search for printers infinitely long if it outputs every found > device immediately. Then all printers found during CUPS' timeout are > taken into account. > > The bluetooth backend of 4.48 asks the Bluetooth daemon for printers > and collects results for 10 seconds and after that it outputs > them. This takes a total of 10.5 sec and so CUPS kills the backend > right before it answers (at least with the 10-second default timeout), > resulting in Bluetooth printers never being discovered by CUPS. > > This change fixes it by making each new printer added to the list > being output immediately. Note that the list structure cannot be > removed from cups/main.c as otherwise we would get duplicate > listings. Also important is the addition of unbuffered output on > stdout. > --- > ChangeLog | 2 + > cups/main.c | 63 > +++++++++++++++++++++++----------------------------------- > 2 files changed, 27 insertions(+), 38 deletions(-) I can't use git am to apply this patch. Someone has to fix this for me. Regards Marcel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-27 19:21 ` Marcel Holtmann @ 2009-08-28 2:39 ` Mario Limonciello 2009-08-29 4:26 ` Marcel Holtmann 2009-08-28 2:40 ` Mario Limonciello 1 sibling, 1 reply; 10+ messages in thread From: Mario Limonciello @ 2009-08-28 2:39 UTC (permalink / raw) To: Marcel Holtmann; +Cc: Till Kamppeter, linux-bluetooth [-- Attachment #1.1: Type: text/plain, Size: 412 bytes --] Hi Marcel: On Thu, Aug 27, 2009 at 14:21, Marcel Holtmann <marcel@holtmann.org> wrote: > > I can't use git am to apply this patch. Someone has to fix this for me. > > Regards > > Marcel > It looks like Till's email client is just beating it up. Applies for me with "git am" and the attached patch fine, but the inline is corrupt. -- Mario Limonciello superm1@gmail.com Sent from Austin, TX, United States [-- Attachment #1.2: Type: text/html, Size: 815 bytes --] [-- Attachment #2: 0001-Make-discovery-mode-of-bluetooth-CUPS-backend-work-w.patch --] [-- Type: text/x-patch, Size: 4827 bytes --] From fdf7b75f5fc8a9726db6756bcddff6aa74b42ba0 Mon Sep 17 00:00:00 2001 From: Till Kamppeter <till.kamppeter@gmail.com> Date: Thu, 27 Aug 2009 09:07:49 +0200 Subject: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 The new CUPS 1.4.x does device discovery only for a given time frame requested by the client (printer setup tool, "lpinfo" command). CUPS's default for CUPS-1.3.x-ish requests without timeout specification seems to be 10 seconds. CUPS starts all backends at once in the beginning (in parallel) and kills every backend which remains running at the end of the timeout. It accepts output from the backends whenever it occurs not only when the backend finishes, so a backend can search for printers infinitely long if it outputs every found device immediately. Then all printers found during CUPS' timeout are taken into account. The bluetooth backend of 4.48 asks the Bluetooth daemon for printers and collects results for 10 seconds and after that it outputs them. This takes a total of 10.5 sec and so CUPS kills the backend right before it answers (at least with the 10-second default timeout), resulting in Bluetooth printers never being discovered by CUPS. This change fixes it by making each new printer added to the list being output immediately. Note that the list structure cannot be removed from cups/main.c as otherwise we would get duplicate listings. Also important is the addition of unbuffered output on stdout. --- ChangeLog | 2 + cups/main.c | 63 +++++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d06f494..6c170f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +ver 4.51: + Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0. ver 4.50: Fix issue with missing manual pages in distribution. Fix issue with the configuration and state directories. diff --git a/cups/main.c b/cups/main.c index da757b0..1bbc78c 100644 --- a/cups/main.c +++ b/cups/main.c @@ -185,6 +185,27 @@ static char *device_get_ieee1284_id(const char *adapter, const char *device) return id; } +static void print_printer_details(const char *name, const char *bdaddr, const char *id) +{ + char *uri, *escaped; + + escaped = g_strdelimit(g_strdup(name), "\"", '\''); + uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", + bdaddr[0], bdaddr[1], + bdaddr[3], bdaddr[4], + bdaddr[6], bdaddr[7], + bdaddr[9], bdaddr[10], + bdaddr[12], bdaddr[13], + bdaddr[15], bdaddr[16]); + printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); + if (id != NULL) + printf(" \"%s\"\n", id); + else + printf("\n"); + g_free(escaped); + g_free(uri); +} + static void add_device_to_list(const char *name, const char *bdaddr, const char *id) { struct cups_device *device; @@ -212,27 +233,7 @@ static void add_device_to_list(const char *name, const char *bdaddr, const char device->id = g_strdup(id); device_list = g_slist_prepend(device_list, device); -} - -static void print_printer_details(const char *name, const char *bdaddr, const char *id) -{ - char *uri, *escaped; - - escaped = g_strdelimit(g_strdup(name), "\"", '\''); - uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", - bdaddr[0], bdaddr[1], - bdaddr[3], bdaddr[4], - bdaddr[6], bdaddr[7], - bdaddr[9], bdaddr[10], - bdaddr[12], bdaddr[13], - bdaddr[15], bdaddr[16]); - printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); - if (id != NULL) - printf(" \"%s\"\n", id); - else - printf("\n"); - g_free(escaped); - g_free(uri); + print_printer_details(device->name, device->bdaddr, device->id); } static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr) @@ -384,23 +385,6 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c static void discovery_completed(void) { - GSList *l; - - for (l = device_list; l != NULL; l = l->next) { - struct cups_device *device = (struct cups_device *) l->data; - - if (device->name == NULL) - device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-'); - /* Give another try to getting an ID for the device */ - if (device->id == NULL) - remote_device_found(NULL, device->bdaddr, device->name); - print_printer_details(device->name, device->bdaddr, device->id); - g_free(device->name); - g_free(device->bdaddr); - g_free(device->id); - g_free(device); - } - g_slist_free(device_list); device_list = NULL; @@ -638,6 +622,9 @@ int main(int argc, char *argv[]) /* Make sure status messages are not buffered */ setbuf(stderr, NULL); + /* Make sure output is not buffered */ + setbuf(stdout, NULL); + /* Ignore SIGPIPE signals */ #ifdef HAVE_SIGSET sigset(SIGPIPE, SIG_IGN); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-28 2:39 ` Mario Limonciello @ 2009-08-29 4:26 ` Marcel Holtmann 0 siblings, 0 replies; 10+ messages in thread From: Marcel Holtmann @ 2009-08-29 4:26 UTC (permalink / raw) To: Mario Limonciello; +Cc: Till Kamppeter, linux-bluetooth Hi Mario, > > I can't use git am to apply this patch. Someone has to fix > this for me. > > It looks like Till's email client is just beating it up. Applies for > me with "git am" and the attached patch fine, but the inline is > corrupt. can I get this one without touching ChangeLog. That file will only be touched be me before making the release. You guys make it pretty hard for me to apply patches. It is not that complicated. Regards Marcel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-27 19:21 ` Marcel Holtmann 2009-08-28 2:39 ` Mario Limonciello @ 2009-08-28 2:40 ` Mario Limonciello 1 sibling, 0 replies; 10+ messages in thread From: Mario Limonciello @ 2009-08-28 2:40 UTC (permalink / raw) Cc: linux-bluetooth [-- Attachment #1: Type: text/plain, Size: 411 bytes --] Hi Marcel: On Thu, Aug 27, 2009 at 14:21, Marcel Holtmann <marcel@holtmann.org> wrote: > > I can't use git am to apply this patch. Someone has to fix this for me. > > Regards > > Marcel > > It looks like Till's email client is just beating it up. Applies for me with "git am" and the attached patch fine, but the inline is corrupt. -- Mario Limonciello superm1@gmail.com Sent from Austin, TX, United States [-- Attachment #2: 0001-Make-discovery-mode-of-bluetooth-CUPS-backend-work-w.patch --] [-- Type: text/x-patch, Size: 4827 bytes --] From fdf7b75f5fc8a9726db6756bcddff6aa74b42ba0 Mon Sep 17 00:00:00 2001 From: Till Kamppeter <till.kamppeter@gmail.com> Date: Thu, 27 Aug 2009 09:07:49 +0200 Subject: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 The new CUPS 1.4.x does device discovery only for a given time frame requested by the client (printer setup tool, "lpinfo" command). CUPS's default for CUPS-1.3.x-ish requests without timeout specification seems to be 10 seconds. CUPS starts all backends at once in the beginning (in parallel) and kills every backend which remains running at the end of the timeout. It accepts output from the backends whenever it occurs not only when the backend finishes, so a backend can search for printers infinitely long if it outputs every found device immediately. Then all printers found during CUPS' timeout are taken into account. The bluetooth backend of 4.48 asks the Bluetooth daemon for printers and collects results for 10 seconds and after that it outputs them. This takes a total of 10.5 sec and so CUPS kills the backend right before it answers (at least with the 10-second default timeout), resulting in Bluetooth printers never being discovered by CUPS. This change fixes it by making each new printer added to the list being output immediately. Note that the list structure cannot be removed from cups/main.c as otherwise we would get duplicate listings. Also important is the addition of unbuffered output on stdout. --- ChangeLog | 2 + cups/main.c | 63 +++++++++++++++++++++++----------------------------------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index d06f494..6c170f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +ver 4.51: + Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0. ver 4.50: Fix issue with missing manual pages in distribution. Fix issue with the configuration and state directories. diff --git a/cups/main.c b/cups/main.c index da757b0..1bbc78c 100644 --- a/cups/main.c +++ b/cups/main.c @@ -185,6 +185,27 @@ static char *device_get_ieee1284_id(const char *adapter, const char *device) return id; } +static void print_printer_details(const char *name, const char *bdaddr, const char *id) +{ + char *uri, *escaped; + + escaped = g_strdelimit(g_strdup(name), "\"", '\''); + uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", + bdaddr[0], bdaddr[1], + bdaddr[3], bdaddr[4], + bdaddr[6], bdaddr[7], + bdaddr[9], bdaddr[10], + bdaddr[12], bdaddr[13], + bdaddr[15], bdaddr[16]); + printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); + if (id != NULL) + printf(" \"%s\"\n", id); + else + printf("\n"); + g_free(escaped); + g_free(uri); +} + static void add_device_to_list(const char *name, const char *bdaddr, const char *id) { struct cups_device *device; @@ -212,27 +233,7 @@ static void add_device_to_list(const char *name, const char *bdaddr, const char device->id = g_strdup(id); device_list = g_slist_prepend(device_list, device); -} - -static void print_printer_details(const char *name, const char *bdaddr, const char *id) -{ - char *uri, *escaped; - - escaped = g_strdelimit(g_strdup(name), "\"", '\''); - uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", - bdaddr[0], bdaddr[1], - bdaddr[3], bdaddr[4], - bdaddr[6], bdaddr[7], - bdaddr[9], bdaddr[10], - bdaddr[12], bdaddr[13], - bdaddr[15], bdaddr[16]); - printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); - if (id != NULL) - printf(" \"%s\"\n", id); - else - printf("\n"); - g_free(escaped); - g_free(uri); + print_printer_details(device->name, device->bdaddr, device->id); } static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr) @@ -384,23 +385,6 @@ static void remote_device_found(const char *adapter, const char *bdaddr, const c static void discovery_completed(void) { - GSList *l; - - for (l = device_list; l != NULL; l = l->next) { - struct cups_device *device = (struct cups_device *) l->data; - - if (device->name == NULL) - device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-'); - /* Give another try to getting an ID for the device */ - if (device->id == NULL) - remote_device_found(NULL, device->bdaddr, device->name); - print_printer_details(device->name, device->bdaddr, device->id); - g_free(device->name); - g_free(device->bdaddr); - g_free(device->id); - g_free(device); - } - g_slist_free(device_list); device_list = NULL; @@ -638,6 +622,9 @@ int main(int argc, char *argv[]) /* Make sure status messages are not buffered */ setbuf(stderr, NULL); + /* Make sure output is not buffered */ + setbuf(stdout, NULL); + /* Ignore SIGPIPE signals */ #ifdef HAVE_SIGSET sigset(SIGPIPE, SIG_IGN); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 2009-08-27 9:33 ` [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 Till Kamppeter 2009-08-27 19:21 ` Marcel Holtmann @ 2009-09-01 16:13 ` Bastien Nocera 1 sibling, 0 replies; 10+ messages in thread From: Bastien Nocera @ 2009-09-01 16:13 UTC (permalink / raw) To: Till Kamppeter; +Cc: linux-bluetooth, Marcel Holtmann, Mario Limonciello On Thu, 2009-08-27 at 11:33 +0200, Till Kamppeter wrote: > The new CUPS 1.4.x does device discovery only for a given time frame > requested by the client (printer setup tool, "lpinfo" command). CUPS's > default for CUPS-1.3.x-ish requests without timeout specification > seems to be 10 seconds. CUPS starts all backends at once in the > beginning (in parallel) and kills every backend which remains running > at the end of the timeout. It accepts output from the backends > whenever it occurs not only when the backend finishes, so a backend > can search for printers infinitely long if it outputs every found > device immediately. Then all printers found during CUPS' timeout are > taken into account. > > The bluetooth backend of 4.48 asks the Bluetooth daemon for printers > and collects results for 10 seconds and after that it outputs > them. This takes a total of 10.5 sec and so CUPS kills the backend > right before it answers (at least with the 10-second default timeout), > resulting in Bluetooth printers never being discovered by CUPS. > > This change fixes it by making each new printer added to the list > being output immediately. Note that the list structure cannot be > removed from cups/main.c as otherwise we would get duplicate > listings. Also important is the addition of unbuffered output on > stdout. Looks fine to me, although I'd have the stdout unbuffered change in a separate patch instead. Cheers ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-09-01 16:13 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-26 17:59 PATCHES: Device discovery of the "bluetooth" CUPS backend does not work Till Kamppeter 2009-08-26 18:14 ` Marcel Holtmann 2009-08-26 19:12 ` Till Kamppeter 2009-08-27 2:35 ` Marcel Holtmann 2009-08-27 9:33 ` [PATCH] Make discovery mode of bluetooth CUPS backend work with CUPS 1.4.0 Till Kamppeter 2009-08-27 19:21 ` Marcel Holtmann 2009-08-28 2:39 ` Mario Limonciello 2009-08-29 4:26 ` Marcel Holtmann 2009-08-28 2:40 ` Mario Limonciello 2009-09-01 16:13 ` Bastien Nocera
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox