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

@ctrochalakis ctrochalakis Jan 15, 2018

Copy link
Copy Markdown

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?

Copy link
Copy Markdown

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