Read response until <= 2 bytes.
diff --git a/ChangeLog b/ChangeLog
index c781f78..b4e47eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-27 Linus Walleij <triad@df.lth.se>
+
+ * src/libusb-glue.c: re-read response from device until
+ it atleast exceeds two bytes. This fixes a problem with
+ the Samsung YP-U3 when populated with many, many songs.
+
2008-01-21 Richard Low <richard@wentnet.com>
* src/music-players.h: add Thomson Lyrca HC308A, remove
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index f3da672..cd75036 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -3,7 +3,7 @@
* Low-level USB interface glue towards libusb.
*
* Copyright (C) 2005-2007 Richard A. Low <richard@wentnet.com>
- * Copyright (C) 2005-2007 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2008 Linus Walleij <triad@df.lth.se>
* Copyright (C) 2006-2007 Marcus Meissner
* Copyright (C) 2007 Ted Bullock
*
@@ -1112,6 +1112,13 @@
/* read response, it should never be longer than sizeof(usbresp) */
ret = ptp_usb_getpacket(params, &usbresp, &rlen);
+ while (ret==PTP_RC_OK && rlen<=2) {
+ ptp_debug (params, "ptp_usb_getresp: detected a response less or "
+ "equal to two bytes, expect problems! (re-reading "
+ "response)");
+ ret = ptp_usb_getpacket(params, &usbresp, &rlen);
+ }
+
if (ret!=PTP_RC_OK) {
ret = PTP_ERROR_IO;
} else
@@ -1134,7 +1141,8 @@
if (ptp_usb->device_flags & DEVICE_FLAG_IGNORE_HEADER_ERRORS) {
if (resp->Transaction_ID != params->transaction_id-1) {
ptp_debug (params, "ptp_usb_getresp: detected a broken "
- "PTP header, transaction ID insane, expect problems! (But continuing)");
+ "PTP header, transaction ID insane, expect "
+ "problems! (But continuing)");
// Repair the header, so it won't wreak more havoc.
resp->Transaction_ID = params->transaction_id-1;
}