src/share/classes/java/net/SocketOutputStream.java

Print this page
rev 5501 : imported patch io-trace

@@ -28,10 +28,12 @@
 import java.io.FileDescriptor;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.channels.FileChannel;
 
+import sun.misc.IoTrace;
+
 /**
  * This stream extends FileOutputStream to implement a
  * SocketOutputStream. Note that this class should <b>NOT</b> be
  * public.
  *

@@ -102,13 +104,16 @@
                 return;
             }
             throw new ArrayIndexOutOfBoundsException();
         }
 
+        Object traceContext = IoTrace.socketWriteBegin(impl.address, impl.port);
+        int bytesWritten = 0;
         FileDescriptor fd = impl.acquireFD();
         try {
             socketWrite0(fd, b, off, len);
+            bytesWritten = len;
         } catch (SocketException se) {
             if (se instanceof sun.net.ConnectionResetException) {
                 impl.setConnectionResetPending();
                 se = new SocketException("Connection reset");
             }

@@ -117,10 +122,11 @@
             } else {
                 throw se;
             }
         } finally {
             impl.releaseFD();
+            IoTrace.socketWriteEnd(traceContext, bytesWritten);
         }
     }
 
     /**
      * Writes a byte to the socket.