Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
a5dff28d
Commit
a5dff28d
authored
Jan 16, 2015
by
Dave Cridland
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #156 from tevans/OF-857
OF-857: Synchronize connection/session cleanup
parents
111fe941
32a1c171
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
29 deletions
+99
-29
OfflineMessageStrategy.java
...ava/org/jivesoftware/openfire/OfflineMessageStrategy.java
+3
-0
SessionManager.java
src/java/org/jivesoftware/openfire/SessionManager.java
+6
-4
ClientConnectionHandler.java
...rg/jivesoftware/openfire/nio/ClientConnectionHandler.java
+1
-1
NIOConnection.java
src/java/org/jivesoftware/openfire/nio/NIOConnection.java
+26
-24
OfflinePacketDeliverer.java
...org/jivesoftware/openfire/nio/OfflinePacketDeliverer.java
+63
-0
No files found.
src/java/org/jivesoftware/openfire/OfflineMessageStrategy.java
View file @
a5dff28d
...
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
...
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
import
org.xmpp.packet.JID
;
import
org.xmpp.packet.JID
;
import
org.xmpp.packet.Message
;
import
org.xmpp.packet.Message
;
import
org.xmpp.packet.PacketError
;
import
org.xmpp.packet.PacketError
;
import
org.xmpp.packet.PacketExtension
;
/**
/**
* Controls what is done with offline messages.
* Controls what is done with offline messages.
...
@@ -80,9 +81,11 @@ public class OfflineMessageStrategy extends BasicModule {
...
@@ -80,9 +81,11 @@ public class OfflineMessageStrategy extends BasicModule {
public
void
storeOffline
(
Message
message
)
{
public
void
storeOffline
(
Message
message
)
{
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
// Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
// Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
// Also ignore message carbons
JID
recipientJID
=
message
.
getTo
();
JID
recipientJID
=
message
.
getTo
();
if
(
recipientJID
==
null
||
serverAddress
.
equals
(
recipientJID
)
||
if
(
recipientJID
==
null
||
serverAddress
.
equals
(
recipientJID
)
||
recipientJID
.
getNode
()
==
null
||
recipientJID
.
getNode
()
==
null
||
message
.
getExtension
(
"received"
,
"urn:xmpp:carbons:2"
)
!=
null
||
!
UserManager
.
getInstance
().
isRegisteredUser
(
recipientJID
.
getNode
()))
{
!
UserManager
.
getInstance
().
isRegisteredUser
(
recipientJID
.
getNode
()))
{
return
;
return
;
}
}
...
...
src/java/org/jivesoftware/openfire/SessionManager.java
View file @
a5dff28d
...
@@ -641,12 +641,14 @@ public class SessionManager extends BasicModule implements ClusterEventListener
...
@@ -641,12 +641,14 @@ public class SessionManager extends BasicModule implements ClusterEventListener
JID
searchJID
=
new
JID
(
originatingResource
.
getNode
(),
originatingResource
.
getDomain
(),
null
);
JID
searchJID
=
new
JID
(
originatingResource
.
getNode
(),
originatingResource
.
getDomain
(),
null
);
List
<
JID
>
addresses
=
routingTable
.
getRoutes
(
searchJID
,
null
);
List
<
JID
>
addresses
=
routingTable
.
getRoutes
(
searchJID
,
null
);
for
(
JID
address
:
addresses
)
{
for
(
JID
address
:
addresses
)
{
if
(!
originatingResource
.
equals
(
address
))
{
// Send the presence of the session whose presence has changed to
// Send the presence of the session whose presence has changed to
// this other user's session
// this user's other session(s)
presence
.
setTo
(
address
);
presence
.
setTo
(
address
);
routingTable
.
routePacket
(
address
,
presence
,
false
);
routingTable
.
routePacket
(
address
,
presence
,
false
);
}
}
}
}
}
/**
/**
* Notification message sent when a client sent an unavailable presence for the session. Making
* Notification message sent when a client sent an unavailable presence for the session. Making
...
...
src/java/org/jivesoftware/openfire/nio/ClientConnectionHandler.java
View file @
a5dff28d
...
@@ -50,7 +50,7 @@ public class ClientConnectionHandler extends ConnectionHandler {
...
@@ -50,7 +50,7 @@ public class ClientConnectionHandler extends ConnectionHandler {
@Override
@Override
NIOConnection
createNIOConnection
(
IoSession
session
)
{
NIOConnection
createNIOConnection
(
IoSession
session
)
{
return
new
NIOConnection
(
session
,
XMPPServer
.
getInstance
().
get
PacketDeliverer
());
return
new
NIOConnection
(
session
,
new
Offline
PacketDeliverer
());
}
}
@Override
@Override
...
...
src/java/org/jivesoftware/openfire/nio/NIOConnection.java
View file @
a5dff28d
...
@@ -203,9 +203,10 @@ public class NIOConnection implements Connection {
...
@@ -203,9 +203,10 @@ public class NIOConnection implements Connection {
}
}
public
void
close
()
{
public
void
close
()
{
boolean
closedSuccessfully
=
false
;
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
isClosed
())
{
if
(!
isClosed
())
{
return
;
}
try
{
try
{
deliverRawText
(
flashClient
?
"</flash:stream>"
:
"</stream:stream>"
,
false
);
deliverRawText
(
flashClient
?
"</flash:stream>"
:
"</stream:stream>"
,
false
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -214,14 +215,10 @@ public class NIOConnection implements Connection {
...
@@ -214,14 +215,10 @@ public class NIOConnection implements Connection {
if
(
session
!=
null
)
{
if
(
session
!=
null
)
{
session
.
setStatus
(
Session
.
STATUS_CLOSED
);
session
.
setStatus
(
Session
.
STATUS_CLOSED
);
}
}
ioSession
.
close
(
false
);
closed
=
true
;
closed
=
true
;
closedSuccessfully
=
true
;
notifyCloseListeners
();
// clean up session, etc.
}
}
if
(
closedSuccessfully
)
{
notifyCloseListeners
();
}
}
ioSession
.
close
(
false
);
// async via MINA
}
}
public
void
systemShutdown
()
{
public
void
systemShutdown
()
{
...
@@ -248,12 +245,9 @@ public class NIOConnection implements Connection {
...
@@ -248,12 +245,9 @@ public class NIOConnection implements Connection {
session
=
owner
;
session
=
owner
;
}
}
public
boolean
isClosed
()
{
public
synchronized
boolean
isClosed
()
{
if
(
session
==
null
)
{
return
closed
;
return
closed
;
}
}
return
session
.
getStatus
()
==
Session
.
STATUS_CLOSED
;
}
public
boolean
isSecure
()
{
public
boolean
isSecure
()
{
return
ioSession
.
getFilterChain
().
contains
(
TLS_FILTER_NAME
);
return
ioSession
.
getFilterChain
().
contains
(
TLS_FILTER_NAME
);
...
@@ -261,7 +255,15 @@ public class NIOConnection implements Connection {
...
@@ -261,7 +255,15 @@ public class NIOConnection implements Connection {
public
void
deliver
(
Packet
packet
)
throws
UnauthorizedException
{
public
void
deliver
(
Packet
packet
)
throws
UnauthorizedException
{
if
(
isClosed
())
{
if
(
isClosed
())
{
backupDeliverer
.
deliver
(
packet
);
// OF-857: Do not allow the backup deliverer to recurse
if
(
backupDeliverer
==
null
)
{
Log
.
error
(
"Failed to deliver packet: "
+
packet
.
toXML
());
throw
new
IllegalStateException
(
"Connection closed"
);
}
// attempt to deliver via backup only once
PacketDeliverer
backup
=
backupDeliverer
;
backupDeliverer
=
null
;
backup
.
deliver
(
packet
);
}
}
else
{
else
{
boolean
errorDelivering
=
false
;
boolean
errorDelivering
=
false
;
...
...
src/java/org/jivesoftware/openfire/nio/OfflinePacketDeliverer.java
0 → 100644
View file @
a5dff28d
/**
* Copyright (C) 2005-2015 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
jivesoftware
.
openfire
.
nio
;
import
org.jivesoftware.openfire.OfflineMessageStrategy
;
import
org.jivesoftware.openfire.PacketDeliverer
;
import
org.jivesoftware.openfire.PacketException
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.auth.UnauthorizedException
;
import
org.jivesoftware.util.LocaleUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.IQ
;
import
org.xmpp.packet.Message
;
import
org.xmpp.packet.Packet
;
import
org.xmpp.packet.Presence
;
/**
* Fallback method used by {@link org.jivesoftware.openfire.nio.NIOConnection} when a
* connection fails to send a {@link Packet} (likely because it was closed). Message packets
* will be stored offline for later retrieval. IQ and Presence packets are dropped.<p>
*
* @author Tom Evans
*/
public
class
OfflinePacketDeliverer
implements
PacketDeliverer
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
OfflinePacketDeliverer
.
class
);
private
OfflineMessageStrategy
messageStrategy
;
public
OfflinePacketDeliverer
()
{
this
.
messageStrategy
=
XMPPServer
.
getInstance
().
getOfflineMessageStrategy
();
}
@Override
public
void
deliver
(
Packet
packet
)
throws
UnauthorizedException
,
PacketException
{
if
(
packet
instanceof
Message
)
{
messageStrategy
.
storeOffline
((
Message
)
packet
);
}
else
if
(
packet
instanceof
Presence
)
{
// presence packets are dropped silently
}
else
if
(
packet
instanceof
IQ
)
{
// IQ packets are logged before being dropped
Log
.
warn
(
LocaleUtils
.
getLocalizedString
(
"admin.error.routing"
)
+
"\n"
+
packet
.
toString
());
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment