diff options
author | Determinant <[email protected]> | 2019-06-11 20:14:51 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-11 20:14:51 -0400 |
commit | 40d830a4a3e225ea8819251c7c87a66eab0d46d0 (patch) | |
tree | fadd94d4d92049712bb94fd1a5bd82bba60c78ed | |
parent | 13630c375090079bbfb5129c4adcd53e04e19dd9 (diff) |
fix conn bug
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | network.go | 7 | ||||
m--------- | salticidae | 0 | ||||
-rw-r--r-- | test_p2p_stress/main.go | 3 |
4 files changed, 11 insertions, 3 deletions
@@ -9,7 +9,7 @@ salticidae/libsalticidae.so: build: mkdir -p build -build/test_msgnet: salticidae/libsalticidae.so +build/test_msgnet: salticidae/libsalticidae.so test_msgnet/main.go go build -o $@ salticidae-go/test_msgnet -build/test_p2p_stress: salticidae/libsalticidae.so +build/test_p2p_stress: salticidae/libsalticidae.so test_p2p_stress/main.go go build -o $@ salticidae-go/test_p2p_stress @@ -70,6 +70,9 @@ func (self MsgNetwork) SendMsg(msg Msg, conn MsgNetworkConn) { C.msgnetwork_send func (self MsgNetwork) Connect(addr NetAddr) { C.msgnetwork_connect(self, addr) } func (self MsgNetwork) Terminate(conn MsgNetworkConn) { C.msgnetwork_terminate(self, conn) } +func (self MsgNetworkConn) Copy() MsgNetworkConn { return C.msgnetwork_conn_copy(self) } +func (self MsgNetworkConn) Free() { C.msgnetwork_conn_free(self) } + type MsgNetworkMsgCallback = C.msgnetwork_msg_callback_t type MsgNetworkConnCallback = C.msgnetwork_conn_callback_t @@ -134,6 +137,10 @@ func (self PeerNetwork) AsMsgNetwork() MsgNetwork { return C.peernetwork_as_msgn func NewMsgNetworkConnFromPeerNetWorkConn(conn PeerNetworkConn) MsgNetworkConn { return C.msgnetwork_conn_new_from_peernetwork_conn(conn) } +func (self PeerNetworkConn) Copy() PeerNetworkConn { return C.peernetwork_conn_copy(self) } + +func (self PeerNetworkConn) Free() { C.peernetwork_conn_free(self) } + func (self PeerNetwork) SendMsgByMove(_moved_msg Msg, paddr NetAddr) { C.peernetwork_send_msg_by_move(self, _moved_msg, paddr) } func (self PeerNetwork) MulticastMsgByMove(_moved_msg Msg, paddrs []NetAddr) { diff --git a/salticidae b/salticidae -Subproject a936ace0aacc0319587eff5c23325e27b647680 +Subproject edc6e299727098c499fd1edae145a0462fee780 diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index ed671fc..ff7bd47 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -194,9 +194,10 @@ func onReceiveAck(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userd ctx := C.timeout_callback_context_new() ctx.app_id = C.int(id) ctx.addr_id = C.uint64_t(addr) - ctx.conn = (*C.struct_msgnetwork_conn_t)(conn) + ctx.conn = (*C.struct_msgnetwork_conn_t)(conn.Copy()) if tc.timer != nil { tc.timer.Free() + salticidae.MsgNetworkConn(tc.timer_ctx.conn).Free() C.free(unsafe.Pointer(tc.timer_ctx)) } tc.timer = salticidae.NewTimerEvent(app.ec, salticidae.TimerEventCallback(C.onTimeout), unsafe.Pointer(ctx)) |