Commit Graph

12 Commits

Author SHA1 Message Date
Boris Grozev 67a5c3a41a [core] Correctly handle due time of '0' in SmackReactor
Scheduled actions that are due in 0 milliseconds are due
immediately. Otherwise we would invoke select() with 0.

Fixes SMACK-923.
2022-02-06 17:38:50 +01:00
Florian Schmaus b1a4ccfae8 [core] Do not weakly reference "channel selected" callback
Since d65f2c932 ("Bump Error Prone version to 2.3.4 and fix new bug
patterns") the channel selected callback is no longer a final field of
the connection instance, hence it may be come null even if the
connection instance is still strongly referenced. Also the
ConnectionAttemptState class uses simply a lambda as callback, which
is also not strongly referenced otherwise.

The "channel selected" callback was wrapped in weak reference, so that
connection instances could get gc'ed if they are still connected but
the user lost all references to them. In this case, the weak reference
to the connection instance would become 'null' and
selectionKey.cancel() would be called.

This change means that a socket and its selection key of a "leaked"
connected connection instance continues to be part of the reactor. But
this may not be that bad: first, users are expected to manager their
connection instances, and disconnect them before they are
discarded. And secondly, at some point the connection likely will get
disconnected, and in this case, the socket and its selection key will
be removed from the reactor.
2020-05-30 19:45:59 +02:00
Florian Schmaus 72c5dc5886 [core] Introduce ScheduledAction.Kind for blocking and non-blocking actions 2020-05-18 09:15:14 +02:00
Florian Schmaus 6daf19dbd3 [core] Add javadoc to SmackReactor.cancel(ScheduledAction) 2020-05-18 09:15:14 +02:00
Florian Schmaus cc636fff21 Introduce Smack's Modular Connection Architecture
This is a complete redesign of what was previously
XmppNioTcpConnection. The new architecture allows to extend an XMPP
client to server (c2s) connection with new transport bindings and
other extensions.
2020-04-04 13:03:31 +02:00
Florian Schmaus b510d373b5 reactor: have synchronized block include peeking at scheduled actions
If we do not peek at the scheduled actions in the reactors
synchronized block, then there is a kind of lost-update problem. While
Ractor.schedule() will call wakeup() on the selector, a thread could
have already determined the value of selectWait, while being blocked
at the start of the synchronized reactor section. Once it is able to
enter the section, it will use an outdated selectWait value.

This leads to scheduled actions not being executed on time.

Thanks to Eng ChongMeng for reporting this and suggesting the fix.
2019-10-12 10:22:31 +02:00
Florian Schmaus 05c920ab56 Fix typo in comment 2019-10-12 10:14:17 +02:00
Florian Schmaus 4ca2c7cc69 Enable MissingJavadocPackage and UnnecessaryParentheses checkstyle checks 2019-07-24 09:18:39 +02:00
Florian Schmaus 3c306eaff9 Improve comment in SmackReactor 2019-06-05 10:54:07 +02:00
Florian Schmaus 4334ca33ff Add missing selector.wakeup() in SmackRactor.schedule()
Without this, newly scheduled runnables would potentially not be
scheduled in case the reactor thread was blocking in select(0)
indefinetly.

Thanks to Eng ChongMeng for reporting this.
2019-06-03 09:28:52 +02:00
Florian Schmaus 027cae3bd0 Remove unnecessary synchronization in SmackReater.schedule()
The DelayQueue 'scheduledActions' is already thread-safe.
2019-06-03 09:27:28 +02:00
Florian Schmaus e98d42790a SmackReactor/NIO, Java8/Android19, Pretty print XML, FSM connections
This commit adds
- SmackReactor / NIO
- a framework for finite state machine connections
- support for Java 8
- pretty printed XML debug output

It also
- reworks the integration test framework
- raises the minimum Android API level to 19
- introduces XmppNioTcpConnection

Furthermore fixes SMACK-801 (at least partly). Java 8 language
features are available, but not all runtime library methods. For that
we would need to raise the Android API level to 24 or higher.
2019-02-05 13:18:03 +01:00