This commit is contained in:
Xing Xing 2013-12-23 17:05:42 +08:00
parent 2b4cc002d1
commit 2ee2be0891
4 changed files with 20 additions and 21 deletions

View File

@ -7,8 +7,8 @@ package worker
import (
"bytes"
"fmt"
"encoding/binary"
"fmt"
"strconv"
)
@ -38,7 +38,7 @@ func (inpack *inPack) SendData(data []byte) {
l := hl + len(data) + 1
outpack.data = getBuffer(l)
copy(outpack.data, []byte(inpack.handle))
copy(outpack.data[hl + 1:], data)
copy(outpack.data[hl+1:], data)
inpack.a.write(outpack)
}
@ -49,7 +49,7 @@ func (inpack *inPack) SendWarning(data []byte) {
l := hl + len(data) + 1
outpack.data = getBuffer(l)
copy(outpack.data, []byte(inpack.handle))
copy(outpack.data[hl + 1:], data)
copy(outpack.data[hl+1:], data)
inpack.a.write(outpack)
}
@ -70,7 +70,6 @@ func (inpack *inPack) UpdateStatus(numerator, denominator int) {
inpack.a.write(outpack)
}
// Decode job from byte slice
func decodeInPack(data []byte) (inpack *inPack, l int, err error) {
if len(data) < MIN_PACKET_LEN { // valid package should not less 12 bytes

View File

@ -5,10 +5,10 @@
package worker
import (
"fmt"
"time"
"sync"
"encoding/binary"
"fmt"
"sync"
"time"
)
const (
@ -78,7 +78,7 @@ func (worker *Worker) AddServer(net, addr string) (err error) {
if err != nil {
return err
}
worker.agents[net + addr] = a
worker.agents[net+addr] = a
return
}
@ -120,7 +120,7 @@ func (worker *Worker) addFunc(funcname string, timeout uint32) {
outpack.data = getBuffer(l + 5)
copy(outpack.data, []byte(funcname))
outpack.data[l] = '\x00'
binary.BigEndian.PutUint32(outpack.data[l + 1:], timeout)
binary.BigEndian.PutUint32(outpack.data[l+1:], timeout)
}
worker.broadcast(outpack)
}

View File

@ -1,8 +1,8 @@
package worker
import (
"sync"
"testing"
"sync"
"testing"
)
var worker *Worker