Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Build Identifier: Some enhancement in the quick print function. Add maximum printed topics and maximum connections to the preference to optimize the quick print operation. So that block issue would be prevent when overload condition occur. Reproducible: Always
This enhancement seems useful for limiting the memory consumed on the server when printing.
Created attachment 152257 [details] Patch V1 I have added parameter maxConnections & maxTopics. So that the performance could be enhanced in aspect of 'print selected topic and all subtopics'.
I have tested the code and it is working. I also could not see any potential XSS vulnerabilities in the jsp files I did notice a few things that should be changed: 1. Mismatched html tags. I examined the html when printing Workbench User Guide > Getting started > Basic tutorial > Editors and Views. I saw this html early in the file: <body dir="ltr" onload="print()"> <div id="toc"><h1>Editors and views</h1><h2>Contents</h2><div id="toc_content"><div class="toc_entry">1. <a href="#section1">Editors</a></div><div class="toc_entry">2. <a href="#section2">Views</a></div></div></div><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en"> <HEAD> and this at the end: </BODY> </HTML> </body> </html> It appears that the </body> and </html> at the end of the file should appear much earlier. 2. The new preferences need to be documented in the help page /org.eclipse.platform.doc.isv/guide/ua_help_setup_preferences.htm 3. In PrintData.generateResources() there is a synchronized section of code that contains these lines: RequestDispatcher rd = context.getRequestDispatcher("/advanced/printError.jsp"); //$NON-NLS-1$ request.setAttribute("msg", "noConnection"); //$NON-NLS-1$ //$NON-NLS-2$ rd.forward(request, response); while I don't know if any of these could cause a problem it is always good to have as few lines as possible in a synchronized area. This could be accomplished by adding functions like private static boolean synchronized getLock() { if (allowedConnections > 0) { allowedConnections--; return true; } return false; } private static boolean synchronized releaseLock() { allowedConnections++; } and replacing the start of generateResources() with public void generateResources(Writer out) throws IOException, ServletException { if (!getLock()) { RequestDispatcher rd = context.getRequestDispatcher("/advanced/printError.jsp"); //$NON-NLS-1$ request.setAttribute("msg", "noConnection"); //$NON-NLS-1$ //$NON-NLS-2$ rd.forward(request, response); return; } so that the synchronized area is minimized. I also have a couple of suggestions: 4. I think that there should be a value of maxTopics which can be used to indicate no limit, for example a value of 0 could mean there is no limit. 5. The defaults are 100 for maxTopics and 50 for maxConnections, maybe maxTopics should be higher (500) and maxConnections lower (5). 6. Have you thought about having a way for the user to print a large book in sections so that an entire book can still be printed?
Created attachment 152474 [details] Patch V2
Created attachment 152477 [details] Patch V3 Sorry, patch v2 is submitted by mistake. Here is the latest patch.
Hi Chirs, I've updated the patch. For question 1, I modified print.jsp and the method generateToc in PrintData. Now, mismatched html tags will not occur. For question 2, I've added these two parameters in /org.eclipse.platform.doc.isv/guide/ua_help_setup_preferences.htm. For question 3, that's really a good refactor of synchronize section. I've refactor related code in PrintData. To reproduce the 'noConnection error', you can follow this step: * Set maxConnection as 1 * Open Firefox, Perform print task with large amount of topics * Meanwhile, perform the same task in IE ASAP. Then task will be successfully done in FF. And in IE, 'noConnection' alert will display. For question 5, I've set default of maxTopics as 500, and default of maxConnections as 10. For question 4 and 6, now user can set maxTopics a large value to realize this. Cause lack of perfect solution at present, maybe we could make an enhancement on this issue in the future.
Patch committed to HEAD, Fixed.
*** Bug 171987 has been marked as a duplicate of this bug. ***