Skip to content

Commit

Permalink
Revert "dcache-xroot: prevent attempt to write to channel for which c…
Browse files Browse the repository at this point in the history
…hecksum has been computed"

This reverts commit 3b89d2e.
  • Loading branch information
alrossi committed Aug 12, 2021
1 parent 489af68 commit 302db70
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
Expand Up @@ -52,9 +52,4 @@ void write(ByteBuffersProvider msg)
* Whether the file was opened with kXR_posc.
*/
boolean isPersistOnSuccessfulClose();

/**
* Option to postprocess. Default is NOP.
*/
default void close() {}
}
Expand Up @@ -16,35 +16,29 @@
public class WriteDescriptor extends ReadDescriptor
{
private boolean posc;
private boolean closed;

public WriteDescriptor(NettyTransferService<XrootdProtocolInfo>.NettyMoverChannel channel, boolean posc)
{
super(channel);
this.posc = posc;
closed = false;
}

@Override
public synchronized XrootdResponse<SyncRequest> sync(SyncRequest msg)
public XrootdResponse<SyncRequest> sync(SyncRequest msg)
throws IOException, InterruptedException
{
if (!closed) {
_channel.sync();
}
_channel.sync();
return new OkResponse(msg);
}

@Override
public synchronized void write(ByteBuffersProvider provider)
public void write(ByteBuffersProvider provider)
throws IOException
{
if (!closed) {
long position = provider.getWriteOffset();
for (ByteBuffer buffer : provider.toByteBuffers()) {
while (buffer.hasRemaining()) {
long position = provider.getWriteOffset();
for (ByteBuffer buffer : provider.toByteBuffers()) {
while (buffer.hasRemaining()) {
position += _channel.write(buffer, position);
}
}
}
}
Expand All @@ -54,8 +48,4 @@ public boolean isPersistOnSuccessfulClose()
{
return posc;
}

public synchronized void close() {
closed = true;
}
}
Expand Up @@ -178,10 +178,10 @@ public void channelInactive(ChannelHandlerContext ctx)
/* close leftover descriptors */
for (FileDescriptor descriptor : _descriptors) {
if (descriptor != null) {
/*
* Does not affect read descriptors.
*/
descriptor.close();
if (descriptor instanceof TpcWriteDescriptor) {
((TpcWriteDescriptor)descriptor).shutDown();
}

if (descriptor.isPersistOnSuccessfulClose()) {
descriptor.getChannel().release(new FileCorruptedCacheException(
"File was opened with Persist On Successful Close and not closed."));
Expand Down Expand Up @@ -774,11 +774,8 @@ protected XrootdResponse<CloseRequest> doOnClose(ChannelHandlerContext ctx, Clos
* The alternative adopted here is to implement a forcible close by releasing
* all references to the mover.
*/

FileDescriptor descriptor = _descriptors.get(fd);
descriptor.close();

NettyTransferService<XrootdProtocolInfo>.NettyMoverChannel channel = descriptor.getChannel();
NettyTransferService<XrootdProtocolInfo>.NettyMoverChannel channel
= _descriptors.get(fd).getChannel();

/*
* Stop any timer in case this is a reconnect.
Expand Down
Expand Up @@ -337,10 +337,8 @@ public void write(InboundReadResponse inboundReadResponse)
write((ByteBuffersProvider)inboundReadResponse);
}

public void close()
public void shutDown()
{
super.close();

if (client == null) {
return;
}
Expand Down

0 comments on commit 302db70

Please sign in to comment.