worryg0d commented on code in PR #1822:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1822#discussion_r1808705368


##########
conn.go:
##########
@@ -1756,6 +1888,41 @@ func (c *Conn) awaitSchemaAgreement(ctx context.Context) 
(err error) {
        return fmt.Errorf("gocql: cluster schema versions not consistent: %+v", 
schemas)
 }
 
+// recvLastsFrames reads proto v5 frames from Conn.r and writes decoded 
payload to dst.
+// It reads data until the bytesToRead is reached.
+// If Conn.compressor is not nil, it processes Compressed Format frames.
+func (c *Conn) recvLastsFrames(dst *bytes.Buffer, bytesToRead int) error {
+       var read int
+       var segment []byte
+       var err error
+       for read != bytesToRead {
+               // Read frame based on compression
+               if c.compressor != nil {
+                       segment, _, err = readCompressedFrame(c.r, c.compressor)
+               } else {
+                       segment, _, err = readUncompressedFrame(c.r)
+               }
+               if err != nil {
+                       return fmt.Errorf("gocql: failed to read non 
self-contained frame: %w", err)
+               }
+
+               // Write the segment to the destination writer
+               n, _ := dst.Write(segment)
+               read += n

Review Comment:
   Yeah, it kinda makes sense to check if we're writing as much data as 
expected. Added a check for this too.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to