internal sync, license update, 1.2 on travis etc
This commit is contained in:
parent
ce06322e66
commit
eca73f0096
@ -1 +1,6 @@
|
||||
script: curl https://raw.github.com/daaku/go.travis/master/install | sh
|
||||
language: go
|
||||
go:
|
||||
- 1.1
|
||||
- 1.2
|
||||
script:
|
||||
- curl https://raw.github.com/daaku/go.travis/master/install | sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Command gracedemo implements a demo server showing how to gracefully
|
||||
// terminate an HTTP server using go.grace.
|
||||
// terminate an HTTP server using grace.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -196,6 +196,12 @@ func (h *harness) SendOne(dialgroup *sync.WaitGroup, url string, pid int) {
|
||||
h.T.Fatalf("Failed to ready decode json response body pid=%d: %s", pid, err)
|
||||
}
|
||||
if pid != res.Pid {
|
||||
for _, old := range h.Process[0 : len(h.Process)-1] {
|
||||
if res.Pid == old.Pid {
|
||||
h.T.Logf("Found old pid %d, ignoring the discrepancy", res.Pid)
|
||||
return
|
||||
}
|
||||
}
|
||||
h.T.Fatalf("Didn't get expected pid %d instead got %d", pid, res.Pid)
|
||||
}
|
||||
debug("Done %02d pid=%d url=%s", count, pid, url)
|
||||
|
@ -22,7 +22,20 @@ type response struct {
|
||||
Error string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Wait for 10 consecutive responses from our own pid.
|
||||
//
|
||||
// This prevents flaky tests that arise from the fact that we have the
|
||||
// perfectly acceptable (read: not a bug) condition where both the new and the
|
||||
// old servers are accepting requests. In fact the amount of time both are
|
||||
// accepting at the same time and the number of requests that flip flop between
|
||||
// them is unbounded and in the hands of the various kernels our code tends to
|
||||
// run on.
|
||||
//
|
||||
// In order to combat this, we wait for 10 successful responses from our own
|
||||
// pid. This is a somewhat reliable way to ensure the old server isn't
|
||||
// serving anymore.
|
||||
func wait(wg *sync.WaitGroup, url string) {
|
||||
var success int
|
||||
defer wg.Done()
|
||||
for {
|
||||
res, err := http.Get(url)
|
||||
@ -34,9 +47,14 @@ func wait(wg *sync.WaitGroup, url string) {
|
||||
log.Fatalf("Error decoding json: %s", err)
|
||||
}
|
||||
if r.Pid == os.Getpid() {
|
||||
return
|
||||
success++
|
||||
if success == 10 {
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
success = 0
|
||||
// we expect connection refused
|
||||
if !strings.HasSuffix(err.Error(), "connection refused") {
|
||||
e2 := json.NewEncoder(os.Stderr).Encode(&response{
|
||||
@ -90,8 +108,8 @@ func main() {
|
||||
go func() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go wait(&wg, fmt.Sprintf("http://%s/sleep/?duration=0", httpAddr))
|
||||
go wait(&wg, fmt.Sprintf("https://%s/sleep/?duration=0", httpsAddr))
|
||||
go wait(&wg, fmt.Sprintf("http://%s/sleep/?duration=1ms", httpAddr))
|
||||
go wait(&wg, fmt.Sprintf("https://%s/sleep/?duration=1ms", httpsAddr))
|
||||
wg.Wait()
|
||||
|
||||
err = json.NewEncoder(os.Stderr).Encode(&response{Pid: os.Getpid()})
|
||||
|
37
license
37
license
@ -1,13 +1,30 @@
|
||||
Copyright 2013 Facebook, Inc
|
||||
BSD License
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
For grace software
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
23
patents
Normal file
23
patents
Normal file
@ -0,0 +1,23 @@
|
||||
Additional Grant of Patent Rights
|
||||
|
||||
"Software" means the grace software distributed by Facebook, Inc.
|
||||
|
||||
Facebook hereby grants you a perpetual, worldwide, royalty-free, non-exclusive,
|
||||
irrevocable (subject to the termination provision below) license under any
|
||||
rights in any patent claims owned by Facebook, to make, have made, use, sell,
|
||||
offer to sell, import, and otherwise transfer the Software. For avoidance of
|
||||
doubt, no license is granted under Facebook’s rights in any patent claims that
|
||||
are infringed by (i) modifications to the Software made by you or a third party,
|
||||
or (ii) the Software in combination with any software or other technology
|
||||
provided by you or a third party.
|
||||
|
||||
The license granted hereunder will terminate, automatically and without notice,
|
||||
for anyone that makes any claim (including by filing any lawsuit, assertion or
|
||||
other action) alleging (a) direct, indirect, or contributory infringement or
|
||||
inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or
|
||||
affiliates, whether or not such claim is related to the Software, (ii) by any
|
||||
party if such claim arises in whole or in part from any software, product or
|
||||
service of Facebook or any of its subsidiaries or affiliates, whether or not
|
||||
such claim is related to the Software, or (iii) by any party relating to the
|
||||
Software; or (b) that any right in any patent claim of Facebook is invalid or
|
||||
unenforceable.
|
Loading…
Reference in New Issue
Block a user