-
Notifications
You must be signed in to change notification settings - Fork 7
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
Switch map to sync.Map to make it safe in multi-thread application? #16
Comments
CGO is not yet compatible with multithreaded programming, which may cause deadlock. |
Nice to hear some ideas.
Are there any more details?
Would you compare this with nginx + modsecurity? What's the advantage? |
libcoroza is easy to develop . I've developed a log4j module for detecting more evasive exploit.But porting to libmodsecurity is hard. Learning C++ is quite challenging. |
I guess it's because the Go's threads disappear after the Nginx calls
I am glad to hear that. |
sure loading the |
You can open an issue there and discuss with them. |
Currently, libcoraza uses map to store the states:
libcoraza/libcoraza/coraza.go
Line 42 in 23b4abd
map is not thread-safe, if we want to use libcoraza in a multi-thread C/C++ application, it would be better to switch to sync.Map.
Compared with the whole operation, the extra cost from the
sync.Map
is acceptable. And seems the use cases in libcoraza satisfy "a given key is only ever written once but read many times" so it may be better than using extra sync.RWMutex.More info can be found in https://pkg.go.dev/sync#Map
The text was updated successfully, but these errors were encountered: