readpending
This commit is contained in:
@@ -187,7 +187,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
|||||||
}
|
}
|
||||||
channel.setReadBuffer(buffer.clear());
|
channel.setReadBuffer(buffer.clear());
|
||||||
context.executeDispatch(request, response);
|
context.executeDispatch(request, response);
|
||||||
if (!response.readRegistered) {
|
if (request.readCompleted) {
|
||||||
channel.readRegister(this);
|
channel.readRegister(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
|
|
||||||
protected boolean inNonBlocking = true;
|
protected boolean inNonBlocking = true;
|
||||||
|
|
||||||
protected boolean readRegistered;
|
|
||||||
|
|
||||||
// 输出的结果对象
|
// 输出的结果对象
|
||||||
protected Object output;
|
protected Object output;
|
||||||
|
|
||||||
@@ -141,7 +139,6 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
inited = true;
|
inited = true;
|
||||||
inNonBlocking = true;
|
inNonBlocking = true;
|
||||||
readRegistered = false;
|
|
||||||
request.prepare();
|
request.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +179,6 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
|
|
||||||
protected void refuseAlive() {
|
protected void refuseAlive() {
|
||||||
this.request.keepAlive = false;
|
this.request.keepAlive = false;
|
||||||
this.readRegistered = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(AsyncConnection channel) {
|
protected void init(AsyncConnection channel) {
|
||||||
@@ -353,7 +349,6 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
if (!request.readCompleted) {
|
if (!request.readCompleted) {
|
||||||
conn.readRegister(conn.protocolCodec);
|
conn.readRegister(conn.protocolCodec);
|
||||||
this.readRegistered = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Supplier<Response> poolSupplier = this.responseSupplier;
|
Supplier<Response> poolSupplier = this.responseSupplier;
|
||||||
@@ -362,7 +357,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
|||||||
new ProtocolCodec(context, poolSupplier, poolConsumer, conn)
|
new ProtocolCodec(context, poolSupplier, poolConsumer, conn)
|
||||||
.response(this)
|
.response(this)
|
||||||
.run(null);
|
.run(null);
|
||||||
this.readRegistered = true;
|
request.readCompleted = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
this.keepAlive = false;
|
this.keepAlive = false;
|
||||||
}
|
}
|
||||||
// readCompleted=true时ProtocolCodec会继续读下一个request
|
// readCompleted=true时ProtocolCodec会继续读下一个request
|
||||||
this.readCompleted = !this.boundary;
|
this.readCompleted = !this.boundary && !maybews;
|
||||||
this.bodyBytes.clear();
|
this.bodyBytes.clear();
|
||||||
this.readState = READ_STATE_BODY;
|
this.readState = READ_STATE_BODY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1037,10 +1037,6 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
|||||||
this.responseConsumer.accept(this);
|
this.responseConsumer.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void skipReadRegistered() {
|
|
||||||
this.readRegistered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 以304状态码输出 */
|
/** 以304状态码输出 */
|
||||||
public void finish304() {
|
public void finish304() {
|
||||||
skipHeader();
|
skipHeader();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.net.http;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,8 +19,10 @@ import org.redkale.convert.json.JsonConvert;
|
|||||||
*/
|
*/
|
||||||
public class WebSocketAction implements Serializable {
|
public class WebSocketAction implements Serializable {
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
protected String action;
|
protected String action;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 2)
|
||||||
protected Map<String, String> attach;
|
protected Map<String, String> attach;
|
||||||
|
|
||||||
public WebSocketAction() {}
|
public WebSocketAction() {}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.redkale.net.http;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,8 +21,10 @@ import org.redkale.convert.json.JsonConvert;
|
|||||||
*/
|
*/
|
||||||
public class WebSocketAddress implements Serializable {
|
public class WebSocketAddress implements Serializable {
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
protected InetSocketAddress addr;
|
protected InetSocketAddress addr;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 2)
|
||||||
protected String topic;
|
protected String topic;
|
||||||
|
|
||||||
public WebSocketAddress() {}
|
public WebSocketAddress() {}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.net.http;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
import org.redkale.net.http.WebSocketPacket.FrameType;
|
import org.redkale.net.http.WebSocketPacket.FrameType;
|
||||||
import org.redkale.util.ByteArray;
|
import org.redkale.util.ByteArray;
|
||||||
|
|
||||||
@@ -65,10 +66,13 @@ public final class WebSocketPacket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
protected FrameType type;
|
protected FrameType type;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 2)
|
||||||
protected byte[] payload;
|
protected byte[] payload;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 3)
|
||||||
protected boolean last = true;
|
protected boolean last = true;
|
||||||
|
|
||||||
public WebSocketPacket() {}
|
public WebSocketPacket() {}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package org.redkale.net.http;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,8 +19,10 @@ import org.redkale.convert.json.JsonConvert;
|
|||||||
*/
|
*/
|
||||||
public class WebSocketRange implements Serializable {
|
public class WebSocketRange implements Serializable {
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
protected String wskey;
|
protected String wskey;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 2)
|
||||||
protected Map<String, String> attach;
|
protected Map<String, String> attach;
|
||||||
|
|
||||||
public WebSocketRange() {}
|
public WebSocketRange() {}
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public abstract class WebSocketServlet extends HttpServlet implements Resourcabl
|
|||||||
webSocket.deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
|
webSocket.deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
|
||||||
webSocket.inflater = new Inflater(true);
|
webSocket.inflater = new Inflater(true);
|
||||||
}
|
}
|
||||||
response.skipReadRegistered();
|
|
||||||
initRestWebSocket(webSocket);
|
initRestWebSocket(webSocket);
|
||||||
CompletableFuture<String> sessionFuture = webSocket.onOpen(request);
|
CompletableFuture<String> sessionFuture = webSocket.onOpen(request);
|
||||||
if (sessionFuture == null) {
|
if (sessionFuture == null) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.redkale.net.http;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import org.redkale.convert.ConvertColumn;
|
||||||
import org.redkale.convert.json.JsonConvert;
|
import org.redkale.convert.json.JsonConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,10 +42,13 @@ public interface WebSocketUserAddress extends Serializable {
|
|||||||
|
|
||||||
public static class SimpleWebSocketUserAddress implements WebSocketUserAddress {
|
public static class SimpleWebSocketUserAddress implements WebSocketUserAddress {
|
||||||
|
|
||||||
|
@ConvertColumn(index = 1)
|
||||||
private Serializable userid;
|
private Serializable userid;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 2)
|
||||||
private WebSocketAddress address;
|
private WebSocketAddress address;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 3)
|
||||||
private Collection<WebSocketAddress> addresses;
|
private Collection<WebSocketAddress> addresses;
|
||||||
|
|
||||||
public SimpleWebSocketUserAddress() {}
|
public SimpleWebSocketUserAddress() {}
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.redkale.net.sncp;
|
package org.redkale.net.sncp;
|
||||||
|
|
||||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
|
||||||
import static org.redkale.asm.Opcodes.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.nio.channels.CompletionHandler;
|
import java.nio.channels.CompletionHandler;
|
||||||
@@ -16,6 +13,8 @@ import java.util.concurrent.*;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.redkale.annotation.NonBlocking;
|
import org.redkale.annotation.NonBlocking;
|
||||||
import org.redkale.asm.*;
|
import org.redkale.asm.*;
|
||||||
|
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||||
|
import static org.redkale.asm.Opcodes.*;
|
||||||
import org.redkale.asm.Type;
|
import org.redkale.asm.Type;
|
||||||
import org.redkale.convert.*;
|
import org.redkale.convert.*;
|
||||||
import org.redkale.convert.pb.ProtobufFactory;
|
import org.redkale.convert.pb.ProtobufFactory;
|
||||||
@@ -155,7 +154,7 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
SncpServlet o = other;
|
SncpServlet o = other;
|
||||||
int rs = 0;
|
int rs;
|
||||||
if (this.resourceType == null) {
|
if (this.resourceType == null) {
|
||||||
rs = o.resourceType == null ? 0 : -1;
|
rs = o.resourceType == null ? 0 : -1;
|
||||||
} else if (o.resourceType == null) {
|
} else if (o.resourceType == null) {
|
||||||
@@ -489,7 +488,6 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
|||||||
|
|
||||||
final Class serviceClass = service.getClass();
|
final Class serviceClass = service.getClass();
|
||||||
final String supDynName = SncpActionServlet.class.getName().replace('.', '/');
|
final String supDynName = SncpActionServlet.class.getName().replace('.', '/');
|
||||||
final String resourceTypeName = resourceType.getName().replace('.', '/');
|
|
||||||
final String serviceImpTypeName = serviceImplClass.getName().replace('.', '/');
|
final String serviceImpTypeName = serviceImplClass.getName().replace('.', '/');
|
||||||
final String convertName = Convert.class.getName().replace('.', '/');
|
final String convertName = Convert.class.getName().replace('.', '/');
|
||||||
final String uint128Desc = Type.getDescriptor(Uint128.class);
|
final String uint128Desc = Type.getDescriptor(Uint128.class);
|
||||||
@@ -521,7 +519,6 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
|||||||
if (newClazz == null) {
|
if (newClazz == null) {
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
ClassWriter cw = new ClassWriter(COMPUTE_FRAMES);
|
||||||
FieldVisitor fv;
|
|
||||||
MethodDebugVisitor mv;
|
MethodDebugVisitor mv;
|
||||||
|
|
||||||
cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null);
|
cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null);
|
||||||
@@ -761,7 +758,9 @@ public class SncpServlet extends Servlet<SncpContext, SncpRequest, SncpResponse>
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
for (java.lang.reflect.Type t : originalParamTypes) {
|
for (java.lang.reflect.Type t : originalParamTypes) {
|
||||||
if (t.toString().startsWith("java.lang.")) {
|
if (t == java.io.Serializable.class
|
||||||
|
|| t == java.io.Serializable[].class
|
||||||
|
|| t.toString().startsWith("java.lang.")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProtobufFactory.root().loadDecoder(t);
|
ProtobufFactory.root().loadDecoder(t);
|
||||||
|
|||||||
Reference in New Issue
Block a user