Merge lp:~niemeyer/gozk/is-not-exist into lp:gozk/zookeeper

Proposed by Gustavo Niemeyer
Status: Merged
Merged at revision: 30
Proposed branch: lp:~niemeyer/gozk/is-not-exist
Merge into: lp:gozk/zookeeper
Diff against target: 29 lines (+4/-5)
1 file modified
runserver.go (+4/-5)
To merge this branch: bzr merge lp:~niemeyer/gozk/is-not-exist
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+94257@code.launchpad.net

Description of the change

Fix after latest changes in Go's tip.

https://codereview.appspot.com/5684066/

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Reviewers: mp+94257_code.launchpad.net,

Message:
Please take a look.

Description:

https://code.launchpad.net/~niemeyer/gozk/is-not-exist/+merge/94257

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/5684066/

Affected files:
   M runserver.go

Index: runserver.go
=== <email address hidden> >
<email address hidden>
=== modified file 'runserver.go'
--- runserver.go 2012-02-15 13:14:05 +0000
+++ runserver.go 2012-02-22 18:56:23 +0000
@@ -24,8 +24,8 @@
  func (srv *Server) Process() (*os.Process, error) {
   data, err := ioutil.ReadFile(srv.path("pid.txt"))
   if err != nil {
- if err, ok := err.(*os.PathError); ok && err.Err == os.ENOENT {
- return nil, NotRunning
+ if os.IsNotExist(err) {
+ err = NotRunning
    }
    return nil, err
   }
@@ -131,12 +131,11 @@
   if err := p.Kill(); err != nil {
    return fmt.Errorf("cannot kill server process: %v", err)
   }
- // ignore the error returned from Wait because there's little
+ // Ignore the error returned from Wait because there's little
   // we can do about it - it either means that the process has just exited
   // anyway or that we can't wait for it for some other reason,
   // for example because it was originally started by some other process.
- _, err = p.Wait(0)
- if e, ok := err.(*os.SyscallError); ok && e.Err == os.ECHILD {
+ if _, err := p.Wait(); err != nil {
    // If we can't wait for the server, it's possible that it was running
    // but not as a child of this process, so the only thing we can do
    // is to poll until it exits. If the process has taken longer than

Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 2012/02/22 19:08:58, niemeyer wrote:
> Please take a look.

LGTM

https://codereview.appspot.com/5684066/

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

*** Submitted:

Fix after latest changes in Go's tip.

R=rog
CC=
https://codereview.appspot.com/5684066

https://codereview.appspot.com/5684066/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'runserver.go'
--- runserver.go 2012-02-15 13:14:05 +0000
+++ runserver.go 2012-02-22 19:09:21 +0000
@@ -24,8 +24,8 @@
24func (srv *Server) Process() (*os.Process, error) {24func (srv *Server) Process() (*os.Process, error) {
25 data, err := ioutil.ReadFile(srv.path("pid.txt"))25 data, err := ioutil.ReadFile(srv.path("pid.txt"))
26 if err != nil {26 if err != nil {
27 if err, ok := err.(*os.PathError); ok && err.Err == os.ENOENT {27 if os.IsNotExist(err) {
28 return nil, NotRunning28 err = NotRunning
29 }29 }
30 return nil, err30 return nil, err
31 }31 }
@@ -131,12 +131,11 @@
131 if err := p.Kill(); err != nil {131 if err := p.Kill(); err != nil {
132 return fmt.Errorf("cannot kill server process: %v", err)132 return fmt.Errorf("cannot kill server process: %v", err)
133 }133 }
134 // ignore the error returned from Wait because there's little134 // Ignore the error returned from Wait because there's little
135 // we can do about it - it either means that the process has just exited135 // we can do about it - it either means that the process has just exited
136 // anyway or that we can't wait for it for some other reason,136 // anyway or that we can't wait for it for some other reason,
137 // for example because it was originally started by some other process.137 // for example because it was originally started by some other process.
138 _, err = p.Wait(0)138 if _, err := p.Wait(); err != nil {
139 if e, ok := err.(*os.SyscallError); ok && e.Err == os.ECHILD {
140 // If we can't wait for the server, it's possible that it was running139 // If we can't wait for the server, it's possible that it was running
141 // but not as a child of this process, so the only thing we can do140 // but not as a child of this process, so the only thing we can do
142 // is to poll until it exits. If the process has taken longer than141 // is to poll until it exits. If the process has taken longer than

Subscribers

People subscribed via source and target branches