Skip to content

Commit c7d0124

Browse files
dependabot[bot]iphydf
authored andcommitted
Bump github.com/sasha-s/go-deadlock from 0.2.0 to 0.3.1
Bumps [github.com/sasha-s/go-deadlock](https://github.com/sasha-s/go-deadlock) from 0.2.0 to 0.3.1. - [Release notes](https://github.com/sasha-s/go-deadlock/releases) - [Commits](sasha-s/go-deadlock@v0.2.0...v0.3.1) --- updated-dependencies: - dependency-name: github.com/sasha-s/go-deadlock dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent ac58790 commit c7d0124

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

.cirrus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
cirrus-ci_task:
33
container:
4-
image: toxchat/toktok-stack:0.0.27-third_party
4+
image: toxchat/toktok-stack:0.0.31-third_party
55
cpu: 2
66
memory: 4G
77
configure_script:

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/TokTok/go-toxcore-c
33
go 1.12
44

55
require (
6-
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
7-
github.com/sasha-s/go-deadlock v0.2.0
6+
github.com/sasha-s/go-deadlock v0.3.1
87
github.com/streamrail/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6
98
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
22
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
3-
github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y=
4-
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
3+
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
4+
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
55
github.com/streamrail/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6 h1:XklXvOrWxWCDX2n4vdEQWkjuIP820XD6C4kF0O0FzH4=
66
github.com/streamrail/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6/go.mod h1:yqDD2twFAqxvvH5gtpwwgLsj5L1kbNwtoPoDOwBzXcs=

tox.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type cb_file_chunk_request_ftype func(this *Tox, friend_number uint32, file_numb
7676
type Tox struct {
7777
opts *ToxOptions
7878
toxcore *C.Tox // save C.Tox
79+
Killed bool
7980
threadSafe bool
8081
mu deadlock.RWMutex
8182
// mu sync.RWMutex
@@ -527,6 +528,7 @@ func (this *Tox) Kill() {
527528
cbUserDatas.del(this.toxcore)
528529
C.tox_kill(this.toxcore)
529530
this.toxcore = nil
531+
this.Killed = true
530532
}
531533

532534
// uint32_t tox_iteration_interval(Tox *tox);
@@ -543,6 +545,12 @@ func (this *Tox) IterationInterval() int {
543545
// compatable with legacy version
544546
func (this *Tox) Iterate() {
545547
this.lock()
548+
if this.Killed {
549+
log.Panic("Tox was already killed")
550+
}
551+
if this.toxcore == nil {
552+
log.Panic("toxcore became nil")
553+
}
546554
C.tox_iterate(this.toxcore, nil)
547555
cbevts := this.cbevts
548556
this.cbevts = nil
@@ -554,6 +562,9 @@ func (this *Tox) Iterate() {
554562
// for toktok new method
555563
func (this *Tox) Iterate2(userData interface{}) {
556564
this.lock()
565+
if this.toxcore == nil {
566+
log.Panic("toxcore became nil")
567+
}
557568
this.cb_iterate_data = userData
558569
C.tox_iterate(this.toxcore, nil)
559570
this.cb_iterate_data = nil

tox_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,16 @@ func TestCommunication(t *testing.T) {
914914
opts.ThreadSafe = true
915915
opts.Tcp_port = 34567
916916
_t1 := NewTox(opts)
917+
if _t1 == nil {
918+
t.Error("NewTox failed")
919+
}
920+
defer _t1.Kill()
917921
log.Println(_t1)
918922
go func() {
919923
for {
924+
if _t1.Killed {
925+
return
926+
}
920927
_t1.Iterate()
921928
time.Sleep(100 * time.Millisecond)
922929
}
@@ -926,12 +933,19 @@ func TestCommunication(t *testing.T) {
926933
opts2.ThreadSafe = true
927934
opts2.Tcp_port = 34568
928935
_t2 := NewTox(opts2)
936+
if _t2 == nil {
937+
t.Error("NewTox failed")
938+
}
939+
defer _t2.Kill()
929940
log.Println(_t2)
930941
_t2.CallbackGroupInviteAdd(func(_ *Tox, friendNumber uint32, itype uint8, data string, userData interface{}) {
931942
log.Println(friendNumber, itype)
932943
}, nil)
933944
go func() {
934945
for {
946+
if _t2.Killed {
947+
return
948+
}
935949
_t2.Iterate()
936950
time.Sleep(100 * time.Millisecond)
937951
}

toxav.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func callbackAudioForC(m *C.Tox, groupnumber C.uint32_t, peernumber C.uint32_t,
316316
}
317317

318318
func (this *Tox) AddAVGroupChat(cbfn cb_audio_ftype) uint32 {
319-
r := C.toxav_add_av_groupchat(this.toxcore, (*[0]byte)(unsafe.Pointer(C.callbackAudioForC)), nil)
319+
r := C.toxav_add_av_groupchat(this.toxcore, (*C.toxav_audio_data_cb)(unsafe.Pointer(C.callbackAudioForC)), nil)
320320
if cbfn != nil {
321321
this.cb_audios[uint32(r)] = cbfn
322322
}
@@ -335,7 +335,7 @@ func (this *Tox) JoinAVGroupChat(friendNumber uint32, cookie string, cbfn cb_aud
335335
var _length = C.uint16_t(length)
336336

337337
r := C.toxav_join_av_groupchat(this.toxcore, _fn, _data, _length,
338-
(*[0]byte)(unsafe.Pointer(C.callbackAudioForC)), nil)
338+
(*C.toxav_audio_data_cb)(unsafe.Pointer(C.callbackAudioForC)), nil)
339339
if int(r) == -1 {
340340
return uint32(r), errors.New("Join av group chat failed")
341341
}

0 commit comments

Comments
 (0)