Skip to content

Commit

Permalink
ftp: close pool connection with MODE-E proxy
Browse files Browse the repository at this point in the history
Motivation:

When SocketAdapter is proxying MODE-E, the pool connection is left
half-closed.

Modification:

Move resposibility for closing the output connection from the
mode-specific handler to the adapter.

Result:

An unreleased regression is fixed.

Target: master
Request: 4.1
Require-notes: no
Require-book: no
Patch: https://rb.dcache.org/r/10817/
Acked-by: Tigran Mkrtchyan
  • Loading branch information
paulmillar committed Mar 9, 2018
1 parent a379c4c commit c7af0ad
Showing 1 changed file with 29 additions and 26 deletions.
Expand Up @@ -211,11 +211,6 @@ public void run()
+ e.getMessage());
}
} finally {
try {
_output.close();
} catch (IOException e) {
LOGGER.warn("Problem closing output: {}", e.getMessage());
}
_inbound.returnChannel(_input);
}
} catch (InterruptedException e) {
Expand Down Expand Up @@ -522,30 +517,38 @@ public void run()
*/
SocketChannel output = _outbound.accept();

/* Send the EOF. The GridFTP protocol allows us to send
* this information at any time. Doing it up front will
* make sure, that the other end doesn't need to wait for
* it.
*/
if (_modeE) {
sendEof(output);
}
try {
/* Send the EOF. The GridFTP protocol allows us to send
* this information at any time. Doing it up front will
* make sure, that the other end doesn't need to wait for
* it.
*/
if (_modeE) {
sendEof(output);
}

_inbound.accept(c -> {acceptNewChannel(c, output);});
_inbound.accept(c -> {acceptNewChannel(c, output);});

awaitRedirectors();
awaitRedirectors();

/* Send the EOD (remember that we already sent the EOF
* earlier).
*/
if (_modeE) {
if (!isEODExpectedSpecified()) {
setError("Did not receive EOF marker. Transfer failed.");
} else if (!hasSeenAllExpectedEOD()) {
setError("Transfer failed: not enough EOD markers (expected " +
getEODExpected() + ", got " + getEODSeen() + ")");
} else {
sendEod(output);
/* Send the EOD (remember that we already sent the EOF
* earlier).
*/
if (_modeE) {
if (!isEODExpectedSpecified()) {
setError("Did not receive EOF marker. Transfer failed.");
} else if (!hasSeenAllExpectedEOD()) {
setError("Transfer failed: not enough EOD markers (expected " +
getEODExpected() + ", got " + getEODSeen() + ")");
} else {
sendEod(output);
}
}
} finally {
try {
output.close();
} catch (IOException e) {
LOGGER.warn("Problem closing output: {}", e.getMessage());
}
}
} catch (InterruptedException e) {
Expand Down

0 comments on commit c7af0ad

Please sign in to comment.