mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
c012902c16
This reverts commit 69694a17be
.
48 lines
878 B
Go
48 lines
878 B
Go
package weed_server
|
|
|
|
import (
|
|
"bufio"
|
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
|
"io"
|
|
"net"
|
|
)
|
|
|
|
func (vs *VolumeServer) HandleUdpConnection(c net.Conn) {
|
|
defer c.Close()
|
|
|
|
bufReader := bufio.NewReaderSize(c, 1024*1024)
|
|
bufWriter := bufio.NewWriterSize(c, 1024*1024)
|
|
|
|
for {
|
|
cmd, err := bufReader.ReadString('\n')
|
|
if err != nil {
|
|
if err != io.EOF {
|
|
// glog.Errorf("read command from: %v", err)
|
|
}
|
|
return
|
|
}
|
|
println("received", cmd)
|
|
cmd = cmd[:len(cmd)-1]
|
|
switch cmd[0] {
|
|
case '+':
|
|
fileId := cmd[1:]
|
|
err = vs.handleTcpPut(fileId, bufReader)
|
|
if err != nil {
|
|
glog.Errorf("put %s: %v", fileId, err)
|
|
}
|
|
case '-':
|
|
fileId := cmd[1:]
|
|
err = vs.handleTcpDelete(fileId)
|
|
if err != nil {
|
|
glog.Errorf("del %s: %v", fileId, err)
|
|
}
|
|
case '?':
|
|
fileId := cmd[1:]
|
|
err = vs.handleTcpGet(fileId, bufWriter)
|
|
case '!':
|
|
}
|
|
|
|
}
|
|
|
|
}
|