From: <jbo...@li...> - 2005-11-23 16:03:50
|
Author: rem...@jb... Date: 2005-11-23 11:03:27 -0500 (Wed, 23 Nov 2005) New Revision: 1632 Modified: trunk/labs/jbossweb/src/share/classes/org/apache/coyote/http11/Http11AprProcessor.java Log: - Fix crashes when the socket pointer is used outside of the socket method (this could happen with JMX). Modified: trunk/labs/jbossweb/src/share/classes/org/apache/coyote/http11/Http11AprProcessor.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/coyote/http11/Http11AprProcessor.java 2005-11-23 15:42:28 UTC (rev 1631) +++ trunk/labs/jbossweb/src/share/classes/org/apache/coyote/http11/Http11AprProcessor.java 2005-11-23 16:03:27 UTC (rev 1632) @@ -215,7 +215,7 @@ /** * Socket associated with the current connection. */ - protected long socket; + protected long socket = 0; /** @@ -906,6 +906,7 @@ // Recycle inputBuffer.recycle(); outputBuffer.recycle(); + this.socket = 0; return openSocket; @@ -1002,7 +1003,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE) { // Get remote host address - if (remoteAddr == null) { + if (remoteAddr == null && (socket != 0)) { try { long sa = Address.get(Socket.APR_REMOTE, socket); remoteAddr = Address.getip(sa); @@ -1015,7 +1016,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE) { // Get local host name - if (localName == null) { + if (localName == null && (socket != 0)) { try { long sa = Address.get(Socket.APR_LOCAL, socket); localName = Address.getnameinfo(sa, 0); @@ -1028,7 +1029,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_HOST_ATTRIBUTE) { // Get remote host name - if (remoteHost == null) { + if (remoteHost == null && (socket != 0)) { try { long sa = Address.get(Socket.APR_REMOTE, socket); remoteHost = Address.getnameinfo(sa, 0); @@ -1041,7 +1042,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE) { // Get local host address - if (localAddr == null) { + if (localAddr == null && (socket != 0)) { try { long sa = Address.get(Socket.APR_LOCAL, socket); Sockaddr addr = new Sockaddr(); @@ -1059,7 +1060,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_REMOTEPORT_ATTRIBUTE) { // Get remote port - if (remotePort == -1) { + if (remotePort == -1 && (socket != 0)) { try { long sa = Address.get(Socket.APR_REMOTE, socket); Sockaddr addr = Address.getInfo(sa); @@ -1073,7 +1074,7 @@ } else if (actionCode == ActionCode.ACTION_REQ_LOCALPORT_ATTRIBUTE) { // Get local port - if (localPort == -1) { + if (localPort == -1 && (socket != 0)) { try { long sa = Address.get(Socket.APR_LOCAL, socket); Sockaddr addr = new Sockaddr(); |