Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events client: Ensure all go routines exit upon client disconnect. #41

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sonic_data_client/events_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func compute_latency(evtc *EventClient) {
}

func update_stats(evtc *EventClient) {
defer evtc.wg.Done()

/* Wait for any update */
db_counters := make(map[string]uint64)
var wr_counters *map[string]uint64 = nil
Expand Down Expand Up @@ -259,6 +261,8 @@ func C_deinit_subs(h unsafe.Pointer) {
}

func get_events(evtc *EventClient) {
defer evtc.wg.Done()

str_ptr := C.malloc(C.sizeof_char * C.size_t(EVENT_BUFFSZ))
defer C.free(unsafe.Pointer(str_ptr))

Expand Down Expand Up @@ -326,7 +330,9 @@ func (evtc *EventClient) StreamRun(q *queue.PriorityQueue, stop chan struct{}, w
evtc.channel = stop

go get_events(evtc)
evtc.wg.Add(1)
go update_stats(evtc)
evtc.wg.Add(1)

for {
select {
Expand Down