/*
* "$Id$"
*
- * Copyright 2005-2014 Apple Inc. All rights reserved.
+ * Copyright 2005-2015 Apple Inc. All rights reserved.
*
* IMPORTANT: This Apple software is supplied to you by Apple Computer,
* Inc. ("Apple") in consideration of your agreement to the following
ssize_t debug_bytes; /* Current bytes to read */
#endif /* DEBUG_WRITES */
+ Boolean use_generic_class_driver;
Boolean wait_eof;
int drain_output; /* Drain all pending output */
int bidi_flag; /* 0=unidirectional, 1=bidirectional */
} while (g.wait_eof || !g.read_thread_stop); /* Abort from main thread tests error here */
+ /* Workaround for usb race condition. <rdar://problem/21882551> */
+ if (!g.wait_eof && g.use_generic_class_driver)
+ {
+ const char *pdl = getenv("FINAL_CONTENT_TYPE");
+ if (pdl && strcmp(pdl, "application/vnd.cups-postscript") == 0)
+ {
+ while (readstatus == kIOReturnSuccess && ((rbytes > 0 && readbuffer[rbytes-1] != 0x4) || rbytes == 0))
+ {
+ start = mach_absolute_time();
+
+ rbytes = sizeof(readbuffer);
+ readstatus = (*g.classdriver)->ReadPipe(g.classdriver, readbuffer, &rbytes);
+ if (readstatus == kIOReturnSuccess && rbytes > 0 && readbuffer[rbytes-1] == 0x4)
+ break;
+
+ /* Make sure this loop executes no more than once every 250 miliseconds... */
+ mach_wait_until(start + delay);
+ }
+ }
+ }
+
/*
* Let the main thread know that we have completed the read thread...
*/
cupsBackendReport("direct", uristr, make_modelstr, make_modelstr, idstr,
NULL);
-
+
if (make != NULL) CFRelease(make);
if (model != NULL) CFRelease(model);
if (serial != NULL) CFRelease(serial);
{
*driverBundlePath = IORegistryEntryCreateCFProperty(g.printer_obj, kUSBClassDriverProperty, NULL, kNilOptions);
+ g.use_generic_class_driver = (*driverBundlePath == NULL || (CFStringCompare(*driverBundlePath, kUSBGenericTOPrinterClassDriver, 0x0) == kCFCompareEqualTo));
kr = load_classdriver(*driverBundlePath, interface, &g.classdriver);
if (kr != kIOReturnSuccess)
if (manufacturer != NULL)
CFRelease(manufacturer);
-
+
if (model != NULL)
CFRelease(model);
-
+
if (serial != NULL)
CFRelease(serial);
CFRelease(ret);
return NULL;
}
-
+
return ret;
}