Commit 81efe5bd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9f51b6d7
...@@ -101,6 +101,7 @@ type socket struct { ...@@ -101,6 +101,7 @@ type socket struct {
// conn represents one endpoint of connection created under Network // conn represents one endpoint of connection created under Network
type conn struct { type conn struct {
socket *socket socket *socket
peersk *socket // the other side of this connection
net.Conn net.Conn
...@@ -268,8 +269,8 @@ func (l *listener) Accept() (net.Conn, error) { ...@@ -268,8 +269,8 @@ func (l *listener) Accept() (net.Conn, error) {
skc := req.from.allocFreeSocket() skc := req.from.allocFreeSocket()
sks := h.allocFreeSocket() sks := h.allocFreeSocket()
skc.conn = &conn{socket: skc, Conn: pc} skc.conn = &conn{socket: skc, peersk: sks, Conn: pc}
sks.conn = &conn{socket: sks, Conn: ps} sks.conn = &conn{socket: sks, peersk: skc, Conn: ps}
n.mu.Unlock() n.mu.Unlock()
...@@ -338,8 +339,7 @@ func (c *conn) Close() (err error) { ...@@ -338,8 +339,7 @@ func (c *conn) Close() (err error) {
n.mu.Lock() n.mu.Lock()
defer n.mu.Unlock() defer n.mu.Unlock()
h.socketv[sk.port] = nil sk.conn = nil
if sk.empty() { if sk.empty() {
h.socketv[sk.port] = nil h.socketv[sk.port] = nil
} }
...@@ -355,7 +355,7 @@ func (c *conn) LocalAddr() net.Addr { ...@@ -355,7 +355,7 @@ func (c *conn) LocalAddr() net.Addr {
// RemoteAddr returns address of remote end of connection // RemoteAddr returns address of remote end of connection
func (c *conn) RemoteAddr() net.Addr { func (c *conn) RemoteAddr() net.Addr {
return c.socket.addr() // FIXME -> must be addr of remote socket return c.peersk.addr()
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment