Skip to content

Query may fail on Windows (driver: bad connection) [moved] #2

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
julienschmidt opened this issue Jan 5, 2013 · 0 comments
Closed
Milestone

Comments

@julienschmidt
Copy link
Member

This is Issue 2 moved from a Google Code project.
Added by 2012-05-21T08:15:55.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Defect, Priority-High, OpSys-Windows

Original description

<b>What steps will reproduce the problem?</b>
1. on Windows
2. Query
<b>3.</b>

<b>What is the expected output? What do you see instead?</b>
expected output: success
actual output: driver: bad connection



<b>What version of the product are you using? On what operating system?</b>


<b>Please provide any additional information below.</b>
Suggested fix:
line 52 of packets.go
    n, e := mc.netconn.Read(data)
    if e != nil || n != int(pktLen) {
        e = driver.ErrBadConn
    }
Here, we assume Read only return when the data is filled. But at least on Go Windows version, it will return prematurely.

So maybe we can change the code to
   n, e := mc.netconn.Read(data)
   na := 0
   for e == nil && n < int(pktLen) {
       na, e = mc.netconn.Read(data[n:])
       n += na
   }

I've verified it on Windows, it works.     
arnehormann pushed a commit that referenced this issue Jan 7, 2016
Pull recent changes from the main fork
julienschmidt pushed a commit that referenced this issue May 31, 2017
* add RejectReadOnly

* update README.md

* close connection explicitly before returning ErrBadConn for 1792 (#2)

* add test and improve doc

* doc/comment changes
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

No branches or pull requests

1 participant