Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: printing/backend/print_backend_cups.cc

Issue 5609004: cupsGetPPD got stuck sometime for an infinite time due to network configurati... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« printing/backend/cups_helper.h ('K') | « printing/backend/cups_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/backend/print_backend_cups.cc
===================================================================
--- printing/backend/print_backend_cups.cc (revision 67734)
+++ printing/backend/print_backend_cups.cc (working copy)
@@ -218,12 +218,36 @@
const char* ppd_file_path = NULL;
if (print_server_url_.is_empty()) { // Use default (local) print server.
ppd_file_path = cupsGetPPD(name);
+ if (ppd_file_path)
+ ppd_path = FilePath(ppd_file_path);
} else {
+ // cupsGetPPD2 got stuck sometimes for an infinite time due to network
sanjeevr 2010/12/03 23:46:37 got => gets Also "for an infinite loop" => "in an
+ // configuration/issues. To prevent that, use non-blocking http connection
+ // here.
+ // Note: After looking at CUPS sources, it looks like non-blocking
+ // connection will timeout after 10 secons of no data period. And it will
sanjeevr 2010/12/03 23:46:37 secons => seconds
+ // return the same way as if data was completely and sucessfully downloaded.
+ // To distinguish error case from the normal return, will check result file
+ // size agains content length.
HttpConnectionCUPS http(print_server_url_);
+ http.SetBlocking(false);
ppd_file_path = cupsGetPPD2(http.http(), name);
+ // Check if the get full PPD, since non-blocking call may simply return
+ // normally after timeout expired.
+ if (ppd_file_path) {
+ ppd_path = FilePath(ppd_file_path);
+ off_t content_len = httpGetLength2(http.http());
+ int64 ppd_size = 0;
+ if (!file_util::GetFileSize(ppd_path, &ppd_size) ||
+ content_len > ppd_size) {
sanjeevr 2010/12/03 23:46:37 content_len != ppd_size ?
+ LOG(ERROR) << "Error downloading PPD file for: " << name
+ << ", file size: " << ppd_size
+ << ", content length: " << content_len;
+ file_util::Delete(ppd_path, false);
+ ppd_path.clear();
+ }
+ }
}
- if (ppd_file_path)
- ppd_path = FilePath(ppd_file_path);
return ppd_path;
}
« printing/backend/cups_helper.h ('K') | « printing/backend/cups_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698