An-DJ commented on code in PR #124:
URL: 
https://github.com/apache/apisix-go-plugin-runner/pull/124#discussion_r1057409696


##########
internal/util/msg.go:
##########
@@ -65,3 +66,27 @@ func WriteErr(n int, err error) {
                log.Errorf("write: %s", err)
        }
 }
+
+func ReadBytes(c net.Conn, b []byte, n int) (int, error) {
+       l := 0
+       for l < n {
+               tmp, err := c.Read(b[l:])
+               if err != nil {
+                       return l, err

Review Comment:
   The data in `b[l: l + tmp]` may be unreliable because the reading errror.



##########
internal/util/msg.go:
##########
@@ -65,3 +66,27 @@ func WriteErr(n int, err error) {
                log.Errorf("write: %s", err)
        }
 }
+
+func ReadBytes(c net.Conn, b []byte, n int) (int, error) {
+       l := 0
+       for l < n {
+               tmp, err := c.Read(b[l:])
+               if err != nil {
+                       return l, err
+               }
+               l += tmp
+       }
+       return l, nil
+}
+
+func WriteBytes(c net.Conn, b []byte, n int) (int, error) {
+       l := 0
+       for l < n {
+               tmp, err := c.Write(b[l:])
+               if err != nil {
+                       return l, err

Review Comment:
   Ditto



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to