[prev in list] [next in list] [prev in thread] [next in thread]
List: mesos-commits
Subject: [16/35] Renamed 'third_party' to '3rdparty'.
From: benh () apache ! org
Date: 2013-05-29 17:40:54
Message-ID: 33d99203f65547ceb3e04dfc7167a1a2 () git ! apache ! org
[Download RAW message or body]
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/include/process/timer.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/include/process/timer.hpp \
b/third_party/libprocess/include/process/timer.hpp deleted file mode 100644
index 333a806..0000000
--- a/third_party/libprocess/include/process/timer.hpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef __PROCESS_TIMER_HPP__
-#define __PROCESS_TIMER_HPP__
-
-#include <stdlib.h> // For abort.
-
-#include <tr1/functional>
-
-#include <process/timeout.hpp>
-
-#include <stout/duration.hpp>
-
-namespace process {
-
-// Timer support!
-
-class Timer
-{
-public:
- Timer() : id(0), pid(process::UPID()), thunk(&abort) {}
-
- static Timer create(
- const Duration& duration,
- const std::tr1::function<void(void)>& thunk);
-
- static bool cancel(const Timer& timer);
-
- bool operator == (const Timer& that) const
- {
- return id == that.id;
- }
-
- // Invokes this timer's thunk.
- void operator () () const
- {
- thunk();
- }
-
- // Returns the timeout associated with this timer.
- Timeout timeout() const
- {
- return t;
- }
-
- // Returns the PID of the running process when this timer was
- // created (via timers::create) or an empty PID if no process was
- // running when this timer was created.
- process::UPID creator() const
- {
- return pid;
- }
-
-private:
- Timer(long _id,
- const Timeout& _t,
- const process::UPID& _pid,
- const std::tr1::function<void(void)>& _thunk)
- : id(_id), t(_t), pid(_pid), thunk(_thunk)
- {}
-
- uint64_t id; // Used for equality.
-
- Timeout t;
-
- // We store the PID of the "issuing" (i.e., "running") process (if
- // there is one). We don't store a pointer to the process because we
- // can't dereference it since it might no longer be valid. (Instead,
- // the PID can be used internally to check if the process is still
- // valid and get a refernce to it.)
- process::UPID pid;
-
- std::tr1::function<void(void)> thunk;
-};
-
-} // namespace process {
-
-#endif // __PROCESS_TIMER_HPP__
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/include/process/tuples/details.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/include/process/tuples/details.hpp \
b/third_party/libprocess/include/process/tuples/details.hpp deleted file mode 100644
index 34a9fb5..0000000
--- a/third_party/libprocess/include/process/tuples/details.hpp
+++ /dev/null
@@ -1,170 +0,0 @@
-template <MSGID ID> class tuple;
-
-#undef IDENTITY
-#define IDENTITY(...) __VA_ARGS__
-
-#undef TUPLE
-#define TUPLE(ID, types) \
- template <> class tuple<ID> : public boost::tuple<IDENTITY types> \
- { \
- public: \
- tuple(const boost::tuple<IDENTITY types> &t) \
- : boost::tuple<IDENTITY types>(t) {} \
- \
- tuple(const std::string &data) \
- { \
- std::istringstream is(data); \
- process::tuples::deserializer d(is); \
- deserialize(d, *this); \
- } \
- \
- operator std::string () const \
- { \
- std::ostringstream os; \
- process::tuples::serializer s(os); \
- serialize(s, *this); \
- return os.str(); \
- } \
- }
-
-
-inline void serialize(process::tuples::serializer &s,
- const boost::tuples::null_type &)
-{
-}
-
-
-template <typename H, typename T>
-inline void serialize(process::tuples::serializer &s,
- const boost::tuples::cons<H, T> &c)
-{
- s & c.get_head();
- serialize(s, c.get_tail());
-}
-
-
-inline void deserialize(process::tuples::deserializer &d,
- const boost::tuples::null_type &)
-{
-}
-
-
-template <typename H, typename T>
-inline void deserialize(process::tuples::deserializer &d,
- boost::tuples::cons<H, T> &c)
-{
- d & c.get_head();
- deserialize(d, c.get_tail());
-}
-
-
-template <MSGID ID>
-tuple<ID> pack()
-{
- return tuple<ID>(::boost::make_tuple());
-}
-
-
-template <MSGID ID, typename T0>
-tuple<ID> pack(const T0 &t0)
-{
- return tuple<ID>(::boost::make_tuple(t0));
-}
-
-
-template <MSGID ID, typename T0, typename T1>
-tuple<ID> pack(const T0 &t0, const T1 &t1)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1));
-}
-
-
-template <MSGID ID, typename T0, typename T1, typename T2>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4,
- typename T5>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4, const T5 &t5)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4, t5));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4,
- typename T5, typename T6>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4, const T5 &t5, const T6 &t6)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4, t5, t6));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4,
- typename T5, typename T6, typename T7>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4, t5, t6, t7));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4,
- typename T5, typename T6, typename T7, typename T8>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7,
- const T8 &t8)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4, t5, t6, t7, t8));
-}
-
-
-template <MSGID ID,
- typename T0, typename T1, typename T2, typename T3, typename T4,
- typename T5, typename T6, typename T7, typename T8, typename T9>
-tuple<ID> pack(const T0 &t0, const T1 &t1, const T2 &t2, const T3 &t3,
- const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7,
- const T8 &t8, const T9 &t9)
-{
- return tuple<ID>(::boost::make_tuple(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9));
-}
-
-
-template <MSGID ID>
-tuple<ID> unpack(const std::string &data)
-{
- return tuple<ID>(data);
-}
-
-
-template <MSGID ID, int N>
-typename boost::tuples::element<N, tuple<ID> >::type unpack(
- const std::string &data)
-{
- return boost::tuples::get<N>(unpack<ID>(data));
-}
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/include/process/tuples/tuples.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/include/process/tuples/tuples.hpp \
b/third_party/libprocess/include/process/tuples/tuples.hpp deleted file mode 100644
index 16445fa..0000000
--- a/third_party/libprocess/include/process/tuples/tuples.hpp
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef __PROCESS_TUPLES_HPP__
-#define __PROCESS_TUPLES_HPP__
-
-#include <stdlib.h>
-
-#include <arpa/inet.h>
-
-#include <sstream>
-#include <string>
-#include <utility>
-
-#include <boost/tuple/tuple.hpp>
-
-
-namespace process { namespace tuples {
-
-// TODO(benh): Check stream errors! Report errors! Ahhhh!
-
-struct serializer
-{
- std::ostringstream& stream;
-
- serializer(std::ostringstream& s) : stream(s) {}
-
- void operator & (const int32_t & i)
- {
- uint32_t netInt = htonl((uint32_t) i);
- stream.write((char *) &netInt, sizeof(netInt));
- }
-
- void operator & (const int64_t & i)
- {
- uint32_t hiInt = htonl((uint32_t) (i >> 32));
- uint32_t loInt = htonl((uint32_t) (i & 0xFFFFFFFF));
- stream.write((char *) &hiInt, sizeof(hiInt));
- stream.write((char *) &loInt, sizeof(loInt));
- }
-
-#ifdef __APPLE__
- void operator & (const intptr_t &i)
- {
- if (sizeof(intptr_t) == sizeof(int32_t))
- *this & ((int32_t &) i);
- else if (sizeof(intptr_t) == sizeof(int64_t))
- *this & ((int64_t &) i);
- else
- abort();
- }
-#endif
-
- void operator & (const size_t &i)
- {
- if (sizeof(size_t) == sizeof(int32_t))
- *this & ((int32_t &) i);
- else if (sizeof(size_t) == sizeof(int64_t))
- *this & ((int64_t &) i);
- else
- abort();
- }
-
- void operator & (const double &d)
- {
- // TODO(*): Deal with endian issues?
- stream.write((char *) &d, sizeof(d));
- }
-
- void operator & (const std::string &s)
- {
- size_t size = s.size();
- *this & (size);
- stream.write(s.data(), size);
- }
-
- void operator & (const PID &pid)
- {
- *this & ((int32_t) pid.pipe);
- *this & ((int32_t) pid.ip);
- *this & ((int32_t) pid.port);
- }
-};
-
-
-struct deserializer
-{
- std::istringstream &stream;
-
- deserializer(std::istringstream &s) : stream(s) {}
-
- void operator & (int32_t &i)
- {
- uint32_t netInt;
- stream.read((char *) &netInt, sizeof(netInt));
- i = ntohl(netInt);
- }
-
- void operator & (int64_t &i)
- {
- uint32_t hiInt, loInt;
- stream.read((char *) &hiInt, sizeof(hiInt));
- stream.read((char *) &loInt, sizeof(loInt));
- int64_t hi64 = ntohl(hiInt);
- int64_t lo64 = ntohl(loInt);
- i = (hi64 << 32) | lo64;
- }
-
-#ifdef __APPLE__
- void operator & (intptr_t &i)
- {
- if (sizeof(intptr_t) == sizeof(int32_t))
- *this & ((int32_t &) i);
- else if (sizeof(intptr_t) == sizeof(int64_t))
- *this & ((int64_t &) i);
- else
- abort();
- }
-#endif
-
- void operator & (size_t &i)
- {
- if (sizeof(size_t) == sizeof(int32_t))
- *this & ((int32_t &) i);
- else if (sizeof(size_t) == sizeof(int64_t))
- *this & ((int64_t &) i);
- else
- abort();
- }
-
- void operator & (double &d)
- {
- // TODO(*): Deal with endian issues?
- stream.read((char *) &d, sizeof(d));
- }
-
- void operator & (std::string &s)
- {
- size_t size;
- *this & (size);
- s.resize(size);
- stream.read((char *) s.data(), size);
- }
-
- void operator & (PID &pid)
- {
- *this & ((int32_t &) pid.pipe);
- *this & ((int32_t &) pid.ip);
- *this & ((int32_t &) pid.port);
- }
-};
-
-
-}} // namespace process { namespace tuples {
-
-
-#endif // __PROCESS_TUPLES_HPP__
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/install-sh
----------------------------------------------------------------------
diff --git a/third_party/libprocess/install-sh b/third_party/libprocess/install-sh
deleted file mode 100755
index 6781b98..0000000
--- a/third_party/libprocess/install-sh
+++ /dev/null
@@ -1,520 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2009-04-28.21; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-nl='
-'
-IFS=" "" $nl"
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit=${DOITPROG-}
-if test -z "$doit"; then
- doit_exec=exec
-else
- doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_glob='?'
-initialize_posix_glob='
- test "$posix_glob" != "?" || {
- if (set -f) 2>/dev/null; then
- posix_glob=
- else
- posix_glob=:
- fi
- }
-'
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-no_target_directory=
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
- --help display this help and exit.
- --version display version info and exit.
-
- -c (ignored)
- -C install only if different (preserve the last data modification time)
- -d create directories instead of installing files.
- -g GROUP $chgrpprog installed files to GROUP.
- -m MODE $chmodprog installed files to MODE.
- -o USER $chownprog installed files to USER.
- -s $stripprog installed files.
- -t DIRECTORY install into DIRECTORY.
- -T report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
- RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) ;;
-
- -C) copy_on_change=true;;
-
- -d) dir_arg=true;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- case $mode in
- *' '* | *' '* | *'
-'* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- shift;;
-
- -o) chowncmd="$chownprog $2"
- shift;;
-
- -s) stripcmd=$stripprog;;
-
- -t) dst_arg=$2
- shift;;
-
- -T) no_target_directory=true;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
- shift
-done
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dst_arg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dst_arg"
- shift # fnord
- fi
- shift # arg
- dst_arg=$arg
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- trap '(exit $?); exit' 1 2 13 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dst_arg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dst_arg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dst_arg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dst=$dstdir/`basename "$src"`
- dstdir_status=0
- else
- # Prefer dirname, but fall back on a substitute if dirname fails.
- dstdir=`
- (dirname "$dst") 2>/dev/null ||
- expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$dst" : 'X\(//\)[^/]' \| \
- X"$dst" : 'X\(//\)$' \| \
- X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
- echo X"$dst" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'
- `
-
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- if (umask $mkdir_umask &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writeable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/d" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix='/';;
- -*) prefix='./';;
- *) prefix='';;
- esac
-
- eval "$initialize_posix_glob"
-
- oIFS=$IFS
- IFS=/
- $posix_glob set -f
- set fnord $dstdir
- shift
- $posix_glob set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test -z "$d" && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
- { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
- { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # If -C, don't bother to copy if it wouldn't change the file.
- if $copy_on_change &&
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
-
- eval "$initialize_posix_glob" &&
- $posix_glob set -f &&
- set X $old && old=:$2:$4:$5:$6 &&
- set X $new && new=:$2:$4:$5:$6 &&
- $posix_glob set +f &&
-
- test "$old" = "$new" &&
- $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
- then
- rm -f "$dsttmp"
- else
- # Rename the file to the real destination.
- $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
- {
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- test ! -f "$dst" ||
- $doit $rmcmd -f "$dst" 2>/dev/null ||
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
- } ||
- { echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- fi || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/m4/acx_pthread.m4
----------------------------------------------------------------------
diff --git a/third_party/libprocess/m4/acx_pthread.m4 \
b/third_party/libprocess/m4/acx_pthread.m4 deleted file mode 100644
index 2cf20de..0000000
--- a/third_party/libprocess/m4/acx_pthread.m4
+++ /dev/null
@@ -1,363 +0,0 @@
-# This was retrieved from
-# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi
-# See also (perhaps for new versions?)
-# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi
-#
-# We've rewritten the inconsistency check code (from avahi), to work
-# more broadly. In particular, it no longer assumes ld accepts -zdefs.
-# This caused a restructing of the code, but the functionality has only
-# changed a little.
-
-dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
-dnl
-dnl @summary figure out how to build C programs using POSIX threads
-dnl
-dnl This macro figures out how to build C programs using POSIX threads.
-dnl It sets the PTHREAD_LIBS output variable to the threads library and
-dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
-dnl C compiler flags that are needed. (The user can also force certain
-dnl compiler flags/libs to be tested by setting these environment
-dnl variables.)
-dnl
-dnl Also sets PTHREAD_CC to any special C compiler that is needed for
-dnl multi-threaded programs (defaults to the value of CC otherwise).
-dnl (This is necessary on AIX to use the special cc_r compiler alias.)
-dnl
-dnl NOTE: You are assumed to not only compile your program with these
-dnl flags, but also link it with them as well. e.g. you should link
-dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
-dnl $LIBS
-dnl
-dnl If you are only building threads programs, you may wish to use
-dnl these variables in your default LIBS, CFLAGS, and CC:
-dnl
-dnl LIBS="$PTHREAD_LIBS $LIBS"
-dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-dnl CC="$PTHREAD_CC"
-dnl
-dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
-dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
-dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
-dnl
-dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
-dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
-dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
-dnl default action will define HAVE_PTHREAD.
-dnl
-dnl Please let the authors know if this macro fails on any platform, or
-dnl if you have any other suggestions or comments. This macro was based
-dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
-dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
-dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
-dnl We are also grateful for the helpful feedback of numerous users.
-dnl
-dnl @category InstalledPackages
-dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
-dnl @version 2006-05-29
-dnl @license GPLWithACException
-dnl
-dnl Checks for GCC shared/pthread inconsistency based on work by
-dnl Marcin Owsiany <marcin@owsiany.pl>
-
-
-AC_DEFUN([ACX_PTHREAD], [
-AC_REQUIRE([AC_CANONICAL_HOST])
-AC_LANG_SAVE
-AC_LANG_C
-acx_pthread_ok=no
-
-# We used to check for pthread.h first, but this fails if pthread.h
-# requires special compiler flags (e.g. on True64 or Sequent).
-# It gets checked for in the link test anyway.
-
-# First of all, check if the user has set any of the PTHREAD_LIBS,
-# etcetera environment variables, and if threads linking works using
-# them:
-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with \
CFLAGS=$PTHREAD_CFLAGS])
- AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
- AC_MSG_RESULT($acx_pthread_ok)
- if test x"$acx_pthread_ok" = xno; then
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
- fi
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-fi
-
-# We must check for the threads library under a number of different
-# names; the ordering is very important because some systems
-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
-# libraries is broken (non-POSIX).
-
-# Create a list of thread flags to try. Items starting with a "-" are
-# C compiler flags, and other items are library names, except for "none"
-# which indicates that we try without any flags at all, and "pthread-config"
-# which is a program returning the flags for the Pth emulation library.
-
-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads \
-mthreads pthread --thread-safe -mt pthread-config"
-
-# The ordering *is* (sometimes) important. Some notes on the
-# individual items follow:
-
-# pthreads: AIX (must check this before -lpthread)
-# none: in case threads are in libc; should be tried before -Kthread and
-# other compiler flags to prevent continual compiler warnings
-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-# -pthreads: Solaris/gcc
-# -mthreads: Mingw32/gcc, Lynx/gcc
-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-# doesn't hurt to check since this sometimes defines pthreads too;
-# also defines -D_REENTRANT)
-# ... -mt is also the pthreads flag for HP/aCC
-# pthread: Linux, etcetera
-# --thread-safe: KAI C++
-# pthread-config: use pthread-config program (for GNU Pth library)
-
-case "${host_cpu}-${host_os}" in
- *solaris*)
-
- # On Solaris (at least, for some versions), libc contains stubbed
- # (non-functional) versions of the pthreads routines, so link-based
- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
- # a function called by this macro, so we could check for that, but
- # who knows whether they'll stub that too in a future libc.) So,
- # we'll just look for -pthreads and -lpthread first:
-
- acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
- ;;
-esac
-
-if test x"$acx_pthread_ok" = xno; then
-for flag in $acx_pthread_flags; do
-
- case $flag in
- none)
- AC_MSG_CHECKING([whether pthreads work without any flags])
- ;;
-
- -*)
- AC_MSG_CHECKING([whether pthreads work with $flag])
- PTHREAD_CFLAGS="$flag"
- ;;
-
- pthread-config)
- AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
- if test x"$acx_pthread_config" = xno; then continue; fi
- PTHREAD_CFLAGS="`pthread-config --cflags`"
- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
- ;;
-
- *)
- AC_MSG_CHECKING([for the pthreads library -l$flag])
- PTHREAD_LIBS="-l$flag"
- ;;
- esac
-
- save_LIBS="$LIBS"
- save_CFLAGS="$CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
- # Check for various functions. We must include pthread.h,
- # since some functions may be macros. (On the Sequent, we
- # need a special flag -Kthread to make this header compile.)
- # We check for pthread_join because it is in -lpthread on IRIX
- # while pthread_create is in libc. We check for pthread_attr_init
- # due to DEC craziness with -lpthreads. We check for
- # pthread_cleanup_push because it is one of the few pthread
- # functions on Solaris that doesn't have a non-functional libc stub.
- # We try pthread_create on general principles.
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [acx_pthread_ok=yes])
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-
- AC_MSG_RESULT($acx_pthread_ok)
- if test "x$acx_pthread_ok" = xyes; then
- break;
- fi
-
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
-done
-fi
-
-# Various other checks:
-if test "x$acx_pthread_ok" = xyes; then
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
- # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
- AC_MSG_CHECKING([for joinable pthread attribute])
- attr_name=unknown
- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
- AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
- [attr_name=$attr; break])
- done
- AC_MSG_RESULT($attr_name)
- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
- AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
- [Define to necessary symbol if this constant
- uses a non-standard name on your system.])
- fi
-
- AC_MSG_CHECKING([if more special flags are required for pthreads])
- flag=no
- case "${host_cpu}-${host_os}" in
- *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
- *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
- esac
- AC_MSG_RESULT(${flag})
- if test "x$flag" != xno; then
- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
- fi
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
- # More AIX lossage: must compile with xlc_r or cc_r
- if test x"$GCC" != xyes; then
- AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
- else
- PTHREAD_CC=$CC
- fi
-
- # The next part tries to detect GCC inconsistency with -shared on some
- # architectures and systems. The problem is that in certain
- # configurations, when -shared is specified, GCC "forgets" to
- # internally use various flags which are still necessary.
-
- #
- # Prepare the flags
- #
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- save_CC="$CC"
-
- # Try with the flags determined by the earlier checks.
- #
- # -Wl,-z,defs forces link-time symbol resolution, so that the
- # linking checks with -shared actually have any value
- #
- # FIXME: -fPIC is required for -shared on many architectures,
- # so we specify it here, but the right way would probably be to
- # properly detect whether it is actually required.
- CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CC="$PTHREAD_CC"
-
- # In order not to create several levels of indentation, we test
- # the value of "$done" until we find the cure or run out of ideas.
- done="no"
-
- # First, make sure the CFLAGS we added are actually accepted by our
- # compiler. If not (and OS X's ld, for instance, does not accept -z),
- # then we can't do this test.
- if test x"$done" = xno; then
- AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
- AC_TRY_LINK(,, , [done=yes])
-
- if test "x$done" = xyes ; then
- AC_MSG_RESULT([no])
- else
- AC_MSG_RESULT([yes])
- fi
- fi
-
- if test x"$done" = xno; then
- AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [done=yes])
-
- if test "x$done" = xyes; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
- fi
-
- #
- # Linux gcc on some architectures such as mips/mipsel forgets
- # about -lpthread
- #
- if test x"$done" = xno; then
- AC_MSG_CHECKING([whether -lpthread fixes that])
- LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [done=yes])
-
- if test "x$done" = xyes; then
- AC_MSG_RESULT([yes])
- PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
- else
- AC_MSG_RESULT([no])
- fi
- fi
- #
- # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
- #
- if test x"$done" = xno; then
- AC_MSG_CHECKING([whether -lc_r fixes that])
- LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [done=yes])
-
- if test "x$done" = xyes; then
- AC_MSG_RESULT([yes])
- PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
- else
- AC_MSG_RESULT([no])
- fi
- fi
- if test x"$done" = xno; then
- # OK, we have run out of ideas
- AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
-
- # so it's not safe to assume that we may use pthreads
- acx_pthread_ok=no
- fi
-
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
- CC="$save_CC"
-else
- PTHREAD_CC="$CC"
-fi
-
-AC_SUBST(PTHREAD_LIBS)
-AC_SUBST(PTHREAD_CFLAGS)
-AC_SUBST(PTHREAD_CC)
-
-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$acx_pthread_ok" = xyes; then
- ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads \
libraries and header files.]),[$1])
- :
-else
- acx_pthread_ok=no
- $2
-fi
-AC_LANG_RESTORE
-])dnl ACX_PTHREAD
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/config.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/config.hpp \
b/third_party/libprocess/src/config.hpp deleted file mode 100644
index 1daa476..0000000
--- a/third_party/libprocess/src/config.hpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef CONFIG_HPP
-#define CONFIG_HPP
-
-#ifdef __sun__
-#define gethostbyname2(name, _) gethostbyname(name)
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-#ifndef SOL_TCP
-#define SOL_TCP IPPROTO_TCP
-#endif
-#ifndef MAP_32BIT
-#define MAP_32BIT 0
-#endif
-#endif /* __sun__ */
-
-#ifdef __APPLE__
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
-#ifndef SOL_TCP
-#define SOL_TCP IPPROTO_TCP
-#endif
-#ifndef MAP_32BIT
-#define MAP_32BIT 0
-#endif
-#define sendfile(s, fd, offset, size) \
- ({ off_t length = size; \
- sendfile(fd, s, offset, &length, NULL, 0) == 0 \
- ? length \
- : (errno == EAGAIN ? (length > 0 ? length : -1) : -1); })
-#endif /* __APPLE__ */
-
-#ifdef __linux__
-#ifndef MAP_32BIT
-#define MAP_32BIT 0
-#endif
-#include <sys/sendfile.h>
-#define sendfile(s, fd, offset, size) \
- ({ off_t _offset = offset; \
- sendfile(s, fd, &_offset, size) == -1 ? -1 : _offset - offset; })
-#endif /* __linux__ */
-
-#endif /* CONFIG_HPP */
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/decoder.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/decoder.hpp \
b/third_party/libprocess/src/decoder.hpp deleted file mode 100644
index 4c29229..0000000
--- a/third_party/libprocess/src/decoder.hpp
+++ /dev/null
@@ -1,412 +0,0 @@
-#ifndef __DECODER_HPP__
-#define __DECODER_HPP__
-
-#include <http_parser.h>
-
-#include <deque>
-#include <string>
-#include <vector>
-
-#include <process/http.hpp>
-#include <process/socket.hpp>
-
-#include <stout/foreach.hpp>
-#include <stout/gzip.hpp>
-#include <stout/try.hpp>
-
-
-// TODO(bmahler): Upgrade our http_parser to the latest version.
-namespace process {
-
-// TODO: Make DataDecoder abstract and make RequestDecoder a concrete subclass.
-class DataDecoder
-{
-public:
- DataDecoder(const Socket& _s)
- : s(_s), failure(false), request(NULL)
- {
- settings.on_message_begin = &DataDecoder::on_message_begin;
- settings.on_header_field = &DataDecoder::on_header_field;
- settings.on_header_value = &DataDecoder::on_header_value;
- settings.on_path = &DataDecoder::on_path;
- settings.on_url = &DataDecoder::on_url;
- settings.on_fragment = &DataDecoder::on_fragment;
- settings.on_query_string = &DataDecoder::on_query_string;
- settings.on_body = &DataDecoder::on_body;
- settings.on_headers_complete = &DataDecoder::on_headers_complete;
- settings.on_message_complete = &DataDecoder::on_message_complete;
-
- http_parser_init(&parser, HTTP_REQUEST);
-
- parser.data = this;
- }
-
- std::deque<http::Request*> decode(const char* data, size_t length)
- {
- size_t parsed = http_parser_execute(&parser, &settings, data, length);
-
- if (parsed != length) {
- failure = true;
- }
-
- if (!requests.empty()) {
- std::deque<http::Request*> result = requests;
- requests.clear();
- return result;
- }
-
- return std::deque<http::Request*>();
- }
-
- bool failed() const
- {
- return failure;
- }
-
- Socket socket() const
- {
- return s;
- }
-
-private:
- static int on_message_begin(http_parser* p)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
-
- assert(!decoder->failure);
-
- decoder->header = HEADER_FIELD;
- decoder->field.clear();
- decoder->value.clear();
- decoder->query.clear();
-
- assert(decoder->request == NULL);
- decoder->request = new http::Request();
- decoder->request->headers.clear();
- decoder->request->method.clear();
- decoder->request->path.clear();
- decoder->request->url.clear();
- decoder->request->fragment.clear();
- decoder->request->query.clear();
- decoder->request->body.clear();
-
- return 0;
- }
-
- static int on_headers_complete(http_parser* p)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
-
- // Add final header.
- decoder->request->headers[decoder->field] = decoder->value;
- decoder->field.clear();
- decoder->value.clear();
-
- decoder->request->method = http_method_str((http_method) \
decoder->parser.method);
- decoder->request->keepAlive = http_should_keep_alive(&decoder->parser);
- return 0;
- }
-
- static int on_message_complete(http_parser* p)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
-// std::cout << "http::Request:" << std::endl;
-// std::cout << " method: " << decoder->request->method << std::endl;
-// std::cout << " path: " << decoder->request->path << std::endl;
- // Parse the query key/values.
- Try<std::string> decoded = http::decode(decoder->query);
- if (decoded.isError()) {
- return 1;
- }
- decoder->request->query = http::query::parse(decoded.get());
-
- Option<std::string> encoding =
- decoder->request->headers.get("Content-Encoding");
- if (encoding.isSome() && encoding.get() == "gzip") {
- Try<std::string> decompressed = gzip::decompress(decoder->request->body);
- if (decompressed.isError()) {
- return 1;
- }
- decoder->request->body = decompressed.get();
- decoder->request->headers["Content-Length"] =
- decoder->request->body.length();
- }
-
- decoder->requests.push_back(decoder->request);
- decoder->request = NULL;
- return 0;
- }
-
- static int on_header_field(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
-
- if (decoder->header != HEADER_FIELD) {
- decoder->request->headers[decoder->field] = decoder->value;
- decoder->field.clear();
- decoder->value.clear();
- }
-
- decoder->field.append(data, length);
- decoder->header = HEADER_FIELD;
-
- return 0;
- }
-
- static int on_header_value(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->value.append(data, length);
- decoder->header = HEADER_VALUE;
- return 0;
- }
-
- static int on_path(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->request->path.append(data, length);
- return 0;
- }
-
- static int on_url(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->request->url.append(data, length);
- return 0;
- }
-
- static int on_query_string(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->query.append(data, length);
- return 0;
- }
-
- static int on_fragment(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->request->fragment.append(data, length);
- return 0;
- }
-
- static int on_body(http_parser* p, const char* data, size_t length)
- {
- DataDecoder* decoder = (DataDecoder*) p->data;
- assert(decoder->request != NULL);
- decoder->request->body.append(data, length);
- return 0;
- }
-
- const Socket s; // The socket this decoder is associated with.
-
- bool failure;
-
- http_parser parser;
- http_parser_settings settings;
-
- enum {
- HEADER_FIELD,
- HEADER_VALUE
- } header;
-
- std::string field;
- std::string value;
- std::string query;
-
- http::Request* request;
-
- std::deque<http::Request*> requests;
-};
-
-
-class ResponseDecoder
-{
-public:
- ResponseDecoder()
- : failure(false), header(HEADER_FIELD), response(NULL)
- {
- settings.on_message_begin = &ResponseDecoder::on_message_begin;
- settings.on_header_field = &ResponseDecoder::on_header_field;
- settings.on_header_value = &ResponseDecoder::on_header_value;
- settings.on_path = &ResponseDecoder::on_path;
- settings.on_url = &ResponseDecoder::on_url;
- settings.on_fragment = &ResponseDecoder::on_fragment;
- settings.on_query_string = &ResponseDecoder::on_query_string;
- settings.on_body = &ResponseDecoder::on_body;
- settings.on_headers_complete = &ResponseDecoder::on_headers_complete;
- settings.on_message_complete = &ResponseDecoder::on_message_complete;
-
- http_parser_init(&parser, HTTP_RESPONSE);
-
- parser.data = this;
- }
-
- std::deque<http::Response*> decode(const char* data, size_t length)
- {
- size_t parsed = http_parser_execute(&parser, &settings, data, length);
-
- if (parsed != length) {
- failure = true;
- }
-
- if (!responses.empty()) {
- std::deque<http::Response*> result = responses;
- responses.clear();
- return result;
- }
-
- return std::deque<http::Response*>();
- }
-
- bool failed() const
- {
- return failure;
- }
-
-private:
- static int on_message_begin(http_parser* p)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
-
- assert(!decoder->failure);
-
- decoder->header = HEADER_FIELD;
- decoder->field.clear();
- decoder->value.clear();
-
- assert(decoder->response == NULL);
- decoder->response = new http::Response();
- decoder->response->status.clear();
- decoder->response->headers.clear();
- decoder->response->type = http::Response::BODY;
- decoder->response->body.clear();
- decoder->response->path.clear();
-
- return 0;
- }
-
- static int on_headers_complete(http_parser* p)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
-
- // Add final header.
- decoder->response->headers[decoder->field] = decoder->value;
- decoder->field.clear();
- decoder->value.clear();
-
- return 0;
- }
-
- static int on_message_complete(http_parser* p)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
-
- // Get the response status string.
- if (http::statuses.contains(decoder->parser.status_code)) {
- decoder->response->status = http::statuses[decoder->parser.status_code];
- } else {
- decoder->failure = true;
- return 1;
- }
-
- // We can only provide the gzip encoding.
- Option<std::string> encoding =
- decoder->response->headers.get("Content-Encoding");
- if (encoding.isSome() && encoding.get() == "gzip") {
- Try<std::string> decompressed = gzip::decompress(decoder->response->body);
- if (decompressed.isError()) {
- decoder->failure = true;
- return 1;
- }
- decoder->response->body = decompressed.get();
- decoder->response->headers["Content-Length"] =
- decoder->response->body.length();
- }
-
- decoder->responses.push_back(decoder->response);
- decoder->response = NULL;
- return 0;
- }
-
- static int on_header_field(http_parser* p, const char* data, size_t length)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
- assert(decoder->response != NULL);
-
- if (decoder->header != HEADER_FIELD) {
- decoder->response->headers[decoder->field] = decoder->value;
- decoder->field.clear();
- decoder->value.clear();
- }
-
- decoder->field.append(data, length);
- decoder->header = HEADER_FIELD;
-
- return 0;
- }
-
- static int on_header_value(http_parser* p, const char* data, size_t length)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
- assert(decoder->response != NULL);
- decoder->value.append(data, length);
- decoder->header = HEADER_VALUE;
- return 0;
- }
-
- static int on_path(http_parser* p, const char* data, size_t length)
- {
- return 0;
- }
-
- static int on_url(http_parser* p, const char* data, size_t length)
- {
- return 0;
- }
-
- static int on_query_string(http_parser* p, const char* data, size_t length)
- {
- return 0;
- }
-
- static int on_fragment(http_parser* p, const char* data, size_t length)
- {
- return 0;
- }
-
- static int on_body(http_parser* p, const char* data, size_t length)
- {
- ResponseDecoder* decoder = (ResponseDecoder*) p->data;
- assert(decoder->response != NULL);
- decoder->response->body.append(data, length);
- return 0;
- }
-
- bool failure;
-
- http_parser parser;
- http_parser_settings settings;
-
- enum {
- HEADER_FIELD,
- HEADER_VALUE
- } header;
-
- std::string field;
- std::string value;
-
- http::Response* response;
-
- std::deque<http::Response*> responses;
-};
-
-
-} // namespace process {
-
-#endif // __DECODER_HPP__
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/encoder.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/encoder.hpp \
b/third_party/libprocess/src/encoder.hpp deleted file mode 100644
index 55aba22..0000000
--- a/third_party/libprocess/src/encoder.hpp
+++ /dev/null
@@ -1,262 +0,0 @@
-#ifndef __ENCODER_HPP__
-#define __ENCODER_HPP__
-
-#include <map>
-#include <sstream>
-
-#include <process/http.hpp>
-#include <process/process.hpp>
-
-#include <stout/foreach.hpp>
-#include <stout/gzip.hpp>
-#include <stout/hashmap.hpp>
-#include <stout/numify.hpp>
-#include <stout/os.hpp>
-
-// NOTE: We forward declare "ev_loop" and "ev_io" here because,
-// on OSX, including "ev.h" causes conflict with "EV_ERROR" declared
-// in "/usr/include/sys/event.h".
-struct ev_loop;
-struct ev_io;
-
-namespace process {
-
-const uint32_t GZIP_MINIMUM_BODY_LENGTH = 1024;
-
-typedef void (*Sender)(struct ev_loop*, ev_io*, int);
-
-extern void send_data(struct ev_loop*, ev_io*, int);
-extern void send_file(struct ev_loop*, ev_io*, int);
-
-
-class Encoder
-{
-public:
- Encoder(const Socket& _s) : s(_s) {}
- virtual ~Encoder() {}
-
- virtual Sender sender() = 0;
-
- Socket socket() const
- {
- return s;
- }
-
-private:
- const Socket s; // The socket this encoder is associated with.
-};
-
-
-class DataEncoder : public Encoder
-{
-public:
- DataEncoder(const Socket& s, const std::string& _data)
- : Encoder(s), data(_data), index(0) {}
-
- virtual ~DataEncoder() {}
-
- virtual Sender sender()
- {
- return send_data;
- }
-
- virtual const char* next(size_t* length)
- {
- size_t temp = index;
- index = data.size();
- *length = data.size() - temp;
- return data.data() + temp;
- }
-
- virtual void backup(size_t length)
- {
- if (index >= length) {
- index -= length;
- }
- }
-
- virtual size_t remaining() const
- {
- return data.size() - index;
- }
-
-private:
- const std::string data;
- size_t index;
-};
-
-
-class MessageEncoder : public DataEncoder
-{
-public:
- MessageEncoder(const Socket& s, Message* _message)
- : DataEncoder(s, encode(_message)), message(_message) {}
-
- virtual ~MessageEncoder()
- {
- if (message != NULL) {
- delete message;
- }
- }
-
- static std::string encode(Message* message)
- {
- if (message != NULL) {
- std::ostringstream out;
-
- out << "POST /" << message->to.id << "/" << message->name
- << " HTTP/1.0\r\n"
- << "User-Agent: libprocess/" << message->from << "\r\n"
- << "Connection: Keep-Alive\r\n";
-
- if (message->body.size() > 0) {
- out << "Transfer-Encoding: chunked\r\n\r\n"
- << std::hex << message->body.size() << "\r\n";
- out.write(message->body.data(), message->body.size());
- out << "\r\n"
- << "0\r\n"
- << "\r\n";
- } else {
- out << "\r\n";
- }
-
- return out.str();
- }
- }
-
-private:
- Message* message;
-};
-
-
-class HttpResponseEncoder : public DataEncoder
-{
-public:
- HttpResponseEncoder(
- const Socket& s,
- const http::Response& response,
- const http::Request& request)
- : DataEncoder(s, encode(response, request)) {}
-
- static std::string encode(
- const http::Response& response,
- const http::Request& request)
- {
- std::ostringstream out;
-
- // TODO(benh): Check version?
-
- out << "HTTP/1.1 " << response.status << "\r\n";
-
- hashmap<std::string, std::string> headers = response.headers;
-
- // HTTP 1.1 requires the "Date" header. In the future once we
- // start checking the version (above) then we can conditionally
- // add this header, but for now, we always do.
- time_t rawtime;
- time(&rawtime);
-
- char date[256];
-
- // TODO(benh): Check return code of strftime!
- strftime(date, 256, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&rawtime));
-
- headers["Date"] = date;
-
- // Should we compress this response?
- std::string body = response.body;
-
- if (response.type == http::Response::BODY &&
- response.body.length() >= GZIP_MINIMUM_BODY_LENGTH &&
- !headers.contains("Content-Encoding") &&
- request.accepts("gzip")) {
- Try<std::string> compressed = gzip::compress(body);
- if (compressed.isError()) {
- LOG(WARNING) << "Failed to gzip response body: " << compressed.error();
- } else {
- body = compressed.get();
- headers["Content-Length"] = stringify(body.length());
- headers["Content-Encoding"] = "gzip";
- }
- }
-
- foreachpair (const std::string& key, const std::string& value, headers) {
- out << key << ": " << value << "\r\n";
- }
-
- // Add a Content-Length header if the response is of type "none"
- // or "body" and no Content-Length header has been supplied.
- if (response.type == http::Response::NONE &&
- !headers.contains("Content-Length")) {
- out << "Content-Length: 0\r\n";
- } else if (response.type == http::Response::BODY &&
- !headers.contains("Content-Length")) {
- out << "Content-Length: " << body.size() << "\r\n";
- }
-
- // Use a CRLF to mark end of headers.
- out << "\r\n";
-
- // Add the body if necessary.
- if (response.type == http::Response::BODY) {
- // If the Content-Length header was supplied, only write as much data
- // as the length specifies.
- Result<uint32_t> length = numify<uint32_t>(headers.get("Content-Length"));
- if (length.isSome() && length.get() <= body.length()) {
- out.write(body.data(), length.get());
- } else {
- out.write(body.data(), body.size());
- }
- }
-
- return out.str();
- }
-};
-
-
-class FileEncoder : public Encoder
-{
-public:
- FileEncoder(const Socket& s, int _fd, size_t _size)
- : Encoder(s), fd(_fd), size(_size), index(0) {}
-
- virtual ~FileEncoder()
- {
- os::close(fd);
- }
-
- virtual Sender sender()
- {
- return send_file;
- }
-
- virtual int next(off_t* offset, size_t* length)
- {
- off_t temp = index;
- index = size;
- *offset = temp;
- *length = size - temp;
- return fd;
- }
-
- virtual void backup(size_t length)
- {
- if (index >= length) {
- index -= length;
- }
- }
-
- virtual size_t remaining() const
- {
- return size - index;
- }
-
-private:
- int fd;
- size_t size;
- off_t index;
-};
-
-} // namespace process {
-
-#endif // __ENCODER_HPP__
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/fatal.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/fatal.cpp \
b/third_party/libprocess/src/fatal.cpp deleted file mode 100644
index b2934e0..0000000
--- a/third_party/libprocess/src/fatal.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-void __fatal(const char *file, int line, const char *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- fprintf(stderr, " (%s:%u)\n", file, line);
- fflush(stderr);
- va_end(args);
- exit(1);
-}
-
-void __fatalerror(const char *file, int line, const char *fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- fprintf(stderr, " (%s:%u): ", file, line);
- perror(NULL);
- fflush(stderr);
- va_end(args);
- exit(1);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/fatal.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/fatal.hpp \
b/third_party/libprocess/src/fatal.hpp deleted file mode 100644
index 38646f3..0000000
--- a/third_party/libprocess/src/fatal.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Basic perror + exit routines.
- *
- * Contributed by Benjamin Hindman <benh@berkeley.edu>, 2008.
- */
-
-#ifndef FATAL_HPP
-#define FATAL_HPP
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
- * Like the non-debug version except includes the file name and line
- * number in the output.
- */
-#define fatal(fmt...) __fatal(__FILE__, __LINE__, fmt)
-void __fatal(const char *file, int line, const char *fmt, ...);
-
-/*
- * Like the non-debug version except includes the file name and line
- * number in the output.
- */
-#define fatalerror(fmt...) __fatalerror(__FILE__, __LINE__, fmt)
-void __fatalerror(const char *file, int line, const char *fmt, ...);
-
-#endif /* FATAL_HPP */
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/gate.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/gate.hpp \
b/third_party/libprocess/src/gate.hpp deleted file mode 100644
index 954f620..0000000
--- a/third_party/libprocess/src/gate.hpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef GATE_H
-#define GATE_H
-
-/* TODO(benh): Provide an implementation directly on-top-of futex's for Linux. */
-//#ifdef __linux__
-//#else
-
-class Gate
-{
-public:
- typedef intptr_t state_t;
-
-private:
- int waiters;
- state_t state;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-
-public:
- Gate() : waiters(0), state(0)
- {
- pthread_mutex_init(&mutex, NULL);
- pthread_cond_init(&cond, NULL);
- }
-
- ~Gate()
- {
- pthread_cond_destroy(&cond);
- pthread_mutex_destroy(&mutex);
- }
-
- void open(bool all = true)
- {
- pthread_mutex_lock(&mutex);
- {
- state++;
- if (all) pthread_cond_broadcast(&cond);
- else pthread_cond_signal(&cond);
- }
- pthread_mutex_unlock(&mutex);
- }
-
- void wait()
- {
- pthread_mutex_lock(&mutex);
- {
- waiters++;
- state_t old = state;
- while (old == state)
- pthread_cond_wait(&cond, &mutex);
- waiters--;
- }
- pthread_mutex_unlock(&mutex);
- }
-
- state_t approach()
- {
- state_t old;
- pthread_mutex_lock(&mutex);
- {
- waiters++;
- old = state;
- }
- pthread_mutex_unlock(&mutex);
- return old;
- }
-
- void arrive(state_t old)
- {
- pthread_mutex_lock(&mutex);
- {
- while (old == state) {
- pthread_cond_wait(&cond, &mutex);
- }
- waiters--;
- }
- pthread_mutex_unlock(&mutex);
- }
-
- void leave()
- {
- pthread_mutex_lock(&mutex);
- {
- waiters--;
- }
- pthread_mutex_unlock(&mutex);
- }
-
- bool empty()
- {
- bool occupied = true;
- pthread_mutex_lock(&mutex);
- {
- occupied = waiters > 0 ? true : false;
- }
- pthread_mutex_unlock(&mutex);
- return !occupied;
- }
-};
-
-//#endif
-
-#endif /* GATE_H */
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/httpd.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/httpd.cpp \
b/third_party/libprocess/src/httpd.cpp deleted file mode 100644
index 793a5b0..0000000
--- a/third_party/libprocess/src/httpd.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/* TODO(benh): TCP_CORK!!!!! */
-/* TODO(benh): Complete HttpParser & HttpMessage implementation. */
-/* TODO(benh): Turn off Nagle (on TCP_NODELAY) for pipelined requests. */
-
-#include <string.h>
-
-#include <process.hpp>
-#include <tuple.hpp>
-
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <stdexcept>
-
-#include <arpa/inet.h>
-
-#include <stout/os.hpp>
-
-#include "net.hpp"
-
-#include "http-parser/http_parser.h"
-
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::runtime_error;
-using std::string;
-using std::map;
-
-using process::tuple::Tuple;
-
-#define malloc(bytes) \
- ({ void *tmp; if ((tmp = malloc(bytes)) == NULL) abort(); tmp; })
-
-#define realloc(address, bytes) \
- ({ void *tmp; if ((tmp = realloc(address, bytes)) == NULL) abort(); tmp; })
-
-#define HTTP_500 \
- "HTTP/1.1 500 Internal Server Error\r\n\r\n"
-
-#define HTTP_501 \
- "HTTP/1.1 501 Not Implemented\r\n\r\n"
-
-#define HTTP_404 \
- "HTTP/1.1 404 Not Found\r\n\r\n"
-
-
-struct HttpMessage
-{
- unsigned short method;
- /* TODO(*): Use HTTP_MAX_URI_SIZE. */
- string uri;
-};
-
-
-class HttpParser
-{
-protected:
- static int on_uri(http_parser *parser, const char *p, size_t len)
- {
- HttpMessage *message = (HttpMessage *) parser->data;
- message->uri += string(p, len);
- return 0;
- }
-
- static int on_headers_complete(http_parser *parser)
- {
- HttpMessage *message = (HttpMessage *) parser->data;
- message->method = parser->method;
- return 0;
- }
-
-public:
- static HttpMessage * parse(const string &raw)
- {
- http_parser parser;
- http_parser_init(&parser, HTTP_REQUEST);
-
- HttpMessage *message = new HttpMessage;
-
- parser.data = message;
-
- parser.on_message_begin = NULL;
- parser.on_header_field = NULL;
- parser.on_header_value = NULL;
- parser.on_path = NULL;
- parser.on_uri = &HttpParser::on_uri;
- parser.on_fragment = NULL;
- parser.on_query_string = NULL;
- parser.on_body = NULL;
- parser.on_headers_complete = &HttpParser::on_headers_complete;
- parser.on_message_complete = NULL;
-
- http_parser_execute(&parser, raw.c_str(), raw.length());
-
- if (http_parser_has_error(&parser)) {
- //cerr << "parser error" << endl;
- abort();
- }
-
- return message;
- }
-};
-
-
-class HttpConnection : public SocketProcess<TCP>
-{
-protected:
- void operator () ()
- {
- //cout << ht_id() << ": running " << this << " connection (1)" << endl;
-
- string raw;
-
- /* Read headers (until CRLF CRLF). */
- do {
- char buf[512];
- ssize_t len = recv(buf, 512);
- raw += string(buf, len);
- } while (raw.find("\r\n\r\n") == string::npos);
-
- //cout << ht_id() << ": running " << this << " connection (2)" << endl;
-
- /* Parse headers. */
- HttpMessage *message = HttpParser::parse(raw);
-
- /* Handle request. */
- switch (message->method) {
- case HTTP_GET: {
- message->uri =
- message->uri != "/"
- ? "." + message->uri
- : "./index.html";
-
- //cout << "URI: " << message->uri << endl;
-
- /* Open file (if possible). */
- int fd;
-
- if ((fd = open(message->uri.c_str(), O_RDONLY, 0)) < 0) {
- send(HTTP_404, strlen(HTTP_404));
- return;
- }
-
- /* Lookup file size. */
- struct stat fd_stat;
-
- if (fstat(fd, &fd_stat) < 0) {
- send(HTTP_500, strlen(HTTP_500));
- os::close(fd);
- return;
- }
-
- /* TODO(benh): Use TCP_CORK. */
-
- /* Transmit reply header. */
- std::stringstream out;
-
- out << "HTTP/1.1 200 OK\r\n";
-
- /* Determine the content type. */
- if (message->uri.find(".jpg") != string::npos) {
- out << "Content-Type: image/jpeg\r\n";
- } else if (message->uri.find(".gif") != string::npos) {
- out << "Content-Type: image/gif\r\n";
- } else if (message->uri.find(".png") != string::npos) {
- out << "Content-Type: image/png\r\n";
- } else if (message->uri.find(".css") != string::npos) {
- out << "Content-Type: text/css\r\n";
- } else {
- out << "Content-Type: text/html\r\n";
- }
-
- out <<
- "Content-Length: " << fd_stat.st_size << "\r\n"
- "\r\n";
-
- //cout << out.str() << endl;
-
- send(out.str().c_str(), out.str().size());
-
- //cout << ht_id() << ": running " << this << " connection (3)" << endl;
-
- /* Transmit file (TODO(benh): Use file cache.). */
- sendfile(fd, fd_stat.st_size);
-
- //cout << ht_id() << ": running " << this << " connection (4)" << endl;
-
- os::close(fd);
-
- break;
- }
-
- default:
- /* Unimplemented. */
- send(HTTP_501, strlen(HTTP_501));
- break;
- }
- }
-
-public:
- HttpConnection(int s) : SocketProcess<TCP>(s) {}
- ~HttpConnection() {}
-};
-
-
-enum HTTP_MESSAGES { ACCEPT = PROCESS_MSGID };
-
-namespace process { namespace tuple { TUPLE(::ACCEPT, (int)); }}
-
-class HttpAcceptor : public Tuple< Acceptor<TCP> >
-{
-private:
- PID server;
-
-protected:
- void operator () ()
- {
- do {
- struct sockaddr_in addr;
- int c = accept(addr);
- //cout << ht_id() << ": running acceptor" << endl;
- send<ACCEPT>(server, c);
- } while (true);
- }
-
-public:
- HttpAcceptor(const PID &_server, int s) : server(_server) { socket(s); }
-};
-
-
-
-class HttpServer : public Tuple< Server<TCP> >
-{
-private:
- map<PID, HttpConnection *> connections;
-
-protected:
- void operator () ()
- {
- int on = 1;
- setsockopt(SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
- bind();
- listen(100000);
-
- HttpAcceptor *acceptor = new HttpAcceptor(self(), s);
- link(spawn(acceptor));
-
- do {
- switch (receive()) {
- case ACCEPT: {
- //cout << ht_id() << ": running server (accept)" << endl;
- int c;
- unpack<ACCEPT>(c);
- HttpConnection *connection = new HttpConnection(c);
- connections[link(spawn(connection))] = connection;
- //cout << "...started (" << connection << ")..." << endl;
- break;
- }
- case PROCESS_EXIT: {
- //cout << ht_id() << ": running server (exit)" << endl;
- if (from() == acceptor->getPID()) {
- throw runtime_error("unimplemented acceptor failure");
- } else if (connections.find(from()) != connections.end()) {
- HttpConnection *connection = connections[from()];
- connections.erase(from());
- delete connection;
- //cout << "...finished (" << connection << ")..." << endl;
- }
- break;
- }
- default:
- cout << "HttpServer received unexpected message" << endl;
- break;
- }
- } while (true);
- }
-
-public:
- HttpServer(int port) { init(INADDR_ANY, port); }
-};
-
-
-
-int main(int argc, char **argv)
-{
- /* TODO(benh): Blah, 'sendfile' doesn't let us use MSG_NOSIGNAL. :( */
- signal(SIGPIPE, SIG_IGN);
-
- if (argc != 2) {
- cerr << "usage: " << argv[0] << " <port>" << endl;
- return -1;
- }
-
-#ifdef USE_LITHE
- ProcessScheduler *scheduler = new ProcessScheduler();
- Process::spawn(new HttpServer(atoi(argv[1])));
- /* TODO(benh): Make Process::wait take and use the hart if using Lithe! */
- for (;;)
- sleep(10000);
-#else
- Process::wait(Process::spawn(new HttpServer(atoi(argv[1]))));
-#endif /* USE_LITHE */
-
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/latch.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/latch.cpp \
b/third_party/libprocess/src/latch.cpp deleted file mode 100644
index a6f1256..0000000
--- a/third_party/libprocess/src/latch.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <process/id.hpp>
-#include <process/latch.hpp>
-#include <process/process.hpp>
-
-#include <stout/duration.hpp>
-
-namespace process {
-
-// TODO(benh): Provide an "optimized" implementation of a latch that
-// is libprocess aware. That is, allow integrate "waiting" on a latch
-// within libprocess such that it doesn't cost a memory allocation, a
-// spawn, a message send, a wait, and two user-space context-switchs.
-
-Latch::Latch()
-{
- triggered = false;
-
- // Deadlock is possible if one thread is trying to delete a latch
- // but the libprocess thread(s) is trying to acquire a resource the
- // deleting thread is holding. Hence, we only save the PID for
- // triggering the latch and let the GC actually do the deleting
- // (thus no waiting is necessary, and deadlocks are avoided).
- pid = spawn(new ProcessBase(ID::generate("__latch__")), true);
-}
-
-
-Latch::~Latch()
-{
- terminate(pid);
-}
-
-
-void Latch::trigger()
-{
- if (!triggered) {
- terminate(pid);
- triggered = true;
- }
-}
-
-
-bool Latch::await(const Duration& duration)
-{
- if (!triggered) {
- process::wait(pid, duration); // Explict to disambiguate.
- // It's possible that we failed to wait because:
- // (1) Our process has already terminated.
- // (2) We timed out (i.e., duration was not "infinite").
-
- // In the event of (1) we might need to return 'true' since a
- // terminated process might imply that the latch has been
- // triggered. To capture this we simply return the value of
- // 'triggered' (which will also capture cases where we actually
- // timed out but have since triggered, which seems like an
- // acceptable semantics given such a "tie").
- return triggered;
- }
-
- return true;
-}
-
-} // namespace process {
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/net.hpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/net.hpp b/third_party/libprocess/src/net.hpp
deleted file mode 100644
index 2fdc62a..0000000
--- a/third_party/libprocess/src/net.hpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/* TODO(benh): Write a form of 'Client' process. */
-
-#ifndef NET_HPP
-#define NET_HPP
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include <process.hpp>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-
-#include <sys/ioctl.h>
-#include <sys/sendfile.h>
-#include <sys/socket.h>
-
-#include <stdexcept>
-#include <iostream>
-
-#include <stout/os.hpp>
-
-typedef enum Protocol { TCP = SOCK_STREAM, UDP = SOCK_DGRAM } Protocol;
-
-using std::runtime_error;
-using std::string;
-
-
-template <Protocol protocol>
-class SocketProcess : public Process
-{
-protected:
- int s;
-
- void setsockopt(int level, int optname, const void *optval, socklen_t optlen)
- {
- if (::setsockopt(s, level, optname, optval, optlen) < 0)
- throw std::runtime_error(string("setsockopt: ") += strerror(errno));
- }
-
- virtual void socket()
- {
- if ((s = ::socket(AF_INET, protocol, IPPROTO_IP)) < 0)
- throw runtime_error(string("socket: ") += strerror(errno));
-
- socket(s);
- }
-
- virtual void socket(int sd)
- {
- s = sd;
-
- int flags = 1;
- if (ioctl(s, FIONBIO, &flags) &&
- ((flags = fcntl(s, F_GETFL, 0)) < 0 ||
- fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0))
- throw runtime_error(string("ioctl/fcntl: ") += strerror(errno));
-
- if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) {
- throw runtime_error(string("fcntl: ") += strerror(errno));
- }
- }
-
- virtual void bind(in_addr_t ip, in_port_t port)
- {
- struct sockaddr_in addr;
- addr.sin_family = PF_INET;
- addr.sin_addr.s_addr = ip;
- addr.sin_port = htons(port);
-
- if (::bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0)
- throw runtime_error(string("bind: ") += strerror(errno));
- }
-
- virtual ssize_t recv(void *buf, size_t bytes)
- {
- ssize_t len = 0;
- do {
- len = ::recv(s, buf, bytes, 0);
-
- if (len > 0)
- return len;
- else if (len < 0 && errno == EWOULDBLOCK)
- while (!await(s, RDONLY));
- else if (len == 0)
- throw runtime_error(string("recv: connection terminated"));
- else
- throw runtime_error(string("recv: ") += strerror(errno));
- } while (!(len > 0));
-
- return len;
- }
-
- virtual ssize_t recvall(void *buf, size_t bytes)
- {
- ssize_t len, offset = 0;
- do {
- len = ::recv(s, (char *) buf + offset, bytes - offset, 0);
-
- if (len > 0)
- offset += len;
- else if (len < 0 && errno == EWOULDBLOCK)
- while (!await(s, RDONLY));
- else if (len == 0)
- throw runtime_error(string("recvall: connection terminated"));
- else
- throw runtime_error(string("recvall: ") += strerror(errno));
- } while (offset != bytes);
-
- return offset;
- }
-
- virtual void send(const void *buf, size_t bytes)
- {
- size_t offset = 0;
- do {
- size_t len =
- ::send(s, (char *) buf + offset, bytes - offset, MSG_NOSIGNAL);
-
- if (len > 0)
- offset += len;
- else if (len < 0 && errno == EWOULDBLOCK)
- while (!await(s, WRONLY));
- else if (len == 0)
- throw runtime_error(string("send: connection terminated"));
- else
- throw runtime_error(string("send: ") += strerror(errno));
- } while (offset != bytes);
- }
-
- virtual void sendfile(int fd, size_t bytes)
- {
- off_t offset = 0;
- do {
- size_t len = ::sendfile(s, fd, 0, bytes - offset);
-
- if (len > 0)
- offset += len;
- else if (len < 0 && errno == EWOULDBLOCK)
- while (!await(s, WRONLY));
- else if (len == 0)
- throw runtime_error(string("sendfile: connection terminated"));
- else
- throw runtime_error(string("sendfile: ") += strerror(errno));
- } while (offset != bytes);
- }
-
-public:
- SocketProcess() : s(-1) {}
- SocketProcess(int _s) : s(_s)
- {
- int flags = 1;
- if (ioctl(s, FIONBIO, &flags) &&
- ((flags = fcntl(s, F_GETFL, 0)) < 0 ||
- fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0))
- throw runtime_error(string("ioctl/fcntl: ") += strerror(errno));
- }
- ~SocketProcess() { os::close(s); }
-};
-
-
-template <Protocol protocol>
-class Acceptor : public SocketProcess<protocol>
-{
-protected:
- virtual int accept(struct sockaddr_in &addr)
- {
- int c;
-
- do {
- while (!await(SocketProcess<protocol>::s, Process::RDONLY));
-
- size_t size = sizeof(struct sockaddr_in);
-
- c = ::accept(SocketProcess<protocol>::s,
- (struct sockaddr *) &addr,
- (socklen_t *) &size);
-
- if (c == 0)
- throw runtime_error(string("accept: ") += strerror(errno));
- else if (c < 0 && (errno != EWOULDBLOCK))
- throw runtime_error(string("accept: ") += strerror(errno));
- } while (!(c > 0));
-
- return c;
- }
-
-public:
- Acceptor() {}
- Acceptor(int s) : SocketProcess<protocol>(s) {}
-};
-
-
-template <Protocol protocol>
-class Server : public Acceptor<protocol>
-{
-protected:
- in_addr_t ip;
- in_port_t port;
-
- void init(in_addr_t _ip = INADDR_ANY, in_port_t _port = 0)
- {
- ip = _ip;
- port = _port;
- SocketProcess<protocol>::socket();
- }
-
- virtual void listen(int n)
- {
- int &s = SocketProcess<protocol>::s;
- if (::listen(s, n) < 0)
- throw runtime_error(string("listen: ") += strerror(errno));
- }
-
- virtual void bind()
- {
- SocketProcess<protocol>::bind(ip, port);
- }
-
-public:
- Server(in_addr_t _ip = INADDR_ANY, in_port_t _port = 0)
- : ip(_ip), port(_port)
- {
- SocketProcess<protocol>::socket();
- }
-};
-
-
-#endif /* NET_HH */
http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/71a01bd9/third_party/libprocess/src/pid.cpp
----------------------------------------------------------------------
diff --git a/third_party/libprocess/src/pid.cpp b/third_party/libprocess/src/pid.cpp
deleted file mode 100644
index 8f32b08..0000000
--- a/third_party/libprocess/src/pid.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-#include <errno.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <arpa/inet.h>
-
-#include <glog/logging.h>
-
-#include <iostream>
-#include <string>
-
-#include <boost/unordered_map.hpp>
-
-#include <process/pid.hpp>
-#include <process/process.hpp>
-
-#include "config.hpp"
-
-#ifdef __APPLE__
-#define gethostbyname2_r(name, af, ret, buf, buflen, result, h_errnop) \
- ({ *(result) = gethostbyname2(name, af); 0; })
-#endif // __APPLE__
-
-
-using std::istream;
-using std::ostream;
-using std::size_t;
-using std::string;
-
-
-namespace process {
-
-UPID::UPID(const char* s)
-{
- std::istringstream in(s);
- in >> *this;
-}
-
-
-UPID::UPID(const std::string& s)
-{
- std::istringstream in(s);
- in >> *this;
-}
-
-
-// TODO(benh): Make this inline-able (cyclic dependency issues).
-UPID::UPID(const ProcessBase& process)
-{
- id = process.self().id;
- ip = process.self().ip;
- port = process.self().port;
-}
-
-
-UPID::operator std::string() const
-{
- std::ostringstream out;
- out << *this;
- return out.str();
-}
-
-
-ostream& operator << (ostream& stream, const UPID& pid)
-{
- // Call inet_ntop since inet_ntoa is not thread-safe!
- char ip[INET_ADDRSTRLEN];
- if (inet_ntop(AF_INET, (in_addr *) &pid.ip, ip, INET_ADDRSTRLEN) == NULL)
- memset(ip, 0, INET_ADDRSTRLEN);
-
- stream << pid.id << "@" << ip << ":" << pid.port;
- return stream;
-}
-
-
-istream& operator >> (istream& stream, UPID& pid)
-{
- pid.id = "";
- pid.ip = 0;
- pid.port = 0;
-
- string str;
- if (!(stream >> str)) {
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- VLOG(2) << "Attempting to parse '" << str << "' into a PID";
-
- if (str.size() == 0) {
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- string id;
- string host;
- uint32_t ip;
- uint16_t port;
-
- size_t index = str.find('@');
-
- if (index != string::npos) {
- id = str.substr(0, index);
- } else {
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- str = str.substr(index + 1);
-
- index = str.find(':');
-
- if (index != string::npos) {
- host = str.substr(0, index);
- } else {
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- hostent he, *hep;
- char* temp;
- size_t length;
- int result;
- int herrno;
-
- // Allocate temporary buffer for gethostbyname2_r.
- length = 1024;
- temp = new char[length];
-
- while ((result = gethostbyname2_r(host.c_str(), AF_INET, &he,
- temp, length, &hep, &herrno)) == ERANGE) {
- // Enlarge the buffer.
- delete[] temp;
- length *= 2;
- temp = new char[length];
- }
-
- if (result != 0 || hep == NULL) {
- VLOG(2) << "Failed to parse host '" << host
- << "' because " << hstrerror(herrno);
- delete[] temp;
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- if (hep->h_addr_list[0] == NULL) {
- VLOG(2) << "Got no addresses for '" << host << "'";
- delete[] temp;
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- ip = *((uint32_t*) hep->h_addr_list[0]);
-
- delete[] temp;
-
- str = str.substr(index + 1);
-
- if (sscanf(str.c_str(), "%hu", &port) != 1) {
- stream.setstate(std::ios_base::badbit);
- return stream;
- }
-
- pid.id = id;
- pid.ip = ip;
- pid.port = port;
-
- return stream;
-}
-
-
-size_t hash_value(const UPID& pid)
-{
- size_t seed = 0;
- boost::hash_combine(seed, pid.id);
- boost::hash_combine(seed, pid.ip);
- boost::hash_combine(seed, pid.port);
- return seed;
-}
-
-} // namespace process {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic