You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2020/09/17 13:20:14 UTC

[GitHub] [mina-sshd] lgoldstein commented on a change in pull request #169: [SSHD-1080] Rework the PacketWriter to split according to the various…

lgoldstein commented on a change in pull request #169:
URL: https://github.com/apache/mina-sshd/pull/169#discussion_r490234496



##########
File path: sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
##########
@@ -254,6 +253,46 @@ protected AbstractSession(
         }
     }
 
+    /**
+     * @param  len       The packet payload size
+     * @param  blockSize The cipher block size
+     * @param  etmMode   Whether using &quot;encrypt-then-MAC&quot; mode
+     * @return           The required padding length
+     */
+    protected static int calculatePadLength(int len, int blockSize, boolean etmMode) {

Review comment:
       Let's make it public - even though used only by sessions - perhaps someone else (not our code) uses it.

##########
File path: sshd-common/src/main/java/org/apache/sshd/common/io/IoSession.java
##########
@@ -82,6 +84,27 @@
      */
     Object removeAttribute(Object key);
 
+    /**
+     * Write a packet on the socket. Multiple writes can be issued concurrently and will be queued.
+     *
+     * @param  buffer      the buffer send. <B>NOTE:</B> the buffer must not be touched until the returned write future
+     *                     is completed.
+     * @return             An {@code IoWriteFuture} that can be used to check when the packet has actually been sent
+     * @throws IOException if an error occurred when sending the packet
+     */
+    IoWriteFuture writePacket(Buffer buffer) throws IOException;
+
+    /**
+     * Closes this session immediately or after all queued write requests are flushed. This operation is asynchronous.
+     * Wait for the returned {@link CloseFuture} if you want to wait for the session actually closed.
+     *
+     * @param  immediately {@code true} to close this session immediately. The pending write requests will simply be
+     *                     discarded. {@code false} to close this session after all queued write requests are flushed.
+     * @return             The generated {@link CloseFuture}
+     */
+    @Override
+    CloseFuture close(boolean immediately);
+

Review comment:
       Why is this override required ? Isn't the method inherited from `Closeable` enough?

##########
File path: sshd-core/src/main/java/org/apache/sshd/common/channel/throttle/DefaultChannelStreamWriter.java
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.channel.throttle;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.io.IoWriteFuture;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+public class DefaultChannelStreamWriter implements ChannelStreamWriter {

Review comment:
       Missing standard javadoc comment - I think _checkstyle_ will complain

##########
File path: sshd-core/src/main/java/org/apache/sshd/common/channel/throttle/DefaultChannelStreamWriter.java
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.channel.throttle;
+
+import java.io.IOException;
+
+import org.apache.sshd.common.channel.Channel;
+import org.apache.sshd.common.io.IoWriteFuture;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+public class DefaultChannelStreamWriter implements ChannelStreamWriter {
+
+    private final Channel channel;

Review comment:
       Let's make it `protected` in case someone wants to use it as a base class for something




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org