Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIRMINA-1173 #44

Merged
merged 25 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0cbbc8b
working on the multi-phase synchronization; it was working before but…
jon-valliere Feb 20, 2024
ec93bb7
nonblock SSL now passes all tests
jon-valliere Feb 20, 2024
d393ad7
found one place where the UNACK was calculated wrong
jon-valliere Feb 20, 2024
1a4fbda
typos
jon-valliere Feb 22, 2024
05028e8
found an issue where async task execution was always happening inline
jon-valliere Feb 22, 2024
f5f70ed
add accidentally removed sync
jon-valliere Feb 22, 2024
93a4ff7
small change to the control flow for public methods
jon-valliere Feb 24, 2024
ed97be8
adds separate event queue - this is temporary because I don't like th…
jon-valliere Feb 29, 2024
62643fe
alright lets remove all the synchronization from the queue flushes
jon-valliere Mar 1, 2024
df98d09
Free a useless buffer.
elecharny Apr 18, 2024
46fb20f
Merge branch '2.2.X' into bugfix/DIRMINA-1173
elecharny Apr 18, 2024
13d5019
removed a useless import
elecharny Apr 26, 2024
cc86146
Used an AtomicBooleaninstead of using a lock
elecharny Apr 26, 2024
57767e4
Added some new lines for clarity
elecharny Apr 26, 2024
df0ecc6
Disable Nagle's algorithm by default
elecharny May 11, 2024
495a282
Revert the change made on the TCP_NODELAY default value.
elecharny May 11, 2024
0daeb7b
Upgraded PMD to 7.0.0 and pmd-pligin to 3.22
elecharny May 27, 2024
6ab8003
Give more significant name to a variable
elecharny Sep 10, 2024
e3dc20b
Switched to Easymock 5.4.0 as a replacemnt for rmock, hich does not
elecharny Sep 10, 2024
ac9ce3f
Bumped up ognl dependency and PMD
elecharny Sep 10, 2024
2904be1
Bumped up some maven dependencies
elecharny Sep 10, 2024
dd403eb
Bumped up maven dependency versions
elecharny Sep 10, 2024
0fc698a
Added a JenkinsFile
elecharny Sep 11, 2024
994a00b
Deleted badly named Jenkinsfile
elecharny Sep 11, 2024
cf86678
Renamed the Jenkinsfile
elecharny Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.mina.core.polling.AbstractPollingIoProcessor;
import org.apache.mina.core.service.IoProcessor;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class DefaultIoFuture implements IoFuture {
private Object result;

/** The flag used to determinate if the Future is completed or not */
private boolean ready;
private AtomicBoolean ready = new AtomicBoolean(false);

/** A counter for the number of threads waiting on this future */
private int waiters;
Expand Down Expand Up @@ -102,7 +103,7 @@ public boolean join(long timeoutMillis) {
@Override
public IoFuture await() throws InterruptedException {
synchronized (lock) {
while (!ready) {
while (!ready.get()) {
waiters++;

try {
Expand All @@ -113,7 +114,7 @@ public IoFuture await() throws InterruptedException {
} finally {
waiters--;

if (!ready) {
if (!ready.get()) {
checkDeadLock();
}
}
Expand Down Expand Up @@ -200,8 +201,8 @@ private boolean await0(long timeoutMillis, boolean interruptable) throws Interru
synchronized (lock) {
// We can quit if the ready flag is set to true, or if
// the timeout is set to 0 or below : we don't wait in this case.
if (ready||(timeoutMillis <= 0)) {
return ready;
if (ready.get()||(timeoutMillis <= 0)) {
return ready.get();
}

// The operation is not completed : we have to wait
Expand All @@ -222,8 +223,8 @@ private boolean await0(long timeoutMillis, boolean interruptable) throws Interru
}
}

if (ready || (endTime < System.currentTimeMillis())) {
return ready;
if (ready.get() || (endTime < System.currentTimeMillis())) {
return ready.get();
} else {
// Take a chance, detect a potential deadlock
checkDeadLock();
Expand All @@ -237,7 +238,7 @@ private boolean await0(long timeoutMillis, boolean interruptable) throws Interru
// In any case, we decrement the number of waiters, and we get out.
waiters--;

if (!ready) {
if (!ready.get()) {
checkDeadLock();
}
}
Expand Down Expand Up @@ -295,9 +296,7 @@ private void checkDeadLock() {
*/
@Override
public boolean isDone() {
synchronized (lock) {
return ready;
}
return ready.get();
}

/**
Expand All @@ -310,12 +309,12 @@ public boolean isDone() {
public boolean setValue(Object newValue) {
synchronized (lock) {
// Allowed only once.
if (ready) {
if (ready.get()) {
return false;
}

result = newValue;
ready = true;
ready.set(true);

// Now, if we have waiters, notify them that the operation has completed
if (waiters > 0) {
Expand Down Expand Up @@ -348,7 +347,7 @@ public IoFuture addListener(IoFutureListener<?> listener) {
}

synchronized (lock) {
if (ready) {
if (ready.get()) {
// Shortcut : if the operation has completed, no need to
// add a new listener, we just have to notify it. The existing
// listeners have already been notified anyway, when the
Expand Down Expand Up @@ -380,7 +379,7 @@ public IoFuture removeListener(IoFutureListener<?> listener) {
}

synchronized (lock) {
if (!ready) {
if (!ready.get()) {
if (listener == firstListener) {
if ((otherListeners != null) && !otherListeners.isEmpty()) {
firstListener = otherListeners.remove(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) th
buf = newBuf;

// Update the session attribute.
IoBuffer oldBuf = (IoBuffer) session.getAttribute(BUFFER);

if (oldBuf != null) {
oldBuf.free();
}

session.setAttribute(BUFFER, buf);
}
} else {
Expand Down Expand Up @@ -236,6 +242,7 @@ public void dispose(IoSession session) throws Exception {

private void removeSessionBuffer(IoSession session) {
IoBuffer buf = (IoBuffer) session.removeAttribute(BUFFER);

if (buf != null) {
buf.free();
}
Expand All @@ -247,6 +254,12 @@ private void storeRemainingInSession(IoBuffer buf, IoSession session) {
remainingBuf.order(buf.order());
remainingBuf.put(buf);

IoBuffer oldBuf = (IoBuffer) session.getAttribute(BUFFER);

if (oldBuf != null) {
oldBuf.free();
}

session.setAttribute(BUFFER, remainingBuf);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ public void messageReceived(final NextFilter nextFilter, final IoSession session
}
}
}

in.free();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ synchronized public void open(NextFilter next) throws SSLException {

if (mEngine.getUseClientMode()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("{} open() - begin handshaking", toString());
LOGGER.debug("{} open() - begin handshaking", this);
}

mEngine.beginHandshake();
Expand Down Expand Up @@ -252,7 +252,7 @@ protected void receive_loop(NextFilter next, IoBuffer message) throws SSLExcepti
LOGGER.debug("{} receive_loop() - handshake needs task, scheduling", toString());
}

execute_task(next);
schedule_task(next);

break;
case NEED_WRAP:
Expand Down
Loading
Loading