Skip to content
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

net: Close doesn't quite work for fcgi on win32 with nginx #3710

Closed
gopherbot opened this issue Jun 7, 2012 · 7 comments
Closed

net: Close doesn't quite work for fcgi on win32 with nginx #3710

gopherbot opened this issue Jun 7, 2012 · 7 comments
Milestone

Comments

@gopherbot
Copy link

by miepian:

1.config nginx,add below to server section:

    location ~ /app.* {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            include        fastcgi_params;
    }

2.a simple fcgi go program from
'http://www.geekm.ag/Archive/Writing_web_apps_with_Go,_Nginx_and_FastCGI':

package main

import (
    "log"
    "fmt"
    "net"
    "net/http"
    "net/http/fcgi"
)

type FastCGIServer struct{}
func (s FastCGIServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    w.Write([]byte("This is an example server.\n"))
}

func main() {
    fmt.Printf("Starting server")
    l, _ := net.Listen("tcp", "127.0.0.1:9000")
    b := new(FastCGIServer)
    fcgi.Serve(l, b)
}

compile and run the go program,starting nginx,open browser,go to "
http://127.0.0.1/app";,there is no response,and found nginx error log :

(10054: An existing connection was forcibly closed by the remote host)

but on ubuntu 12.04 every thing is ok
@alexbrainman
Copy link
Member

Comment 1:

I do not want to start new net discussion :-), but if I change hg id e69400ace361 as
diff -r e69400ace361 src/pkg/net/http/fcgi/fcgi.go
--- a/src/pkg/net/http/fcgi/fcgi.go Thu Jun 07 03:06:40 2012 -0400
+++ b/src/pkg/net/http/fcgi/fcgi.go Fri Jun 08 16:24:24 2012 +1000
@@ -17,6 +17,7 @@
    "errors"
    "io"
    "sync"
+   "net"
 )
 
 // recType is a record type, as defined by
@@ -113,7 +114,7 @@
 func (c *conn) Close() error {
    c.mutex.Lock()
    defer c.mutex.Unlock()
-   return c.rwc.Close()
+   return c.rwc.(*net.TCPConn).CloseWrite()
 }
 
 type record struct {
it works. It is certainly a case where it is left here, but didn't arrive there.
Alex

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 2 by hashysh:

This bug is also on win64 go 1.02.

@edsrzf
Copy link

edsrzf commented Jul 24, 2012

Comment 3:

I'll look at this pretty soon if no one beats me to it.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 5:

Labels changed: added go1.1.

@alexbrainman
Copy link
Member

Comment 6:

http://golang.org/cl/6604072

Owner changed to @alexbrainman.

Status changed to Started.

@alexbrainman
Copy link
Member

Comment 7:

This issue was closed by revision fa3e4fc.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants