(tomcat) branch 9.0.x updated: Remove sync

2024-01-18 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 344733bfc7 Remove sync
344733bfc7 is described below

commit 344733bfc7b547ef6e2746518ced7dbc0b18eebd
Author: remm 
AuthorDate: Thu Jan 18 15:25:38 2024 +0100

Remove sync

This is always called after creating a message. This does not appear to
be called again so I don't really see the need for timestampSet.
If really needed, using an AtomicLong would probably be better (with
compareAndSet(0, time)).
Found by coverity.
---
 java/org/apache/catalina/ha/session/SessionMessageImpl.java | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/SessionMessageImpl.java 
b/java/org/apache/catalina/ha/session/SessionMessageImpl.java
index 3c2884ae9a..bb54b5d666 100644
--- a/java/org/apache/catalina/ha/session/SessionMessageImpl.java
+++ b/java/org/apache/catalina/ha/session/SessionMessageImpl.java
@@ -112,14 +112,13 @@ public class SessionMessageImpl extends 
ClusterMessageBase implements SessionMes
 
 /**
  * set message send time but only the first setting works (one shot)
+ * @param time the timestamp
  */
 @Override
 public void setTimestamp(long time) {
-synchronized (this) {
-if (!timestampSet) {
-serializationTimestamp = time;
-timestampSet = true;
-}
+if (!timestampSet) {
+serializationTimestamp = time;
+timestampSet = true;
 }
 }
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch 9.0.x updated: Remove sync

2020-03-17 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
 new cc4772a  Remove sync
cc4772a is described below

commit cc4772aa7f3b56cde5bdcd4c8b185db20529f76c
Author: remm 
AuthorDate: Tue Mar 17 18:06:23 2020 +0100

Remove sync

keyFor syncs on a global lock, so remove it when processing sockets.
---
 java/org/apache/tomcat/util/net/NioEndpoint.java | 50 +++-
 webapps/docs/changelog.xml   |  4 ++
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java 
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 8712fe2..3e82123 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1547,33 +1547,29 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 socketWrapper.close();
 return;
 }
-SelectionKey key = 
socket.getIOChannel().keyFor(poller.getSelector());
 
 try {
 int handshake = -1;
-
 try {
-if (key != null) {
-if (socket.isHandshakeComplete()) {
-// No TLS handshaking required. Let the handler
-// process this socket / event combination.
-handshake = 0;
-} else if (event == SocketEvent.STOP || event == 
SocketEvent.DISCONNECT ||
-event == SocketEvent.ERROR) {
-// Unable to complete the TLS handshake. Treat it 
as
-// if the handshake failed.
-handshake = -1;
-} else {
-handshake = socket.handshake(key.isReadable(), 
key.isWritable());
-// The handshake process reads/writes from/to the
-// socket. status may therefore be OPEN_WRITE once
-// the handshake completes. However, the handshake
-// happens when the socket is opened so the status
-// must always be OPEN_READ after it completes. It
-// is OK to always set this as it is only used if
-// the handshake completes.
-event = SocketEvent.OPEN_READ;
-}
+if (socket.isHandshakeComplete()) {
+// No TLS handshaking required. Let the handler
+// process this socket / event combination.
+handshake = 0;
+} else if (event == SocketEvent.STOP || event == 
SocketEvent.DISCONNECT ||
+event == SocketEvent.ERROR) {
+// Unable to complete the TLS handshake. Treat it as
+// if the handshake failed.
+handshake = -1;
+} else {
+handshake = socket.handshake(event == 
SocketEvent.OPEN_READ, event == SocketEvent.OPEN_WRITE);
+// The handshake process reads/writes from/to the
+// socket. status may therefore be OPEN_WRITE once
+// the handshake completes. However, the handshake
+// happens when the socket is opened so the status
+// must always be OPEN_READ after it completes. It
+// is OK to always set this as it is only used if
+// the handshake completes.
+event = SocketEvent.OPEN_READ;
 }
 } catch (IOException x) {
 handshake = -1;
@@ -1590,23 +1586,23 @@ public class NioEndpoint extends 
AbstractJsseEndpoint
 state = getHandler().process(socketWrapper, event);
 }
 if (state == SocketState.CLOSED) {
-poller.cancelledKey(key, socketWrapper);
+
poller.cancelledKey(socket.getIOChannel().keyFor(poller.getSelector()), 
socketWrapper);
 }
 } else if (handshake == -1 ) {
 getHandler().process(socketWrapper, 
SocketEvent.CONNECT_FAIL);
-poller.cancelledKey(key, socketWrapper);
+
poller.cancelledKey(socket.getIOChannel().keyFor(poller.getSelector()), 
socketWrapper);
 } else if (handshake == SelectionKey.OP_READ){
 socketWrapper.registerReadInterest();
 } else if (handshake == SelectionKey.OP_WRITE){