Skip to content

Commit

Permalink
Merge pull request #41 from renukamanavalan/statistics
Browse files Browse the repository at this point in the history
Events client: Ensure all go routines exit upon client disconnect.
  • Loading branch information
renukamanavalan authored Sep 8, 2022
2 parents e89b594 + cb3df3b commit 14f9121
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit 14f9121

Please sign in to comment.