Commit 59e79dd7 authored by Kirill Smelkov's avatar Kirill Smelkov

X net: Polish

parent 29170dee
......@@ -29,7 +29,7 @@ import (
// Networker is interface representing access-point to a streaming network
type Networker interface {
// Network returns name of the network XXX recheck
// Network returns name of the network
Network() string
// XXX +Addr() net.Addr -> address of this access-point on underlying network ?
......
......@@ -127,22 +127,15 @@ type dialReq struct {
// ----------------------------------------
// FIXME temp for testing
//trace:event traceNew(name string)
// New creates new pipenet Network
//
// name is name of this network under "pipe" namespace, e.g. "α" will give full network name "pipeα".
//
// New does not check whether network name provided is unique.
func New(name string) *Network {
traceNew(name)
return &Network{name: name, hostMap: make(map[string]*Host)}
}
//XXX temp
//trace:event traceNewHost(host *Host)
// Host returns network access point by name
//
// If there was no such host before it creates new one.
......@@ -154,7 +147,6 @@ func (n *Network) Host(name string) *Host {
if host == nil {
host = &Host{network: n, name: name}
n.hostMap[name] = host
traceNewHost(host)
}
return host
......@@ -181,16 +173,12 @@ func (h *Host) resolveAddr(addr string) (host *Host, port int, err error) {
return host, a.Port, nil
}
// XXX temp
//trace:event traceListen(laddr string)
// Listen starts new listener
//
// It either allocates free port if laddr is "" or with 0 port, or binds to laddr.
// Once listener is started, Dials could connect to listening address.
// Connection requests created by Dials could be accepted via Accept.
func (h *Host) Listen(laddr string) (net.Listener, error) {
traceListen(laddr)
h.network.mu.Lock()
defer h.network.mu.Unlock()
......@@ -267,9 +255,6 @@ func (l *listener) Close() error {
return nil
}
// XXX temp
//trace:event traceAccept(conn net.Conn)
// Accept tries to connect to Dial called with addr corresponding to our listener
func (l *listener) Accept() (net.Conn, error) {
h := l.socket.host
......@@ -294,19 +279,14 @@ func (l *listener) Accept() (net.Conn, error) {
n.mu.Unlock()
req.resp <- skc.conn
traceAccept(sks.conn)
return sks.conn, nil
}
}
// XXX temp
//trace:event traceDial(addr string)
// Dial dials address on the network
//
// It tries to connect to Accept called on listener corresponding to addr.
func (h *Host) Dial(ctx context.Context, addr string) (net.Conn, error) {
traceDial(addr)
var netaddr net.Addr
derr := func(err error) error {
return &net.OpError{Op: "dial", Net: h.Network(), Addr: netaddr, Err: err}
......
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
package pipenet
// code generated for tracepoints
import (
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
"net"
)
// traceevent: traceAccept(conn net.Conn)
type _t_traceAccept struct {
tracing.Probe
probefunc func(conn net.Conn)
}
var _traceAccept *_t_traceAccept
func traceAccept(conn net.Conn) {
if _traceAccept != nil {
_traceAccept_run(conn)
}
}
func _traceAccept_run(conn net.Conn) {
for p := _traceAccept; p != nil; p = (*_t_traceAccept)(unsafe.Pointer(p.Next())) {
p.probefunc(conn)
}
}
func traceAccept_Attach(pg *tracing.ProbeGroup, probe func(conn net.Conn)) *tracing.Probe {
p := _t_traceAccept{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceAccept)), &p.Probe)
return &p.Probe
}
// traceevent: traceDial(addr string)
type _t_traceDial struct {
tracing.Probe
probefunc func(addr string)
}
var _traceDial *_t_traceDial
func traceDial(addr string) {
if _traceDial != nil {
_traceDial_run(addr)
}
}
func _traceDial_run(addr string) {
for p := _traceDial; p != nil; p = (*_t_traceDial)(unsafe.Pointer(p.Next())) {
p.probefunc(addr)
}
}
func traceDial_Attach(pg *tracing.ProbeGroup, probe func(addr string)) *tracing.Probe {
p := _t_traceDial{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceDial)), &p.Probe)
return &p.Probe
}
// traceevent: traceListen(laddr string)
type _t_traceListen struct {
tracing.Probe
probefunc func(laddr string)
}
var _traceListen *_t_traceListen
func traceListen(laddr string) {
if _traceListen != nil {
_traceListen_run(laddr)
}
}
func _traceListen_run(laddr string) {
for p := _traceListen; p != nil; p = (*_t_traceListen)(unsafe.Pointer(p.Next())) {
p.probefunc(laddr)
}
}
func traceListen_Attach(pg *tracing.ProbeGroup, probe func(laddr string)) *tracing.Probe {
p := _t_traceListen{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceListen)), &p.Probe)
return &p.Probe
}
// traceevent: traceNew(name string)
type _t_traceNew struct {
tracing.Probe
probefunc func(name string)
}
var _traceNew *_t_traceNew
func traceNew(name string) {
if _traceNew != nil {
_traceNew_run(name)
}
}
func _traceNew_run(name string) {
for p := _traceNew; p != nil; p = (*_t_traceNew)(unsafe.Pointer(p.Next())) {
p.probefunc(name)
}
}
func traceNew_Attach(pg *tracing.ProbeGroup, probe func(name string)) *tracing.Probe {
p := _t_traceNew{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceNew)), &p.Probe)
return &p.Probe
}
// traceevent: traceNewHost(host *Host)
type _t_traceNewHost struct {
tracing.Probe
probefunc func(host *Host)
}
var _traceNewHost *_t_traceNewHost
func traceNewHost(host *Host) {
if _traceNewHost != nil {
_traceNewHost_run(host)
}
}
func _traceNewHost_run(host *Host) {
for p := _traceNewHost; p != nil; p = (*_t_traceNewHost)(unsafe.Pointer(p.Next())) {
p.probefunc(host)
}
}
func traceNewHost_Attach(pg *tracing.ProbeGroup, probe func(host *Host)) *tracing.Probe {
p := _t_traceNewHost{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceNewHost)), &p.Probe)
return &p.Probe
}
// trace export signature
func _trace_exporthash_e77a134646e20f099af466ab3192282237d2e547() {}
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