Skip to content

Fix for mysql bug 74483/74933 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

colakong
Copy link

chunk = self.sock.recv(1)
if not chunk:
raise errors.InterfaceError(errno=2013)
packet += chunk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In typically case, sock.recv(4) returns 4 bytes.
Calling socket.recv() 4 times may drop performance significantly.

packet = b''
while len(packet) < 4:
    chunk = self.sock.recv(4-len(packet))
    if not chunk:
        raise errors.InterfaceError(errno=2013)
    packet += chunk

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense ^^

On Fri, Feb 20, 2015, 19:55 INADA Naoki notifications@github.com wrote:

In lib/mysql/connector/network.py
#4 (comment)
:

@@ -220,10 +220,12 @@ def recv_plain(self):
"""Receive packets from the MySQL server"""
try:
# Read the header of the MySQL packet, 4 bytes

  •        packet = bytearray(4)
    
  •        read = self.sock.recv_into(packet, 4)
    
  •        if read != 4:
    
  •            raise errors.InterfaceError(errno=2013)
    
  •        packet = bytearray()
    
  •        while len(packet) < 4:
    
  •            chunk = self.sock.recv(1)
    
  •            if not chunk:
    
  •                raise errors.InterfaceError(errno=2013)
    
  •            packet += chunk
    

In typically case, sock.recv(4) returns 4 bytes.
Calling socket.recv() 4 times may drop performance significantly.

packet = b''while len(packet) < 4:
chunk = self.sock.recv(4-len(packet))
if not chunk:
raise errors.InterfaceError(errno=2013)
packet += chunk


Reply to this email directly or view it on GitHub
https://github.com/mysql/mysql-connector-python/pull/4/files#r25119048.

@mysql-oca-bot
Copy link

Hi, thank you for filing this request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at http://www.oracle.com/technetwork/community/oca-486395.html
Thanks

@colakong
Copy link
Author

FYI, this contribution is under OCA ^^

@mysql-admin
Copy link

Hi colakong,
Unfortunately we cannot accept this contribution as it includes code from other parties and therefor not covered by your signed OCA (see section 5 of the OCA agreement).
Thanks for your suggestion.
==Omer

@mysql-admin mysql-admin closed this May 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants