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
5ad23d21
Commit
5ad23d21
authored
May 29, 2015
by
Dave Cridland
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #223 from guusdk/OF-883
OF-883: Prevent sending data to known disconnected peers.
parents
b5c572f7
0d75703d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
27 deletions
+65
-27
Connection.java
src/java/org/jivesoftware/openfire/Connection.java
+20
-0
SocketConnection.java
src/java/org/jivesoftware/openfire/net/SocketConnection.java
+26
-19
VirtualConnection.java
...java/org/jivesoftware/openfire/net/VirtualConnection.java
+4
-0
ConnectionHandler.java
...java/org/jivesoftware/openfire/nio/ConnectionHandler.java
+1
-1
NIOConnection.java
src/java/org/jivesoftware/openfire/nio/NIOConnection.java
+14
-7
No files found.
src/java/org/jivesoftware/openfire/Connection.java
View file @
5ad23d21
...
...
@@ -144,9 +144,29 @@ public interface Connection {
* <li>Call notifyEvent all listeners that the channel is shutting down.
* <li>Close the socket.
* </ul>
*
* An invocation of this method is equal to invoking {@link #close(boolean)} with a parameter
* that is false.
*/
public
void
close
();
/**
* Close this session including associated socket connection. The order of
* events for closing the session is:
* <ul>
* <li>Set closing flag to prevent redundant shutdowns.
* <li>Call notifyEvent all listeners that the channel is shutting down.
* <li>Close the socket.
* </ul>
*
* This method takes into account the connection state of the peer. Specifically,
* when the peer is known to be in a disconnected state, no data will be sent
* (otherwise, this method can trigger the delivery of an end-of-stream signal).
*
* @param peerIsKnownToBeDisconnected should be set to true when the peer is known to no longer be available.
*/
public
void
close
(
boolean
peerIsKnownToBeDisconnected
);
/**
* Notification message indicating that the server is being shutdown. Implementors
* should send a stream error whose condition is system-shutdown before closing
...
...
src/java/org/jivesoftware/openfire/net/SocketConnection.java
View file @
5ad23d21
...
...
@@ -442,6 +442,10 @@ public class SocketConnection implements Connection {
}
public
void
close
()
{
close
(
false
);
}
public
void
close
(
boolean
peerIsKnownToBeDisconnected
)
{
boolean
wasClosed
=
false
;
synchronized
(
this
)
{
if
(!
isClosed
())
{
...
...
@@ -449,26 +453,29 @@ public class SocketConnection implements Connection {
if
(
session
!=
null
)
{
session
.
setStatus
(
Session
.
STATUS_CLOSED
);
}
boolean
allowedToWrite
=
false
;
try
{
requestWriting
();
allowedToWrite
=
true
;
// Register that we started sending data on the connection
writeStarted
();
writer
.
write
(
"</stream:stream>"
);
if
(
flashClient
)
{
writer
.
write
(
'\0'
);
if
(
!
peerIsKnownToBeDisconnected
)
{
boolean
allowedToWrite
=
false
;
try
{
requestWriting
();
allowedToWrite
=
true
;
// Register that we started sending data on the connection
writeStarted
();
writer
.
write
(
"</stream:stream>"
);
if
(
flashClient
)
{
writer
.
write
(
'\0'
);
}
writer
.
flush
();
}
writer
.
flush
();
}
catch
(
IOException
e
)
{
// Do nothing
}
finally
{
// Register that we finished sending data on the connection
writeFinished
();
if
(
allowedToWrite
)
{
releaseWriting
();
catch
(
IOException
e
)
{
// Do nothing
}
finally
{
// Register that we finished sending data on the connection
writeFinished
();
if
(
allowedToWrite
)
{
releaseWriting
();
}
}
}
}
...
...
src/java/org/jivesoftware/openfire/net/VirtualConnection.java
View file @
5ad23d21
...
...
@@ -169,6 +169,10 @@ public abstract class VirtualConnection implements Connection {
* has been closed.
*/
public
void
close
()
{
close
(
false
);
}
public
void
close
(
boolean
peerIsKnownToBeDisconnected
)
{
boolean
wasClosed
=
false
;
synchronized
(
this
)
{
if
(!
isClosed
())
{
...
...
src/java/org/jivesoftware/openfire/nio/ConnectionHandler.java
View file @
5ad23d21
...
...
@@ -111,7 +111,7 @@ public abstract class ConnectionHandler extends IoHandlerAdapter {
public
void
inputClosed
(
IoSession
session
)
throws
Exception
{
final
Connection
connection
=
(
Connection
)
session
.
getAttribute
(
CONNECTION
);
if
(
connection
!=
null
)
{
connection
.
close
();
connection
.
close
(
true
);
}
}
...
...
src/java/org/jivesoftware/openfire/nio/NIOConnection.java
View file @
5ad23d21
...
...
@@ -219,7 +219,11 @@ public class NIOConnection implements Connection {
return
backupDeliverer
;
}
public
void
close
()
public
void
close
()
{
close
(
false
);
}
public
void
close
(
boolean
peerIsKnownToBeDisconnected
)
{
boolean
notifyClose
=
false
;
synchronized
(
this
)
{
...
...
@@ -234,13 +238,16 @@ public class NIOConnection implements Connection {
if
(
state
!=
State
.
CLOSING
)
{
state
=
State
.
CLOSING
;
try
{
deliverRawText
(
flashClient
?
"</flash:stream>"
:
"</stream:stream>"
);
}
catch
(
Exception
e
)
if
(
!
peerIsKnownToBeDisconnected
)
{
// Ignore
try
{
deliverRawText
(
flashClient
?
"</flash:stream>"
:
"</stream:stream>"
);
}
catch
(
Exception
e
)
{
// Ignore
}
}
}
...
...
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