From 9f64e2ac707d95965578d64291a540ca711bcad0 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Mon, 25 Jan 2016 22:33:05 +0900 Subject: non-nonblock --- Gemfile.lock | 16 ++++++++-------- app/models/result.rb | 1 - sandbox-go/src/main.go | 6 +++--- sandbox-go/src/parent.go | 8 +++----- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2d1c6c7..b43df4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: git://github.com/rhenium/plum.git - revision: 87eef66181c9defc2d44ddd536e23b691f754b91 + revision: 736969c7f3cf49611b3a6f7463640c4d335e5bf2 specs: - plum (0.2.9) + plum (0.2.10) GEM remote: https://rubygems.org/ @@ -52,10 +52,10 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (7.0.0) - autoprefixer-rails (6.2.3) + autoprefixer-rails (6.3.1) execjs json - babel-source (5.8.34) + babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) @@ -63,7 +63,7 @@ GEM autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.2) - celluloid (0.17.2) + celluloid (0.17.3) celluloid-essentials celluloid-extras celluloid-fsm @@ -95,7 +95,7 @@ GEM eventmachine (~> 1.0) hiredis (~> 0.5.0) erubis (2.7.0) - eventmachine (1.0.9) + eventmachine (1.0.9.1) execjs (2.6.0) faye-websocket (0.10.2) eventmachine (>= 0.12.0) @@ -138,10 +138,10 @@ GEM method_source (0.8.2) mime-types (2.99) mini_portile2 (2.0.0) - minitest (5.8.3) + minitest (5.8.4) mysql2 (0.4.2) nenv (0.2.0) - nokogiri (1.6.7.1) + nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) notiffany (0.0.8) nenv (~> 0.1) diff --git a/app/models/result.rb b/app/models/result.rb index a675999..546e6b4 100644 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -15,7 +15,6 @@ class Result < ApplicationRecord ret = [] while orig.bytesize > 0 fd, len = orig.slice!(0, 8).unpack("ii") - p [fd, len] if !truncated? && (!len || orig.bytesize < len) p orig p output.b diff --git a/sandbox-go/src/main.go b/sandbox-go/src/main.go index a881e3a..0a40368 100644 --- a/sandbox-go/src/main.go +++ b/sandbox-go/src/main.go @@ -54,7 +54,7 @@ func cleanup() { } func main() { - runtime.GOMAXPROCS(3) + runtime.GOMAXPROCS(8) dec := json.NewDecoder(os.Stdin) var plan plan if err := dec.Decode(&plan); err != nil { @@ -85,10 +85,10 @@ func main() { if err := syscall.Pipe2(stdin_fd[:], 0); err != nil { poePanic(err, "pipe2 failed") } - if err := syscall.Pipe2(stdout_fd[:], syscall.O_DIRECT|syscall.O_NONBLOCK); err != nil { + if err := syscall.Pipe2(stdout_fd[:], syscall.O_DIRECT); err != nil { poePanic(err, "pipe2 failed") } - if err := syscall.Pipe2(stderr_fd[:], syscall.O_DIRECT|syscall.O_NONBLOCK); err != nil { + if err := syscall.Pipe2(stderr_fd[:], syscall.O_DIRECT); err != nil { poePanic(err, "pipe2 failed") } diff --git a/sandbox-go/src/parent.go b/sandbox-go/src/parent.go index 35a2df2..5fbbf28 100644 --- a/sandbox-go/src/parent.go +++ b/sandbox-go/src/parent.go @@ -3,7 +3,6 @@ package main import ( "bytes" "encoding/binary" - "unsafe" "fmt" "os" "os/signal" @@ -82,12 +81,11 @@ func doParent(mpid int, stdin_fd, stdout_fd, stderr_fd [2]int) resultPack { var buf [65536]byte // TODO: how to get PIPE_BUF? for ev := 0; ev < en; ev++ { for { - r1, _, e1 := syscall.Syscall(syscall.SYS_READ, uintptr(events[ev].Fd), uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf))) - if e1 != 0 { + n, err := syscall.Read(int(events[ev].Fd), buf[:]) + if err != nil { break } - n := int(r1) - if r1 > 0 { + if n > 0 { nbuf := make([]byte, n) copy(nbuf, buf[:n]) out_chan <- childOutput{int(events[ev].Pad), n, nbuf} -- cgit v1.2.3