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

Subscribers

People subscribed via source and target branches