Skip to content
Snippets Groups Projects
Commit 959d9cf3 authored by Manish R Jain's avatar Manish R Jain
Browse files

Fix bugs: Set GRPC server in Goroutine. Break out of loop if ServeRequest...

Fix bugs: Set GRPC server in Goroutine. Break out of loop if ServeRequest returns error -- this was causing the 100% CPU usage issue.
parent d5a8b3dc
No related branches found
No related tags found
No related merge requests found
......@@ -252,11 +252,11 @@ func (s *server) Query(ctx context.Context,
// This function register a DGraph grpc server on the address, which is used
// exchanging protocol buffer messages.
func runGrpcServer(address string) error {
func runGrpcServer(address string) {
ln, err := net.Listen("tcp", address)
if err != nil {
glog.Fatalf("While running server for client: %v", err)
return err
return
}
glog.WithField("address", ln.Addr()).Info("Client Worker listening")
......@@ -265,7 +265,7 @@ func runGrpcServer(address string) error {
if err = s.Serve(ln); err != nil {
glog.Fatalf("While serving gRpc requests", err)
}
return nil
return
}
func main() {
......@@ -313,7 +313,7 @@ func main() {
worker.Connect(addrs)
// Grpc server runs on (port + 1)
runGrpcServer(fmt.Sprintf(":%d", *port+1))
go runGrpcServer(fmt.Sprintf(":%d", *port+1))
http.HandleFunc("/query", queryHandler)
glog.WithField("port", *port).Info("Listening for requests...")
......
......@@ -162,7 +162,11 @@ func serveRequests(irwc io.ReadWriteCloser) {
sc := &conn.ServerCodec{
Rwc: irwc,
}
rpc.ServeRequest(sc)
glog.Info("Serving request from serveRequests")
if err := rpc.ServeRequest(sc); err != nil {
glog.WithField("method", "serveRequests").Info(err)
break
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment