Skip to content

Commit

Permalink
fix bug: new and old version protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry-Mao committed May 28, 2014
1 parent 384dfd3 commit 57eb383
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions comet/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (c *Connection) HandleWrite(key string) {
n, err = c.Conn.Write(msg)
} else if c.Proto == TCPProto {
// redis protocol
n, err = c.Conn.Write([]byte(fmt.Sprintf("$%d\r\n%s\r\n", len(msg), string(msg))))
msg = []byte(fmt.Sprintf("$%d\r\n%s\r\n", len(msg), string(msg)))
n, err = c.Conn.Write(msg)
} else {
glog.Errorf("unknown connection protocol: %d", c.Proto)
panic(ErrConnProto)
Expand All @@ -89,7 +90,7 @@ func (c *Connection) HandleWrite(key string) {
glog.Errorf("user_key: \"%s\" conn.Write() error(%v)", key, err)
MsgStat.IncrFailed(1)
} else {
glog.V(1).Infof("user_key: \"%s\" write \"%s\"(%d)", key, string(msg), n)
glog.V(1).Infof("user_key: \"%s\" write \r\n========%s(%d)========", key, string(msg), n)
MsgStat.IncrSucceed(1)
}
}
Expand Down
11 changes: 8 additions & 3 deletions web/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ func GetOfflineMsg0(w http.ResponseWriter, r *http.Request) {
res["ret"] = InternalErr
return
}
omsgs := []*myrpc.OldMessage{}
omsgs := []string{}
opmsgs := []string{}
for _, msg := range reply.Msgs {
omsgs = append(omsgs, &myrpc.OldMessage{GroupId: msg.GroupId, MsgId: msg.MsgId, Msg: string(msg.Msg)})
omsg, err := msg.OldBytes()
if err != nil {
res["ret"] = InternalErr
return
}
omsgs = append(omsgs, string(omsg))
}
opmsgs := []*myrpc.OldMessage{}
res["data"] = map[string]interface{}{"msgs": omsgs, "pmsgs": opmsgs}
return
}
Expand Down

0 comments on commit 57eb383

Please sign in to comment.