summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimportd
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at/rhimportd')
-rw-r--r--src/helsinki.at/rhimportd/ctrlTelnet.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go
index 41ac7f2..b47d2a1 100644
--- a/src/helsinki.at/rhimportd/ctrlTelnet.go
+++ b/src/helsinki.at/rhimportd/ctrlTelnet.go
@@ -283,15 +283,13 @@ func telnet_cmd_run(ctx rhimport.ImportContext, out chan<- string) {
out <- fmt.Sprintf("\nimporting file '%s'\n", ctx.SourceFile)
if res, err := rhimport.ImportFile(&ctx); err != nil {
- out <- fmt.Sprintf("import file error: %s\n", err)
+ out <- fmt.Sprintf("\nimport file error: %s\n", err)
return
} else {
if res.ResponseCode == http.StatusOK {
out <- fmt.Sprintf("\nFile got succesfully imported into Cart/Cut %d/%d\n", res.Cart, res.Cut)
- rhl.Printf("File got succesfully imported into Cart/Cut %d/%d", res.Cart, res.Cut)
} else {
- out <- fmt.Sprintf("Fileimport has failed (Cart/Cut %d/%d): %s\n", res.Cart, res.Cut, res.ErrorString)
- rhl.Printf("Fileimport has failed (Cart/Cut %d/%d): %s", res.Cart, res.Cut, res.ErrorString)
+ out <- fmt.Sprintf("\nFileimport has failed (Cart/Cut %d/%d): %s\n", res.Cart, res.Cut, res.ErrorString)
}
}
}
@@ -362,7 +360,7 @@ func (c *TelnetClient) handle_iac(iac []byte, cancel chan<- bool) bool {
case IP:
select {
case cancel <- true:
- default: // process got canceled already
+ default: // process got canceled already
}
return false
default:
@@ -454,6 +452,13 @@ func (c *TelnetClient) handle() {
done := make(chan bool)
cancel := make(chan bool, 1)
+ defer func() { // make sure to cancel possible running job when closing connection
+ select {
+ case cancel <- true:
+ default:
+ }
+ }()
+
c.write_string(prompt)
for {
select {