Попытка исправления краша ядра
This commit is contained in:
+18
-12
@@ -21,23 +21,29 @@ public class SocketDataChannel extends DataChannel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendImpl(DataPacket packet) throws IOException {
|
public void sendImpl(DataPacket packet) throws IOException {
|
||||||
outputStream.writeUTF(packet.name);
|
if(socket.isClosed()) return;
|
||||||
outputStream.writeByte(packet.formatId);
|
synchronized (outputStream) {
|
||||||
outputStream.writeInt(packet.data.length);
|
outputStream.writeUTF(packet.name);
|
||||||
outputStream.write(packet.data);
|
outputStream.writeByte(packet.formatId);
|
||||||
|
outputStream.writeInt(packet.data.length);
|
||||||
|
outputStream.write(packet.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataPacket receiveImpl() throws IOException {
|
public DataPacket receiveImpl() throws IOException {
|
||||||
String name = inputStream.readUTF();
|
if(socket.isClosed()) return null;
|
||||||
int formatId = inputStream.readByte();
|
synchronized (inputStream) {
|
||||||
int size = inputStream.readInt();
|
String name = inputStream.readUTF();
|
||||||
if (size < 0 || size > 1024 * 1024 * 64) {
|
int formatId = inputStream.readByte();
|
||||||
throw new IOException("packet has invalid size " + size);
|
int size = inputStream.readInt();
|
||||||
|
if (size < 0 || size > 1024 * 1024 * 64) {
|
||||||
|
throw new IOException("packet has invalid size " + size);
|
||||||
|
}
|
||||||
|
byte[] data = new byte[size];
|
||||||
|
inputStream.readFully(data);
|
||||||
|
return new DataPacket(name, formatId, data);
|
||||||
}
|
}
|
||||||
byte[] data = new byte[size];
|
|
||||||
inputStream.readFully(data);
|
|
||||||
return new DataPacket(name, formatId, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user