forked from yuxh/gearman-go
		
	fixed the closing method
This commit is contained in:
		
							parent
							
								
									d32eb195e1
								
							
						
					
					
						commit
						a003eac543
					
				@ -30,7 +30,6 @@ type Worker struct {
 | 
			
		||||
	limit        chan bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Return a worker.
 | 
			
		||||
//
 | 
			
		||||
// If limit is set to Unlimited(=0), the worker will grab all jobs
 | 
			
		||||
@ -99,7 +98,7 @@ func (worker *Worker) addFunc(funcname string, timeout uint32) {
 | 
			
		||||
	worker.broadcast(outpack)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func prepFuncOutpack(funcname string, timeout uint32) (*outPack){
 | 
			
		||||
func prepFuncOutpack(funcname string, timeout uint32) *outPack {
 | 
			
		||||
	outpack := getOutPack()
 | 
			
		||||
	if timeout == 0 {
 | 
			
		||||
		outpack.dataType = dtCanDo
 | 
			
		||||
@ -196,11 +195,6 @@ func (worker *Worker) Work() {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	defer func() {
 | 
			
		||||
		for _, a := range worker.agents {
 | 
			
		||||
			a.Close()
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
	worker.running = true
 | 
			
		||||
	for _, a := range worker.agents {
 | 
			
		||||
		a.Grab()
 | 
			
		||||
@ -223,8 +217,11 @@ func (worker *Worker) customeHandler(inpack *inPack) {
 | 
			
		||||
// Close connection and exit main loop
 | 
			
		||||
func (worker *Worker) Close() {
 | 
			
		||||
	worker.Lock()
 | 
			
		||||
	worker.Unlock()
 | 
			
		||||
	defer worker.Unlock()
 | 
			
		||||
	if worker.running == true {
 | 
			
		||||
		for _, a := range worker.agents {
 | 
			
		||||
			a.Close()
 | 
			
		||||
		}
 | 
			
		||||
		worker.running = false
 | 
			
		||||
		close(worker.in)
 | 
			
		||||
	}
 | 
			
		||||
@ -337,14 +334,16 @@ type WorkerDisconnectError struct{
 | 
			
		||||
	err   error
 | 
			
		||||
	agent *agent
 | 
			
		||||
}
 | 
			
		||||
func (e *WorkerDisconnectError) Error() ( string){
 | 
			
		||||
	return e.err.Error();
 | 
			
		||||
 | 
			
		||||
func (e *WorkerDisconnectError) Error() string {
 | 
			
		||||
	return e.err.Error()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Responds to the error by asking the worker to reconnect
 | 
			
		||||
func (e *WorkerDisconnectError) Reconnect() (err error) {
 | 
			
		||||
	return e.agent.reconnect()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Which server was this for?
 | 
			
		||||
func (e *WorkerDisconnectError) Server() (net string, addr string) {
 | 
			
		||||
	return e.agent.net, e.agent.addr
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user