2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A/************************************************************************ 0N/A * SocketOutputStream 0N/A * Class: java_net_SocketOutputStream 0N/A * Class: java_net_SocketOutputStream 0N/A * Method: socketWrite 0N/A * Use stack allocate buffer if possible. For large sizes we allocate 0N/A * an intermediate buffer from the heap (up to a maximum). If heap is 0N/A * unavailable just use our stack buffer. 0N/A * Due to a bug in Windows Sockets (observed on NT and Windows 0N/A * 2000) it may be necessary to retry the send. The issue is that 0N/A * is insufficient buffer space available. If there are a large 0N/A * number of threads blocked on write due to congestion then it's 0N/A * possile to hit the NT/2000 bug whereby send returns WSAENOBUFS. 0N/A * The workaround we use is to retry the send. If we have a 0N/A * large buffer to send (>2k) then we retry with a maximum of 0N/A * 2k buffer. If we hit the issue with <=2k buffer then we backoff 0N/A * for 1 second and retry again. We repeat this up to a reasonable 0N/A * limit before bailing out and throwing an exception. In load 0N/A * conditions we've observed that the send will succeed after 2-3 0N/A * attempts but this depends on network buffers associated with 0N/A * other sockets draining. 0N/A "No buffer space available - exhausted attempts to queue buffer");
0N/A * Send failed - can be caused by close or write error.