diff -r 116544b5a04c -r e9feb65d37fa jdk/src/share/classes/sun/security/ssl/AppOutputStream.java --- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Wed Apr 11 07:26:35 2012 -0700 +++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Wed Apr 11 17:12:35 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,9 +91,20 @@ // however they like; if we buffered here, they couldn't. try { do { + boolean holdRecord = false; int howmuch; if (isFirstRecordOfThePayload && c.needToSplitPayload()) { howmuch = Math.min(0x01, r.availableDataBytes()); + /* + * Nagle's algorithm (TCP_NODELAY) was coming into + * play here when writing short (split) packets. + * Signal to the OutputRecord code to internally + * buffer this small packet until the next outbound + * packet (of any type) is written. + */ + if ((len != 1) && (howmuch == 1)) { + holdRecord = true; + } } else { howmuch = Math.min(len, r.availableDataBytes()); } @@ -108,7 +119,7 @@ off += howmuch; len -= howmuch; } - c.writeRecord(r); + c.writeRecord(r, holdRecord); c.checkWrite(); } while (len > 0); } catch (Exception e) {