Commit 8b337434 authored by Stefan Dähling's avatar Stefan Dähling
Browse files

agency handle agent delete

parent 4bc79752
Pipeline #290188 passed with stages
in 2 minutes and 36 seconds
......@@ -98,6 +98,10 @@ func (agency *Agency) aclLookup(agentID int) (acl *ACL, err error) {
err = errors.New("MassiveError")
return
}
if address.Agency == "" {
err = errors.New("Receiver is not active")
return
}
var remAgency *remoteAgency
agency.mutex.Lock()
remAgency, ok = agency.remoteAgencies[address.Agency]
......@@ -222,6 +226,12 @@ func (agency *Agency) receiveMsgs() {
return
}
}
} else {
_, err := agencyclient.ReturnMsg(msgs[i].AgencySender, msgs[i])
if err != nil {
agency.logError.Println(err)
return
}
}
}
}
......
......@@ -227,6 +227,16 @@ func (agency *Agency) getAgentStatus(agentID int) (ret schemas.Status, err error
// removeAgent creates a new mas according to masconfig
func (agency *Agency) removeAgent(agentID int) (err error) {
agency.mutex.Lock()
ag, ok := agency.localAgents[agentID]
agency.mutex.Unlock()
if !ok {
return
}
ag.Terminate()
agency.mutex.Lock()
delete(agency.localAgents, agentID)
agency.mutex.Unlock()
return
}
......
......@@ -80,7 +80,7 @@ func (agency *Agency) handleAPI(w http.ResponseWriter, r *http.Request) {
cmapErr, httpErr = agency.handleMsgs(w, r)
resvalid = true
} else if respath[2] == "agency" && respath[3] == "msgundeliv" {
cmapErr, httpErr = agency.handleMsgs(w, r)
cmapErr, httpErr = agency.handleUndeliverableMsg(w, r)
resvalid = true
}
case 5:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment