* Daniel Cheng <j16sdiz+freenet at gmail.com> [2008-11-07 08:24:06]:
> On Wed, Oct 29, 2008 at 2:09 AM, <nextgens at freenetproject.org> wrote:
> > Author: nextgens
> > Date: 2008-10-28 18:09:53 +0000 (Tue, 28 Oct 2008)
> > New Revision: 23155
> >
> > Modified:
> > trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> > trunk/freenet/src/freenet/support/compress/Compressor.java
> > Log:
> > Use java.utils.concurrent.Semaphore to serialize compression-related
> > operations (not tested)
> >
> > Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> > ===================================================================
> > --- trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> > 2008-10-28 18:09:24 UTC (rev 23154)
> > +++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java
> > 2008-10-28 18:09:53 UTC (rev 23155)
> > @@ -26,6 +26,7 @@
> > import freenet.support.io.BucketChainBucketFactory;
> > import freenet.support.io.BucketTools;
> > import freenet.support.io.NativeThread;
> > +import java.util.concurrent.Semaphore;
> >
> > /**
> > * Attempt to insert a file. May include metadata.
> > @@ -108,10 +109,6 @@
> > OffThreadCompressor otc = new OffThreadCompressor();
> > ctx.executor.execute(otc, "Compressor for " + this);
> > }
> > -
> > - // Use a mutex to serialize compression (limit memory usage/IO)
> > - // Of course it doesn't make any sense on multi-core systems.
> > - private static final Object compressorSync = new Object();
> >
> > private class OffThreadCompressor implements PrioRunnable {
> > public void run() {
> > @@ -140,7 +137,14 @@
> > }
> >
> > private void tryCompress() throws InsertException {
> > - synchronized(compressorSync) {
> > + try {
> > + try {
> > +
> > COMPRESSOR_TYPE.compressorSemaphore.acquire();
> > + } catch (InterruptedException e) {
> > + // should not happen
> > + Logger.error(this, "Caught an
> > InterruptedException:"+e.getMessage(), e);
> > + throw new
> > InsertException(InsertException.INTERNAL_ERROR, e, null);
> > + }
> > // First, determine how small it needs to be
> > Bucket origData = block.getData();
> > Bucket data = origData;
> > @@ -302,6 +306,8 @@
> > sfi.start();
> > if(earlyEncode) sfi.forceEncode();
> > }
> > + } finally {
> > + COMPRESSOR_TYPE.compressorSemaphore.release();
>
> the semaphore should go into Compressor, not Compressor.COMPRESSOR_TYPE
>
Change it then
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20081107/4a4509d1/attachment.pgp>