Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsqd: fatal errors are not fatal #198

Merged
merged 1 commit into from
May 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nsqd/protocol_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func (p *ProtocolV2) IOLoop(conn net.Conn) error {
}
log.Printf("ERROR: [%s] - %s%s", client, err.Error(), context)

err = p.Send(client, nsq.FrameTypeError, []byte(err.Error()))
if err != nil {
sendErr := p.Send(client, nsq.FrameTypeError, []byte(err.Error()));
if sendErr != nil {
break
}

Expand Down
23 changes: 23 additions & 0 deletions nsqd/protocol_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,29 @@ func TestMaxRdyCount(t *testing.T) {
assert.Equal(t, string(data), "E_INVALID RDY count 51 out of range 0-50")
}

func TestFatalError(t *testing.T) {
log.SetOutput(ioutil.Discard)
defer log.SetOutput(os.Stdout)

tcpAddr, _ := mustStartNSQd(NewNsqdOptions())
defer nsqd.Exit()

conn, err := mustConnectNSQd(tcpAddr)
assert.Equal(t, err, nil)

_, err = conn.Write([]byte("ASDF\n"))
assert.Equal(t, err, nil)

resp, err := nsq.ReadResponse(conn)
assert.Equal(t, err, nil)
frameType, data, err := nsq.UnpackResponse(resp)
assert.Equal(t, frameType, int32(1))
assert.Equal(t, string(data), "E_INVALID invalid command ASDF")

_, err = nsq.ReadResponse(conn)
assert.NotEqual(t, err, nil)
}

func BenchmarkProtocolV2Exec(b *testing.B) {
b.StopTimer()
log.SetOutput(ioutil.Discard)
Expand Down