turnage / graw

Golang Reddit API Wrapper
MIT License
286 stars 50 forks source link

Engine from default provider cannot be stopped because stopSig is never initialized #13

Closed silviucm closed 8 years ago

silviucm commented 8 years ago

Hello,

Great library !

One small note if I may: In my opinion the internal/engine/provider.go file needs an extra line around line 33

from:

    e := &Engine{
        op:           op,
        bot:          bot,
        dir:          dir,
        monitors:     list.New(),
        userMonitors: make(map[string]*list.Element),
    }

to:

    e := &Engine{
        op:           op,
        bot:          bot,
        dir:          dir,
        monitors:     list.New(),
        userMonitors: make(map[string]*list.Element),
        stopSig:      make(chan bool),
    }

Otherwise the uninitialized channel blocks forever and calling Stop on the Engine will never reach the code to trigger e.stop = true in the Run method

    for !e.stop {
        select {
        case <-e.stopSig:
            e.stop = true

My regards again, and all the best, Silviu

turnage commented 8 years ago

Thank you for reporting!