1
0
mirror of https://github.com/golang/go synced 2024-11-24 05:20:04 -07:00

undo changes accidentally included in 09c5add99d50

R=ken2
CC=golang-dev
https://golang.org/cl/1736042
This commit is contained in:
Russ Cox 2010-06-20 12:45:39 -07:00
parent 45bdf0367e
commit 1b79cd2e71
7 changed files with 22 additions and 37 deletions

View File

@ -724,8 +724,10 @@ sub RunWeb {
"firefox",
);
foreach my $b (@alt) {
if (system($b, $fname) == 0) {
return;
if (-f $b) {
if (system($b, $fname) == 0) {
return;
}
}
}

View File

@ -14,7 +14,6 @@ import (
"image"
"io"
"os"
"strconv"
)
// Color type, as per the PNG spec.
@ -109,7 +108,7 @@ func (d *decoder) parseIHDR(r io.Reader, crc hash.Hash32, length uint32) os.Erro
}
crc.Write(d.tmp[0:13])
if d.tmp[8] != 8 {
return UnsupportedError("bit depth " + strconv.Itoa(int(d.tmp[8])))
return UnsupportedError("bit depth")
}
if d.tmp[10] != 0 || d.tmp[11] != 0 || d.tmp[12] != 0 {
return UnsupportedError("compression, filter or interlace method")

View File

@ -93,13 +93,7 @@ func (client *Client) input() {
c := client.pending[seq]
client.pending[seq] = c, false
client.mutex.Unlock()
if c == nil {
err = os.NewError("invalid response sequence number")
break
}
err = client.codec.ReadResponseBody(c.Reply)
// TODO(rsc): Should look at err, but breaks tests.
// Empty strings should turn into nil os.Errors
if response.Error != "" {
c.Error = os.ErrorString(response.Error)

View File

@ -58,8 +58,7 @@ func TestServer(t *testing.T) {
cli, srv := net.Pipe()
defer cli.Close()
var ci rpc.ClientInfo
go ServeConn(srv, &ci)
go ServeConn(srv)
dec := json.NewDecoder(cli)
// Send hand-coded requests to server, parse responses.
@ -85,9 +84,8 @@ func TestServer(t *testing.T) {
func TestClient(t *testing.T) {
// Assume server is okay (TestServer is above).
// Test client against server.
var ci rpc.ClientInfo
cli, srv := net.Pipe()
go ServeConn(srv, &ci)
go ServeConn(srv)
client := NewClient(cli)
defer client.Close()

View File

@ -118,6 +118,6 @@ func (c *serverCodec) Close() os.Error {
// ServeConn runs the JSON-RPC server on a single connection.
// ServeConn blocks, serving the connection until the client hangs up.
// The caller typically invokes ServeConn in a go statement.
func ServeConn(conn io.ReadWriteCloser, ci *rpc.ClientInfo) {
rpc.ServeCodec(NewServerCodec(conn), ci)
func ServeConn(conn io.ReadWriteCloser) {
rpc.ServeCodec(NewServerCodec(conn))
}

View File

@ -214,7 +214,7 @@ func (server *serverType) register(rcvr interface{}) os.Error {
}
// Method needs three ins: receiver, *args, *reply.
// The args and reply must be structs until gobs are more general.
if mtype.NumIn() != 3 && mtype.NumIn() != 4 {
if mtype.NumIn() != 3 {
log.Stderr("method", mname, "has wrong number of ins:", mtype.NumIn())
continue
}
@ -301,19 +301,13 @@ func sendResponse(sending *sync.Mutex, req *Request, reply interface{}, codec Se
sending.Unlock()
}
func (s *service) call(sending *sync.Mutex, mtype *methodType, req *Request, argv, replyv reflect.Value, codec ServerCodec, ci *ClientInfo) {
func (s *service) call(sending *sync.Mutex, mtype *methodType, req *Request, argv, replyv reflect.Value, codec ServerCodec) {
mtype.Lock()
mtype.numCalls++
mtype.Unlock()
function := mtype.method.Func
// Invoke the method, providing a new value for the reply.
var args []reflect.Value
if mtype.method.Type.NumIn() == 3 {
args = []reflect.Value{s.rcvr, argv, replyv}
} else {
args = []reflect.Value{s.rcvr, argv, replyv, reflect.NewValue(ci)}
}
returnValues := function.Call(args)
returnValues := function.Call([]reflect.Value{s.rcvr, argv, replyv})
// The return value for the method is an os.Error.
errInter := returnValues[0].Interface()
errmsg := ""
@ -348,7 +342,7 @@ func (c *gobServerCodec) Close() os.Error {
return c.rwc.Close()
}
func (server *serverType) input(codec ServerCodec, ci *ClientInfo) {
func (server *serverType) input(codec ServerCodec) {
sending := new(sync.Mutex)
for {
// Grab the request header.
@ -395,7 +389,7 @@ func (server *serverType) input(codec ServerCodec, ci *ClientInfo) {
sendResponse(sending, req, replyv.Interface(), codec, err.String())
break
}
go service.call(sending, mtype, req, argv, replyv, codec, ci)
go service.call(sending, mtype, req, argv, replyv, codec)
}
codec.Close()
}
@ -406,7 +400,7 @@ func (server *serverType) accept(lis net.Listener) {
if err != nil {
log.Exit("rpc.Serve: accept:", err.String()) // TODO(r): exit?
}
go ServeConn(conn, &ClientInfo{conn.LocalAddr().String(), conn.RemoteAddr().String()})
go ServeConn(conn)
}
}
@ -438,14 +432,14 @@ type ServerCodec interface {
// The caller typically invokes ServeConn in a go statement.
// ServeConn uses the gob wire format (see package gob) on the
// connection. To use an alternate codec, use ServeCodec.
func ServeConn(conn io.ReadWriteCloser, ci *ClientInfo) {
ServeCodec(&gobServerCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(conn)}, ci)
func ServeConn(conn io.ReadWriteCloser) {
ServeCodec(&gobServerCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(conn)})
}
// ServeCodec is like ServeConn but uses the specified codec to
// decode requests and encode responses.
func ServeCodec(codec ServerCodec, ci *ClientInfo) {
server.input(codec, ci)
func ServeCodec(codec ServerCodec) {
server.input(codec)
}
// Accept accepts connections on the listener and serves requests
@ -471,11 +465,7 @@ func serveHTTP(c *http.Conn, req *http.Request) {
return
}
io.WriteString(conn, "HTTP/1.0 "+connected+"\n\n")
ci := &ClientInfo{
LocalAddr: conn.(net.Conn).LocalAddr().String(),
RemoteAddr: c.RemoteAddr,
}
ServeConn(conn, ci)
ServeConn(conn)
}
// HandleHTTP registers an HTTP handler for RPC messages.

View File

@ -48,6 +48,7 @@
# ./gc.go
# ./gc1.go
./hashmap.go
./hilbert.go
./helloworld.go
./if.go
./if1.go
@ -331,6 +332,7 @@ fixedbugs/bug149.go
fixedbugs/bug150.go
fixedbugs/bug151.go
fixedbugs/bug152.go
fixedbugs/bug153.go
# fixedbugs/bug154.go # needs floating point
fixedbugs/bug155.go
fixedbugs/bug156.go