gostor / gotgt

Simple Golang iSCSI Target framework
Apache License 2.0
261 stars 49 forks source link

fix(stats): concurrent map iteration and map write #104

Closed payes closed 3 years ago

payes commented 3 years ago

This PR adds a lock to protect SCSIIOCount map from being updated and iterated at the same time. The caller of Stats() func might be iterating the SCSIIOCount map while the IOs are going on, which leads to a crash.

reflect.mapiternext(0xc004a9ae40)                                                                                 
runtime.throw(0xb06e45, 0x26)                                                                                     
fatal error: concurrent map iteration and map write

Signed-off-by: Payes Anand payes.anand@mayadata.io

carmark commented 3 years ago

Thanks @payes @utkarshmani1997