From d885e74193751896eae7bf5a1432ef61491ea248 Mon Sep 17 00:00:00 2001 From: Gerd Behrmann Date: Thu, 5 Dec 2013 15:07:34 +0100 Subject: [PATCH] ftp: Fix race that lead to erroneous error message in log file Removes the following error message: 05 dec 2013 14:35:34 (httpd) [door:httpd@dCacheDomain:1386250529077 door:httpd@dCacheDomain:1386250530581 door:httpd@dCacheDomain:1386250530980 door:httpd@dCacheDomain:13 86250531049 door:httpd@dCacheDomain:1386250531677 door:httpd@dCacheDomain:1386250531744 door:httpd@dCacheDomain:1386250533468 door:httpd@dCacheDomain:1386250533660 door:h ttpd@dCacheDomain:1386250534760] Cannot abort transfer that already completed: 451 Aborting transfer due to session termination This error is a result of a race in which door shutdown and the transfer termination sequence conincide. The patch rearranges the termination sequence to mark the transfer as completed before providing the final reply to the client. The patch also removes the error logging. Target: trunk Require-notes: no Require-book: no Acked-by: Tigran Mkrtchyan Patch: http://rb.dcache.org/r/6320/ --- .../java/org/dcache/ftp/door/AbstractFtpDoorV1.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/dcache-ftp/src/main/java/org/dcache/ftp/door/AbstractFtpDoorV1.java b/modules/dcache-ftp/src/main/java/org/dcache/ftp/door/AbstractFtpDoorV1.java index 81c3981ddce..91cb7669051 100644 --- a/modules/dcache-ftp/src/main/java/org/dcache/ftp/door/AbstractFtpDoorV1.java +++ b/modules/dcache-ftp/src/main/java/org/dcache/ftp/door/AbstractFtpDoorV1.java @@ -1088,9 +1088,9 @@ protected synchronized void transferCompleted(CacheException error) } notifyBilling(0, ""); - reply("226 Transfer complete."); _completed = true; setTransfer(null); + reply("226 Transfer complete."); } catch (CacheException e) { abort(426, e.getMessage()); } catch (FTPCommandException e) { @@ -1128,13 +1128,7 @@ public void abort(int replyCode, String msg) public synchronized void abort(int replyCode, String replyMsg, Exception exception) { - if (_aborted) { - return; - } - - if (_completed) { - LOGGER.error("Cannot abort transfer that already completed: {} {}", - replyCode, replyMsg); + if (_aborted || _completed) { return; } @@ -1172,9 +1166,9 @@ public synchronized void abort(int replyCode, String replyMsg, LOGGER.error("Transfer error: {} ({})", msg, exception.getMessage()); LOGGER.debug(exception.toString(), exception); } - reply(msg); _aborted = true; setTransfer(null); + reply(msg); } }