Skip to content

Commit

Permalink
Some more fixups after deploying on FreeBSD in the photo album.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Mar 30, 2007
1 parent 6f0b3c1 commit 14d10d0
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/java/net/spy/memcached/MemcachedConnection.java
Expand Up @@ -132,7 +132,7 @@ public void handleIO() throws IOException {
} else {
// It's very easy in NIO to write a bug such that your selector
// spins madly. This will catch that and let it break.
getLogger().info("No selectors ready, interrupted: "
getLogger().debug("No selectors ready, interrupted: "
+ Thread.interrupted());
if(++emptySelects > EXCESSIVE_EMPTY) {
for(SelectionKey sk : selector.keys()) {
Expand Down Expand Up @@ -188,7 +188,7 @@ private void handleIO(SelectionKey sk) throws IOException {
getLogger().info("Connection state changed for %s", sk);
try {
if(qa.channel.finishConnect()) {
assert qa.channel.isConnected() : "Not onnected.";
assert qa.channel.isConnected() : "Not connected.";
synchronized(qa) {
qa.reconnectAttempt=0;
}
Expand Down Expand Up @@ -241,25 +241,19 @@ private void handleOperation(Operation currentOp, SelectionKey sk,
}
break;
case WRITING:
boolean needsReconnect=false;
if(sk.isValid() && sk.isReadable()) {
getLogger().info("Readable in write mode.");
getLogger().debug("Readable in write mode.");
ByteBuffer b=ByteBuffer.allocate(1);
int read=qa.channel.read(b);
assert read <= 0
: "expected to read -1 bytes, read " + read;
needsReconnect=true;
}
if(needsReconnect) {
queueReconnect(qa);
} else {
ByteBuffer b=currentOp.getBuffer();
int wrote=qa.channel.write(b);
getLogger().debug("Wrote %d bytes for %s",
wrote, currentOp);
if(b.remaining() == 0) {
currentOp.writeComplete();
}
ByteBuffer b=currentOp.getBuffer();
int wrote=qa.channel.write(b);
getLogger().debug("Wrote %d bytes for %s",
wrote, currentOp);
if(b.remaining() == 0) {
currentOp.writeComplete();
}
break;
case COMPLETE:
Expand Down Expand Up @@ -445,7 +439,7 @@ public QueueAttachment(SocketAddress sa, SocketChannel c) {
@Override
public String toString() {
int sops=0;
if(sk.isValid()) {
if(sk!= null && sk.isValid()) {
sops=sk.interestOps();
}
return "{QA sa=" + socketAddress + ", #ops=" + ops.size()
Expand Down

0 comments on commit 14d10d0

Please sign in to comment.