From 66914cd88bd822d3399e754f43a42906c043f1fd Mon Sep 17 00:00:00 2001 From: Determinant Date: Sat, 22 Jun 2019 01:45:37 -0400 Subject: support TLS; change some API --- test_p2p_stress/main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'test_p2p_stress') diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index 9e0757f..69f9d6c 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -240,6 +240,7 @@ func onTerm(_ C.int, _ unsafe.Pointer) { func main() { ec = salticidae.NewEventContext() + err := salticidae.NewError() var addrs []salticidae.NetAddr for i := 0; i < 5; i++ { @@ -256,22 +257,23 @@ func main() { ids = make([](*C.int), len(addrs)) for i, addr := range addrs { ec := salticidae.NewEventContext() + net := salticidae.NewPeerNetwork(ec, netconfig, &err); checkError(&err) apps[i] = AppContext { addr: addr, ec: ec, - net: salticidae.NewPeerNetwork(ec, netconfig), + net: net, tcall: salticidae.NewThreadCall(ec), tc: make(map[uint64] *TestContext), } ids[i] = (*C.int)(C.malloc(C.sizeof_int)) *ids[i] = C.int(i) _i := unsafe.Pointer(ids[i]) - net := apps[i].net.AsMsgNetwork() - net.RegHandler(MSG_OPCODE_RAND, salticidae.MsgNetworkMsgCallback(C.onReceiveRand), _i) - net.RegHandler(MSG_OPCODE_ACK, salticidae.MsgNetworkMsgCallback(C.onReceiveAck), _i) - net.RegConnHandler(salticidae.MsgNetworkConnCallback(C.connHandler), _i) - net.RegErrorHandler(salticidae.MsgNetworkErrorCallback(C.errorHandler), _i) - net.Start() + mnet := net.AsMsgNetwork() + mnet.RegHandler(MSG_OPCODE_RAND, salticidae.MsgNetworkMsgCallback(C.onReceiveRand), _i) + mnet.RegHandler(MSG_OPCODE_ACK, salticidae.MsgNetworkMsgCallback(C.onReceiveAck), _i) + mnet.RegConnHandler(salticidae.MsgNetworkConnCallback(C.connHandler), _i) + mnet.RegErrorHandler(salticidae.MsgNetworkErrorCallback(C.errorHandler), _i) + mnet.Start() } threads.Add(len(apps)) @@ -280,7 +282,7 @@ func main() { go func() { err := salticidae.NewError() a := &apps[app_id] - a.net.Listen(a.addr, &err) + a.net.Listen(a.addr, &err); checkError(&err) for _, addr := range addrs { if !addr.IsEq(a.addr) { a.net.AddPeer(addr) -- cgit v1.2.3-70-g09d2