Oliver Jowett wrote:
> Oliver Jowett wrote:
>
>> I have a bit of time spare today, I might look at putting together that
>> OutputStream wrapper.
>
> Try this. I have not tested at all - it compiles but that's as far as I
> got - but it should give you an idea of what I had in mind.
And here are the fixes for the deliberate mistakes in the first version ;-)
This passes the regression testsuite with antiDeadlock=true, but I don't
have a deadlock testcase on hand to try unfortunately.
-O
--- crypt/pgjdbc/org/postgresql/core/AntiDeadlockStream.java.orig 2009-01-22 14:47:06.000000000 +1300
+++ crypt/pgjdbc/org/postgresql/core/AntiDeadlockStream.java 2009-01-22 14:44:47.000000000 +1300
@@ -159,23 +159,23 @@
byte[] oldBuffer = buffer;
buffer = swapBuffer;
- swapBuffer = buffer;
+ swapBuffer = oldBuffer;
writeLength = bufferSize;
doFlush = flushRequest;
doClose = closeRequest;
flushRequest = false;
-
+ bufferSize = 0;
bufferLock.notifyAll();
}
try {
if (writeLength > 0)
wrapped.write(swapBuffer, 0, writeLength);
- if (flushRequest)
+ if (doFlush)
wrapped.flush();
- if (closeRequest) {
+ if (doClose) {
wrapped.close();
synchronized (bufferLock) {