goc2p icon indicating copy to clipboard operation
goc2p copied to clipboard

scheduler.start state need to be set only at the end of the start() function

Open lzl1024 opened this issue 8 years ago • 4 comments

Otherwise, monitor might start running before scheduler is fully started and query those components which are not initialized. It will run into a panic.

lzl1024 avatar Mar 09 '16 08:03 lzl1024

Hi, maybe you could describe in detail.

hyper0x avatar Apr 14 '16 02:04 hyper0x

scheduler.go line 102 has to be put to the end of the start function, because scheduler actually has not been fully started yet at that time. Downloader, analyzer are all not initialized.

However, monitor is waiting for this stat change and will query those components afterwards. So there will be a risk condition when those initializing components are queried by the monitor.

lzl1024 avatar Apr 14 '16 05:04 lzl1024

OK, sometimes there will be a problem, although it seems had little effect. What do you do to improve it? Welcome to send PR. :-)

In fact, it's to prevent repeated start.

hyper0x avatar Apr 25 '16 08:04 hyper0x

@lzl1024 You are right. @hyper0x E.g. :

  1. When the monitor is waiting for state change of scheduler at monitor.go line 193
  2. Then go to line 102 in scheduler.go the state of scheduler change to be running.
  3. After that Function "waitForSchedulerStart" returns, and it runs to line 201 in monitor.go. But at that time, the ErrorChan is not initialized. So it occurs a nil pointer panic.

SwanSpouse avatar Jun 16 '17 08:06 SwanSpouse