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) { ...@@ -98,6 +98,10 @@ func (agency *Agency) aclLookup(agentID int) (acl *ACL, err error) {
err = errors.New("MassiveError") err = errors.New("MassiveError")
return return
} }
if address.Agency == "" {
err = errors.New("Receiver is not active")
return
}
var remAgency *remoteAgency var remAgency *remoteAgency
agency.mutex.Lock() agency.mutex.Lock()
remAgency, ok = agency.remoteAgencies[address.Agency] remAgency, ok = agency.remoteAgencies[address.Agency]
...@@ -222,6 +226,12 @@ func (agency *Agency) receiveMsgs() { ...@@ -222,6 +226,12 @@ func (agency *Agency) receiveMsgs() {
return 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 ...@@ -227,6 +227,16 @@ func (agency *Agency) getAgentStatus(agentID int) (ret schemas.Status, err error
// removeAgent creates a new mas according to masconfig // removeAgent creates a new mas according to masconfig
func (agency *Agency) removeAgent(agentID int) (err error) { 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 return
} }
......
...@@ -80,7 +80,7 @@ func (agency *Agency) handleAPI(w http.ResponseWriter, r *http.Request) { ...@@ -80,7 +80,7 @@ func (agency *Agency) handleAPI(w http.ResponseWriter, r *http.Request) {
cmapErr, httpErr = agency.handleMsgs(w, r) cmapErr, httpErr = agency.handleMsgs(w, r)
resvalid = true resvalid = true
} else if respath[2] == "agency" && respath[3] == "msgundeliv" { } else if respath[2] == "agency" && respath[3] == "msgundeliv" {
cmapErr, httpErr = agency.handleMsgs(w, r) cmapErr, httpErr = agency.handleUndeliverableMsg(w, r)
resvalid = true resvalid = true
} }
case 5: case 5:
......
Supports Markdown
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