aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--network.go7
m---------salticidae0
-rw-r--r--test_p2p_stress/main.go3
4 files changed, 11 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 8a83718..06e1338 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/network.go b/network.go
index c8fae40..10ab26c 100644
--- a/network.go
+++ b/network.go
@@ -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))