Skip to content

Commit

Permalink
Remove OOM handling in IStorageChannels
Browse files Browse the repository at this point in the history
`OutOfMemoryException` is deprecated. In D2, it is an `Error`, so should
not be caught.

Fixes sociomantic-tsunami#338.
  • Loading branch information
Gavin Norman committed Jan 15, 2019
1 parent 6005582 commit 961aeb1
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions src/swarm/node/storage/model/IStorageChannels.d
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@ abstract public class IStorageChannelsTemplate ( Storage : IStorageEngine )
private ulong size_limit;


/***************************************************************************
Flag set to true if the creation of a channel (by the create_() method)
fails due to an OutOfMemory exception. In this case further requests to
create new channels will be ignored, in order to prevent the case where
the node gets into the state where it's constantly attempting and
failing to create a new channel.
***************************************************************************/

private bool no_more_channels;


/***************************************************************************
Constructor.
Expand Down Expand Up @@ -327,33 +314,20 @@ abstract public class IStorageChannelsTemplate ( Storage : IStorageEngine )
idup(typeof(this).stringof ~ ".create: channel '" ~
channel_id ~ "' already exists!"));

if ( !this.no_more_channels )
{
try
{
auto channel = this.channel_pool.get(this.create_(channel_id));
channel.initialise(channel_id);
this.channels[channel.id] = channel;
auto channel = this.channel_pool.get(this.create_(channel_id));
channel.initialise(channel_id);
this.channels[channel.id] = channel;

verify(channel.id == channel_id, idup(typeof(this).stringof ~
".create: channel name mismatch - '" ~ channel_id ~
" vs '" ~ channel.id ~ "'"));
verify(channel.id == channel_id, idup(typeof(this).stringof ~
".create: channel name mismatch - '" ~ channel_id ~
" vs '" ~ channel.id ~ "'"));

verify((channel_id in this.channels) !is null,
idup(typeof(this).stringof ~
".create: channel '" ~ channel_id ~
"' not in map after creation!"));

return channel;
}
catch ( OutOfMemoryException e )
{
log.error("Node out of memory -- failed to create requested channel '{}'", channel_id);
this.no_more_channels = true;
}
}
verify((channel_id in this.channels) !is null,
idup(typeof(this).stringof ~
".create: channel '" ~ channel_id ~
"' not in map after creation!"));

return null;
return channel;
}


Expand Down

0 comments on commit 961aeb1

Please sign in to comment.