Skip to content
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

Add godoc comments indicating that a mutex is needed for use with goroutines #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion magicmime.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ const (
// NewDecoder creates a detector that uses libmagic. It initializes
// the opens the magicmime database with the specified flags. Upon
// success users are expected to call Close on the returned Decoder
// when it is no longer needed.
// when it is no longer needed. Access to the magicmime
// database is not synchronized; the magicmime database file-descriptor
// is referenced through a global variable. Add mutex Lock/Unlock around
// the magicmime functions if using multiple goroutines.
Copy link

@ctrochalakis ctrochalakis Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean we should guard between calls to a specific Decoder's methods? Or between calls to magicmime.NewDecoder() calls? or both?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure that it's only between calls to a specific Decoder.

func NewDecoder(flags Flag) (*Decoder, error) {
db := C.magic_open(C.int(0))
if db == nil {
Expand Down