google / seesaw

Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.
Apache License 2.0
5.63k stars 511 forks source link

Avoiding offending the cgo runtime pointer check. #29

Closed baptr closed 7 years ago

baptr commented 7 years ago

We need to let libnl hold our callback identifier (just a numeric map key), passed as a C void. cgo expects C void params's to get Go unsafe.Pointer args, but does a runtime check to see if the value points at another Go pointer.

By adding a C-side wrapper with a pure numeric signature, we no longer have to use unsafe.Pointer Go side, so we avoid the runtime check.