ssntp: silence go race report in ssntp client
ssntp: silence go race report in ssntp client

Ssntp client.go threads call sync.WaitGroup functions which read
and write the client.frameWg data member.  The waitgroups themselves
intrinsically can be written and read from multiple contexts safely.
But that doesn't mean the counts are coherent.

It is possible that the Close() function starts to Wait() on the
waitgroup _just_ before a new frame comes in and calls Add(1).  Then
the wait is waiting on less than the intended count and can close the
client.frameRoutinesChannel which would result in a write to a
closed channel and a panic.  We're not hitting that panic, but that
potential is probably what is being noted by go-race (does go-race not
have a VERBOSE option?).

There already is a client.status variable that is toggled to ssntpClosed
state.  But it is only checked in the error path of the frame processor
not in the non-error path.  There's a slight gap there for a race, which
is then fixed by grabbing the client.status lock, checking for ssntpClosed
status and returning rather than doing the Add(1) and processing the new
frame (ie: discard frames that come just in the "closing" window).

This was observed in ciao-controller's TestDeleteInstance()
unit test when run with go-race.  That test no longer reports
error in go-race after the patch.

Signed-off-by: Tim Pepper <8dbd764830e941d092a1cb7fa16423169acc0b04@linux.intel.com>

kaccardi/ciao,wcwxyz/ciao,ciao-project/ciao,obedmr/ciao,mrkz/ciao,rbradford/ciao,mcastelino/ciao,wcwxyz/ciao,matthewrsj/ciao,erick0z/ciao,jorgevgut/ciao,leoswaldo/ciao,jorgevgut/ciao,mrkz/ciao,tpepper/ciao,matthewrsj/ciao,rbradford/ciao,leoswaldo/ciao,mcastelino/ciao,matthewrsj/ciao,obedmr/ciao,tpepper/ciao,mcastelino/ciao,obedmr/ciao,wcwxyz/ciao,jorgevgut/ciao,leoswaldo/ciao,erick0z/ciao,tpepper/ciao,01org/ciao,markdryan/ciao,markdryan/ciao,erick0z/ciao,ciao-project/ciao,kaccardi/ciao,01org/ciao,mrkz/ciao