├── WebBench ├── debian │ ├── dirs │ ├── copyright │ ├── control │ ├── rules │ └── changelog ├── build.sh ├── test.sh ├── webbench ├── bin │ └── webbench ├── share │ └── doc │ │ └── webbench │ │ ├── copyright │ │ └── changelog ├── README.md ├── Makefile ├── socket.c ├── webbench.1 ├── man │ └── man1 │ │ └── webbench.1 ├── tags └── webbench.c ├── _config.yml ├── WebServer ├── tests │ ├── CMakeLists.txt │ ├── build │ │ └── release │ │ │ ├── CMakeFiles │ │ │ ├── cmake.check_cache │ │ │ ├── 2.8.12.2 │ │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ │ ├── CMakeSystem.cmake │ │ │ │ ├── CMakeCCompiler.cmake │ │ │ │ ├── CMakeCXXCompiler.cmake │ │ │ │ ├── CompilerIdCXX │ │ │ │ │ └── CMakeCXXCompilerId.cpp │ │ │ │ └── CompilerIdC │ │ │ │ │ └── CMakeCCompilerId.c │ │ │ ├── CMakeError.log │ │ │ └── CMakeOutput.log │ │ │ └── CMakeCache.txt │ └── HTTPClient.cpp ├── base │ ├── noncopyable.h │ ├── CMakeLists.txt │ ├── CountDownLatch.h │ ├── CountDownLatch.cpp │ ├── CurrentThread.h │ ├── MutexLock.h │ ├── Thread.h │ ├── Condition.h │ └── Thread.cpp ├── CMakeLists.txt ├── Util.h ├── EventLoopThread.h ├── EventLoopThreadPool.h ├── Server.h ├── Main.cpp ├── EventLoopThreadPool.cpp ├── Channel.cpp ├── Epoll.h ├── EventLoopThread.cpp ├── ThreadPool.h ├── Timer.h ├── EventLoop.h ├── Server.cpp ├── Timer.cpp ├── Channel.h ├── HttpData.h ├── EventLoop.cpp ├── Epoll.cpp ├── ThreadPool.cpp ├── Util.cpp └── HttpData.cpp ├── .travis.yml ├── .gitignore ├── 项目架构.md ├── CMakeLists.txt ├── LICENSE ├── WebServer的监测和调试.md ├── README.md └── webserver_test.jmx /WebBench/debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker -------------------------------------------------------------------------------- /WebBench/build.sh: -------------------------------------------------------------------------------- 1 | sudo make && sudo make install PREFIX=. -------------------------------------------------------------------------------- /WebServer/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(HTTPClient HTTPClient.cpp) -------------------------------------------------------------------------------- /WebBench/test.sh: -------------------------------------------------------------------------------- 1 | ./bin/webbench -t 60 -c 1000 -2 --get http://127.0.0.1:8888/hello 2 | -------------------------------------------------------------------------------- /WebBench/webbench: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grasslog/WebServer/HEAD/WebBench/webbench -------------------------------------------------------------------------------- /WebBench/bin/webbench: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grasslog/WebServer/HEAD/WebBench/bin/webbench -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grasslog/WebServer/HEAD/WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grasslog/WebServer/HEAD/WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /WebServer/base/noncopyable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class noncopyable 4 | { 5 | protected: 6 | noncopyable() {} 7 | ~noncopyable() {} 8 | private: 9 | noncopyable(const noncopyable&); 10 | const noncopyable& operator=(const noncopyable&); 11 | }; -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: required 3 | dist: trusty 4 | compiler: 5 | - g++ 6 | os: 7 | - linux 8 | install: 9 | - sudo apt-get install cmake 10 | env: 11 | - BUILD_TYPE=debug 12 | - BUILD_TYPE=release 13 | script: 14 | - ./build.sh -------------------------------------------------------------------------------- /WebBench/debian/copyright: -------------------------------------------------------------------------------- 1 | Webbench was written by Radim Kolar 1997-2004 (hsn@netmag.cz). 2 | 3 | UNIX sockets code (socket.c) taken from popclient 1.5 4/1/94 4 | public domain code, created by Virginia Tech Computing Center. 5 | 6 | Copyright: GPL (see /usr/share/common-licenses/GPL) 7 | -------------------------------------------------------------------------------- /WebServer/base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIB_SRC 2 | CountDownLatch.cpp 3 | Thread.cpp 4 | ) 5 | 6 | add_library(libserver_base ${LIB_SRC}) 7 | target_link_libraries(libserver_base pthread rt) 8 | 9 | set_target_properties(libserver_base PROPERTIES OUTPUT_NAME "server_base") 10 | -------------------------------------------------------------------------------- /WebBench/share/doc/webbench/copyright: -------------------------------------------------------------------------------- 1 | Webbench was written by Radim Kolar 1997-2004 (hsn@netmag.cz). 2 | 3 | UNIX sockets code (socket.c) taken from popclient 1.5 4/1/94 4 | public domain code, created by Virginia Tech Computing Center. 5 | 6 | Copyright: GPL (see /usr/share/common-licenses/GPL) 7 | -------------------------------------------------------------------------------- /WebServer/base/CountDownLatch.h: -------------------------------------------------------------------------------- 1 | #pragma ocne 2 | #include "Condition.h" 3 | #include "MutexLock.h" 4 | #include "noncopyable.h" 5 | 6 | class CountDownLatch : noncopyable 7 | { 8 | public: 9 | explicit CountDownLatch(int count); 10 | void wait(); 11 | void countDown(); 12 | 13 | private: 14 | mutable MutexLock mutex_; 15 | Condition condition_; 16 | int count_; 17 | }; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | *.vscode 14 | *.idea 15 | ./cmake-build-debug/* 16 | 17 | # Compiled Dynamic libraries 18 | *.so 19 | *.dylib 20 | *.dll 21 | 22 | # Fortran module files 23 | *.mod 24 | *.smod 25 | 26 | # Compiled Static libraries 27 | *.lai 28 | *.la 29 | *.a 30 | *.lib 31 | 32 | # Executables 33 | *.exe 34 | *.out 35 | *.app 36 | -------------------------------------------------------------------------------- /WebServer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCS 2 | Channel.cpp 3 | Epoll.cpp 4 | EventLoop.cpp 5 | EventLoopThread.cpp 6 | EventLoopThreadPool.cpp 7 | HttpData.cpp 8 | Main.cpp 9 | Server.cpp 10 | #ThreadPool.cpp 11 | Timer.cpp 12 | Util.cpp 13 | ) 14 | include_directories(${PROJECT_SOURCE_DIR}/base) 15 | 16 | 17 | add_executable(WebServer ${SRCS}) 18 | target_link_libraries(WebServer libserver_base) 19 | 20 | 21 | add_subdirectory(base) 22 | add_subdirectory(tests) -------------------------------------------------------------------------------- /WebServer/base/CountDownLatch.cpp: -------------------------------------------------------------------------------- 1 | #include "CountDownLatch.h" 2 | 3 | CountDownLatch::CountDownLatch(int count) 4 | : mutex_(), 5 | condition_(mutex_), 6 | count_(count) 7 | { } 8 | 9 | void CountDownLatch::wait() 10 | { 11 | MutexLockGuard lock(mutex_); 12 | while (count_ > 0) 13 | condition_.wait(); 14 | } 15 | 16 | void CountDownLatch::countDown() 17 | { 18 | MutexLockGuard lock(mutex_); 19 | --count_; 20 | if (count_ == 0) 21 | condition_.notifyAll(); 22 | } -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-4.4.0-112-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "4.4.0-112-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-4.4.0-112-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "4.4.0-112-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /WebBench/debian/control: -------------------------------------------------------------------------------- 1 | Source: webbench 2 | Section: web 3 | Priority: extra 4 | Maintainer: Radim Kolar 5 | Build-Depends: debhelper (>> 3.0.0) 6 | Standards-Version: 3.5.2 7 | 8 | Package: webbench 9 | Architecture: any 10 | Depends: ${shlibs:Depends} 11 | Description: Simple forking Web benchmark 12 | webbench is very simple program for benchmarking WWW or Proxy servers. 13 | Uses fork() for simulating multiple clients load. Can use HTTP 0.9 - 1.1 14 | requests, but Keep-Alive connections are not supported. 15 | -------------------------------------------------------------------------------- /WebServer/Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | ssize_t readn(int fd, void *buff, size_t n); 6 | ssize_t readn(int fd, std::string &inBuffer, bool &zero); 7 | ssize_t readn(int fd, std::string &inBuffer); 8 | ssize_t writen(int fd, void *buff, size_t n); 9 | ssize_t writen(int fd, std::string &sbuff); 10 | void handle_for_sigpipe(); 11 | int setSocketNonBlocking(int fd); 12 | void setSocketNodelay(int fd); 13 | void setSocketNolinger(int fd); 14 | void shutDownWR(int fd); 15 | int socket_bind_listen(int port); -------------------------------------------------------------------------------- /WebServer/EventLoopThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base/Condition.h" 3 | #include "base/MutexLock.h" 4 | #include "base/Thread.h" 5 | #include "base/noncopyable.h" 6 | #include "EventLoop.h" 7 | 8 | // worker thread pool which manage work thread create,join and cancel. 9 | class EventLoopThread : noncopyable 10 | { 11 | public: 12 | EventLoopThread(); 13 | ~EventLoopThread(); 14 | EventLoop* startLoop(); 15 | 16 | private: 17 | void threadFunc(); 18 | EventLoop *loop_; 19 | bool exiting_; 20 | Thread thread_; 21 | MutexLock mutex_; 22 | Condition cond_; 23 | }; -------------------------------------------------------------------------------- /WebServer/EventLoopThreadPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base/noncopyable.h" 3 | #include "EventLoopThread.h" 4 | #include 5 | #include 6 | 7 | class EventLoopThreadPool : noncopyable 8 | { 9 | public: 10 | EventLoopThreadPool(EventLoop* baseLoop, int numThreads); 11 | 12 | ~EventLoopThreadPool() 13 | { 14 | //LOG << "~EventLoopThreadPool()"; 15 | } 16 | void start(); 17 | 18 | EventLoop *getNextLoop(); 19 | 20 | private: 21 | EventLoop* baseLoop_; 22 | bool started_; 23 | int numThreads_; 24 | int next_; 25 | std::vector> threads_; 26 | std::vector loops_; 27 | }; -------------------------------------------------------------------------------- /项目架构.md: -------------------------------------------------------------------------------- 1 | ## 项目的架构 2 | I/O多路复用(事件分配器) + 非阻塞I/O + 主线程(处理请求) + 工作线程池(读、计算。写) + eventloop,即Reactor反应堆模式 3 | ### 处理流程 4 | - 创建主线程(主线程注册I/O事件)监听请求并维持eventloop,创建工作线程池处理后续事件并维持eventloop 5 | - 监听到请求,主线程从阻塞的eventloop唤醒,处理连接请求并以I/O事件封装给工作线程池(轮回的方式分配)的任务队列,每次都会通过TimeManager处理超时的请求并关闭清除 6 | - 工作线程从eventloop唤醒,工作线程处理后续操作,读,计算解析http报文(状态机),写(根据解析的结果返回http应答(如果出现错误可选泽关闭连接)),服务器可选择关闭连接(长连接或短连接)每次都会通过TimeManager处理超时的请求并关闭清除 注:根据不同的情况优雅的关闭连接,而不是暴力的close 7 | ### 一个请求进来出去的细节 8 | ![image](https://github.com/before25tofree/Images/blob/master/WebServer/Main.png) 9 | ### 项目框架图 10 | ![image](https://github.com/before25tofree/Images/blob/master/WebServer/WebServer.PNG) 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(WebServer CXX) 4 | 5 | if(NOT CMAKE_BUILD_TYPE) 6 | set(CMAKE_BUILD_TYPE "Release") 7 | endif() 8 | 9 | set(CXX_FLAGS 10 | -g 11 | -O0 12 | -Wall 13 | -std=c++11 14 | -D_PTHREADS 15 | -Wno-unused-parameter 16 | ) 17 | 18 | 19 | set(CMAKE_CXX_COMPILER "g++") 20 | set(CMAKE_CXX_FLAGS_DEBUG "-O0") 21 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") 22 | 23 | string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}") 24 | 25 | 26 | string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) 27 | message(STATUS "CXX_FLAGS = " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_${BUILD_TYPE}}) 28 | 29 | add_subdirectory(WebServer) -------------------------------------------------------------------------------- /WebServer/Server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "EventLoop.h" 3 | #include "Channel.h" 4 | #include "EventLoopThreadPool.h" 5 | #include 6 | 7 | class Server 8 | { 9 | public: 10 | Server(EventLoop *loop, int threadNum, int port); 11 | ~Server() { } 12 | EventLoop* getLoop() const { return loop_; } 13 | void start(); 14 | void handNewConn(); 15 | void handThisConn() { loop_->updatePoller(acceptChannel_); } 16 | 17 | private: 18 | EventLoop *loop_; 19 | int threadNum_; 20 | std::unique_ptr eventLoopThreadPool_; 21 | bool started_; 22 | std::shared_ptr acceptChannel_; 23 | int port_; 24 | int listenFd_; 25 | static const int MAXFDS = 100000; 26 | }; -------------------------------------------------------------------------------- /WebServer/base/CurrentThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace CurrentThread 5 | { 6 | // internal 7 | extern __thread int t_cachedTid; 8 | extern __thread char t_tidString[32]; 9 | extern __thread int t_tidStringLength; 10 | extern __thread const char* t_threadName; 11 | void cacheTid(); 12 | inline int tid() 13 | { 14 | if(__builtin_expect(t_cachedTid == 0,0)) 15 | { 16 | cacheTid(); 17 | } 18 | return t_cachedTid; 19 | } 20 | 21 | inline const char* tidString() 22 | { 23 | return t_tidString; 24 | } 25 | 26 | inline int tidStringLength() 27 | { 28 | return t_tidStringLength; 29 | } 30 | 31 | inline const char* name() 32 | { 33 | return t_threadName; 34 | } 35 | } -------------------------------------------------------------------------------- /WebServer/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "EventLoop.h" 2 | #include "Server.h" 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | int threadNum = 4; 9 | int port = 8888; 10 | std::string logPath = "./WebServer.log"; 11 | 12 | int opt; 13 | const char *str = "t:p:"; 14 | while((opt = getopt(argc, argv, str)) != -1) 15 | { 16 | switch(opt) 17 | { 18 | case 't': 19 | { 20 | threadNum = atoi(optarg); 21 | break; 22 | } 23 | case 'p': 24 | { 25 | port = atoi(optarg); 26 | break; 27 | } 28 | default: break; 29 | } 30 | } 31 | 32 | #ifndef _PTHREADS 33 | //LOG << "_PTHREADS is not defined !"; 34 | #endif 35 | EventLoop mainLoop; 36 | Server myHTTPServer(&mainLoop, threadNum, port); 37 | myHTTPServer.start(); 38 | mainLoop.loop(); 39 | return 0; 40 | } -------------------------------------------------------------------------------- /WebServer/EventLoopThreadPool.cpp: -------------------------------------------------------------------------------- 1 | #include "EventLoopThreadPool.h" 2 | 3 | EventLoopThreadPool::EventLoopThreadPool(EventLoop* baseLoop, int numThreads) 4 | : baseLoop_(baseLoop), 5 | started_(false), 6 | numThreads_(numThreads), 7 | next_(0) 8 | { 9 | if(numThreads_ <= 0) 10 | { 11 | //LOG << "numThreads_ <= 0"; 12 | abort(); 13 | } 14 | } 15 | 16 | void EventLoopThreadPool::start() 17 | { 18 | baseLoop_->assertInLoopThread(); 19 | started_ = true; 20 | for(int i=0; i t(new EventLoopThread()); 23 | threads_.push_back(t); 24 | loops_.push_back(t->startLoop()); 25 | } 26 | } 27 | 28 | EventLoop *EventLoopThreadPool::getNextLoop() 29 | { 30 | baseLoop_->assertInLoopThread(); 31 | assert(started_); 32 | EventLoop *loop = baseLoop_; 33 | if(!loops_.empty()) 34 | { 35 | loop = loops_[next_]; 36 | next_ = (next_ + 1) % numThreads_; 37 | } 38 | return loop; 39 | } -------------------------------------------------------------------------------- /WebServer/base/MutexLock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "noncopyable.h" 3 | #include 4 | #include 5 | 6 | class MutexLock: noncopyable 7 | { 8 | public: 9 | MutexLock() 10 | { 11 | pthread_mutex_init(&mutex, NULL); 12 | } 13 | ~MutexLock() 14 | { 15 | pthread_mutex_lock(&mutex); 16 | pthread_mutex_destroy(&mutex); 17 | } 18 | 19 | void lock() 20 | { 21 | pthread_mutex_lock(&mutex); 22 | } 23 | void unlock() 24 | { 25 | pthread_mutex_unlock(&mutex); 26 | } 27 | pthread_mutex_t* get() 28 | { 29 | return &mutex; 30 | } 31 | private: 32 | pthread_mutex_t mutex; 33 | 34 | // no limit for friend class member 35 | friend class Condition; 36 | }; 37 | 38 | class MutexLockGuard: noncopyable 39 | { 40 | public: 41 | explicit MutexLockGuard(MutexLock& _mutex) 42 | : mutex(_mutex) 43 | { 44 | mutex.lock(); 45 | } 46 | ~MutexLockGuard() 47 | { 48 | mutex.unlock(); 49 | } 50 | private: 51 | MutexLock& mutex; 52 | }; -------------------------------------------------------------------------------- /WebServer/base/Thread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CountDownLatch.h" 3 | #include "noncopyable.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class Thread : noncopyable 12 | { 13 | public: 14 | typedef std::function ThreadFunc; 15 | explicit Thread(const ThreadFunc&, const std::string& name = std::string()); 16 | ~Thread(); 17 | void start(); 18 | int join(); 19 | bool started() const { return started_;} 20 | pid_t tid() const { return tid_; } 21 | const std::string& name() const { return name_; } 22 | 23 | private: 24 | void setDefaultName(); 25 | bool started_; 26 | bool joined_; 27 | pthread_t pthreadId_; 28 | pid_t tid_; 29 | ThreadFunc func_; // the exactly callback from EventLoopThread's ThreadFunc which run work in loop 30 | std::string name_; 31 | CountDownLatch latch_; // the signal, Be sure thread really could run the callback function 32 | }; -------------------------------------------------------------------------------- /WebServer/base/Condition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "noncopyable.h" 3 | #include "MutexLock.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Condition: noncopyable 10 | { 11 | public: 12 | explicit Condition(MutexLock& _mutex) 13 | : mutex(_mutex) 14 | { 15 | pthread_cond_init(&cond, NULL); 16 | } 17 | ~Condition() 18 | { 19 | pthread_cond_destroy(&cond); 20 | } 21 | void wait() 22 | { 23 | pthread_cond_wait(&cond, mutex.get()); 24 | } 25 | void notify() 26 | { 27 | pthread_cond_signal(&cond); 28 | } 29 | void notifyAll() 30 | { 31 | pthread_cond_broadcast(&cond); 32 | } 33 | bool waitForSeconds(int seconds) 34 | { 35 | struct timespec abstime; 36 | clock_gettime(CLOCK_REALTIME, &abstime); 37 | abstime.tv_sec += static_cast(seconds); 38 | return ETIMEDOUT == pthread_cond_timedwait(&cond, mutex.get(), &abstime); 39 | } 40 | private: 41 | MutexLock &mutex; 42 | pthread_cond_t cond; 43 | }; 44 | -------------------------------------------------------------------------------- /WebServer/Channel.cpp: -------------------------------------------------------------------------------- 1 | #include "Channel.h" 2 | #include "Util.h" 3 | #include "Epoll.h" 4 | #include "EventLoop.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | //Channel中eventLoop以及fd的用处,在后面会体现 12 | Channel::Channel(EventLoop *loop) 13 | : loop_(loop), 14 | events_(0), 15 | lastEvents_(0) 16 | { } 17 | 18 | Channel::Channel(EventLoop *loop, int fd) 19 | : loop_(loop), 20 | fd_(fd), 21 | events_(0), 22 | lastEvents_(0) 23 | { } 24 | 25 | Channel::~Channel() 26 | { 27 | 28 | } 29 | 30 | int Channel::getFd() 31 | { 32 | return fd_; 33 | } 34 | 35 | void Channel::setFd(int fd) 36 | { 37 | fd_ = fd; 38 | } 39 | 40 | void Channel::handleRead() 41 | { 42 | if(readHandler_) 43 | { 44 | readHandler_(); 45 | } 46 | } 47 | 48 | void Channel::handleWrite() 49 | { 50 | if(writeHandler_) 51 | { 52 | writeHandler_(); 53 | } 54 | } 55 | 56 | void Channel::handleConn() 57 | { 58 | if(connHandler_) 59 | { 60 | connHandler_(); 61 | } 62 | } -------------------------------------------------------------------------------- /WebServer/Epoll.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Channel.h" 3 | #include "HttpData.h" 4 | #include "Timer.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class Epoll 11 | { 12 | public: 13 | Epoll(); 14 | ~Epoll(); 15 | // 对应了epoll_ctl对内核I/O事件监测红黑树的操作 16 | void epoll_add(SP_Channel request, int timeout); 17 | void epoll_mod(SP_Channel request, int timeout); 18 | void epoll_del(SP_Channel request); 19 | // I/O事件vector集合 20 | std::vector> poll(); 21 | std::vector> getEventsRequest(int events_num); 22 | // 添加请求事件 23 | void add_timer(std::shared_ptr request_data, int timeout); 24 | int getEpollfd() 25 | { 26 | return epollFd_; 27 | } 28 | void handleExpired(); 29 | private: 30 | static const int MAXFDS = 100000; 31 | int epollFd_; 32 | std::vector events_; // 返回的事件结果vector集合 33 | std::shared_ptr fd2chan_[MAXFDS]; // 记录事件 34 | std::shared_ptr fd2http_[MAXFDS]; // 记录httpdata 35 | TimerManager timerManager_; 36 | }; -------------------------------------------------------------------------------- /WebServer/EventLoopThread.cpp: -------------------------------------------------------------------------------- 1 | #include "EventLoopThread.h" 2 | #include 3 | 4 | EventLoopThread::EventLoopThread() 5 | : loop_(NULL), 6 | exiting_(false), 7 | thread_(bind(&EventLoopThread::threadFunc, this), "EventLoopThread"), 8 | mutex_(), 9 | cond_(mutex_) 10 | { } 11 | 12 | EventLoopThread::~EventLoopThread() 13 | { // when the thread exit do loop_ quit and thread_ join. 14 | exiting_ = true; 15 | if(loop_ != NULL) 16 | { 17 | loop_->quit(); 18 | thread_.join(); 19 | } 20 | } 21 | 22 | // That is the ThreadFunc really does the work eventLoop 23 | EventLoop* EventLoopThread::startLoop() 24 | { 25 | assert(!thread_.started()); 26 | thread_.start(); 27 | { 28 | MutexLockGuard lock(mutex_); 29 | while(loop_ == NULL) // make sure the callback function has been maked. 30 | cond_.wait(); 31 | } 32 | return loop_; 33 | } 34 | 35 | // That is the thread which really runs event loop 36 | void EventLoopThread::threadFunc() 37 | { 38 | EventLoop loop; 39 | 40 | { 41 | MutexLockGuard lock(mutex_); 42 | loop_ = &loop; 43 | cond_.notify(); // as to cond_.wait 44 | } 45 | 46 | loop.loop(); 47 | loop_ = NULL; 48 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 before25tofree 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /WebServer的监测和调试.md: -------------------------------------------------------------------------------- 1 | # WebServer的监测和调试 2 | 3 | ## tcpdump 4 | tcpdump是一款经典的网络抓包工具 5 | $sudo tcpdump tcp port 8888 and host 127.0.0.1 6 | 监测所有经过主机127.0.0.1端口8888的tcp数据包 7 | ## lsof(list open file) 8 | lsof是一个列出当前系统打开的文件描述符的工具。通过它我们可以了解感兴趣的进程打开了哪些文件描述符,或者我们感兴趣的文件描述符被哪些进程打开了。 9 | 10 | $ lsof -c WebServer 11 | ## nc(netcat) 12 | 命令短小精干、功能强大,它主要被用来快速构建网络连接。我们可以让它以服务器的方式运行,监听某个端口并接受客户连接,我们也可以让它以客户端的方式运行,向服务器发送连接并接受数据。 13 | 14 | $ nc -C 127.0.0.1 8888 15 | GET http://localhost:/8888/hello HTTP/1.1 16 | Host: localhost 17 | 18 | HTTP/1.1 404 Bad request 19 | Content-Length: 49 20 | Connection: close 21 | ## strace 22 | starce是测试服务器性能的重要工具。它跟踪程序运行过程中执行的系统调用和接收到的信号,并将系统调用名、参数、返回值及信号名输出到标准输出或指定的文件。 23 | 24 | $ strace -p pid 25 | ## netstat 26 | netstat是一个强大的网络信息统计工具,他可以打印本地网卡接口上的全部链接、路由表信息、网卡接口信息等等。 27 | 28 | $ netstat -nat | grep 127.0.0.1:8888 29 | ## vmstat 30 | vmstat是virtual memory statistics的缩写,它能实时输出系统的各种资源的使用情况,比如进程信息、内存使用、CPU使用率以及I/O使用情况。 31 | 32 | $ vmstat 5 3 33 | ## ifstat 34 | ifstat是interface statistics的缩写,它是一个简单的网络流量监测工具 35 | 36 | $ ifstat -a 2 5 37 | ## mpstat 38 | mapstat是mutil-processor statictics的缩写,他能实时的监测多处理器系统中每个CPU的使用情况。 39 | 40 | $ mpstat -P ALL 5 2 41 | -------------------------------------------------------------------------------- /WebBench/README.md: -------------------------------------------------------------------------------- 1 | # WebBench 2 | 3 | Webbench是一个在linux下使用的非常简单的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模拟3万个并发连接去测试网站的负载能力。 4 | 5 | ## 依赖 6 | ctags 7 | 8 | ## 使用: 9 | 10 | sudo make && sudo make install PREFIX=your_path_to_webbench 11 | 12 | ## 命令行选项: 13 | 14 | 15 | 16 | 17 | | 短参 | 长参数 | 作用 | 18 | | ------------- |:-------------:| -----:| 19 | |-f |--force |不需要等待服务器响应 | 20 | |-r |--reload |发送重新加载请求 | 21 | |-t |--time |运行多长时间,单位:秒" | 22 | |-p |--proxy |使用代理服务器来发送请求 | 23 | |-c |--clients |创建多少个客户端,默认1个" | 24 | |-9 |--http09 |使用 HTTP/0.9 | 25 | |-1 |--http10 |使用 HTTP/1.0 协议 | 26 | |-2 |--http11 |使用 HTTP/1.1 协议 | 27 | | |--get |使用 GET请求方法 | 28 | | |--head |使用 HEAD请求方法 | 29 | | |--options |使用 OPTIONS请求方法 | 30 | | |--trace |使用 TRACE请求方法 | 31 | |-?/-h |--help |打印帮助信息 | 32 | |-V |--version |显示版本号 | 33 | -------------------------------------------------------------------------------- /WebServer/ThreadPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Channel.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | const int THREADPOOL_INVALID = -1; 9 | const int THREADPOOL_LOCK_FAILURE = -2; 10 | const int THREADPOOL_QUEUE_FULL = -3; 11 | const int THREADPOOL_SHUTDOWN = -4; 12 | const int THREADPOOL_THREAD_FAILURE = -5; 13 | const int THREADPOOL_GRACEFUL = 1; 14 | 15 | const int MAX_THREADS = 1024; 16 | const int MAX_QUEUE = 65535; 17 | 18 | typedef enum 19 | { 20 | immediate_shutdown = 1, 21 | graceful_shutdown = 2 22 | } ShutDownOption; 23 | 24 | struct ThreadPoolTask 25 | { 26 | std::function)> fun; 27 | std::shared_ptr args; 28 | }; 29 | 30 | class ThreadPool 31 | { 32 | private: 33 | static pthread_mutex_t lock; 34 | static pthread_cond_t notify; 35 | 36 | static std::vector threads; 37 | static std::vector queue; 38 | static int thread_count; 39 | static int queue_size; 40 | static int head; 41 | static int tail; 42 | static int count; 43 | static int shutdown; 44 | static int started; 45 | public: 46 | static int threadpool_create(int _thread_count, int _queue_size); 47 | static int threadpool_add(std::shared_ptr args, std::function)> fun); 48 | static int threadpool_destroy(ShutDownOption shutdown_option = graceful_shutdown); 49 | static int threadpool_free(); 50 | static void *threadpool_thread(void *args); 51 | }; -------------------------------------------------------------------------------- /WebServer/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HttpData.h" 3 | #include "base/noncopyable.h" 4 | #include "base/MutexLock.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class HttpData; // http request bind with time manager 11 | 12 | class TimerNode // record time message bind with httpdata 13 | { 14 | public: 15 | TimerNode(std::shared_ptr requestData, int timeout); 16 | ~TimerNode(); 17 | TimerNode(TimerNode &tn); 18 | void update(int timeout); // updata the excally time 19 | bool isValid(); 20 | void clearReq(); // 清除连接请求以及与之关联的时间节点 21 | void setDeleted() { deleted_ = true; } 22 | bool isDeleted() const { return deleted_; } 23 | size_t getExptime() const { return expiredTime_; } // expect time 24 | 25 | private: 26 | bool deleted_; 27 | size_t expiredTime_; 28 | std::shared_ptr SPHttpData; // TimerNode关联的HttpData报文类 29 | }; 30 | 31 | struct TimerCmp // 时间比较函数 32 | { 33 | bool operator()(std::shared_ptr &a, std::shared_ptr &b) const 34 | { 35 | return a->getExptime() > b->getExptime(); 36 | } 37 | }; 38 | 39 | class TimerManager // manage TimerNode 40 | { 41 | public: 42 | TimerManager(); 43 | ~TimerManager(); 44 | void addTimer(std::shared_ptr SPHttpData, int timeout); // 将HttpData新添加到时间管理器 45 | void handleExpiredEvent(); // 通过小根堆来管理请求的释放 46 | 47 | private: 48 | typedef std::shared_ptr SPTimerNode; 49 | std::priority_queue, TimerCmp> timerNodeQueue; // 时间管理器 50 | }; -------------------------------------------------------------------------------- /WebBench/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Sample debian/rules that uses debhelper. 3 | # GNU copyright 1997 to 1999 by Joey Hess. 4 | 5 | # Uncomment this to turn on verbose mode. 6 | #export DH_VERBOSE=1 7 | 8 | # This is the debhelper compatability version to use. 9 | export DH_COMPAT=3 10 | 11 | configure: configure-stamp 12 | configure-stamp: 13 | dh_testdir 14 | touch configure-stamp 15 | 16 | build: configure-stamp build-stamp 17 | build-stamp: 18 | dh_testdir 19 | $(MAKE) 20 | touch build-stamp 21 | 22 | clean: 23 | dh_testdir 24 | rm -f build-stamp configure-stamp 25 | 26 | # Add here commands to clean up after the build process. 27 | -$(MAKE) clean 28 | 29 | dh_clean 30 | 31 | install: build 32 | dh_testdir 33 | dh_testroot 34 | dh_clean -k 35 | dh_installdirs 36 | 37 | # Add here commands to install the package into debian/webbench. 38 | $(MAKE) install DESTDIR=$(CURDIR)/debian/webbench 39 | 40 | 41 | # Build architecture-independent files here. 42 | binary-indep: build install 43 | # We have nothing to do by default. 44 | 45 | # Build architecture-dependent files here. 46 | binary-arch: build install 47 | dh_testdir 48 | dh_testroot 49 | dh_installdocs 50 | dh_installman webbench.1 51 | dh_installchangelogs 52 | dh_link 53 | dh_strip 54 | dh_compress 55 | dh_fixperms 56 | # dh_makeshlibs 57 | dh_installdeb 58 | dh_shlibdeps 59 | dh_gencontrol 60 | dh_md5sums 61 | dh_builddeb 62 | 63 | binary: binary-indep binary-arch 64 | .PHONY: build clean binary-indep binary-arch binary install configure 65 | -------------------------------------------------------------------------------- /WebBench/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS?= -Wall -ggdb -W -O 2 | CC?= gcc 3 | LIBS?= 4 | LDFLAGS?= 5 | PREFIX?= /usr/local/webbench 6 | VERSION=1.5 7 | TMPDIR=/tmp/webbench-$(VERSION) 8 | 9 | all: webbench tags 10 | 11 | tags: *.c 12 | -ctags *.c 13 | 14 | install: webbench 15 | install -d $(DESTDIR)$(PREFIX)/bin 16 | install -s webbench $(DESTDIR)$(PREFIX)/bin 17 | ln -sf $(DESTDIR)$(PREFIX)/bin/webbench $(DESTDIR)/usr/local/bin/webbench 18 | 19 | install -d $(DESTDIR)/usr/local/man/man1 20 | install -d $(DESTDIR)$(PREFIX)/man/man1 21 | install -m 644 webbench.1 $(DESTDIR)$(PREFIX)/man/man1 22 | ln -sf $(DESTDIR)$(PREFIX)/man/man1/webbench.1 $(DESTDIR)/usr/local/man/man1/webbench.1 23 | 24 | install -d $(DESTDIR)$(PREFIX)/share/doc/webbench 25 | install -m 644 debian/copyright $(DESTDIR)$(PREFIX)/share/doc/webbench 26 | install -m 644 debian/changelog $(DESTDIR)$(PREFIX)/share/doc/webbench 27 | 28 | webbench: webbench.o Makefile 29 | $(CC) $(CFLAGS) $(LDFLAGS) -o webbench webbench.o $(LIBS) 30 | 31 | clean: 32 | -rm -f *.o webbench *~ core *.core tags 33 | 34 | tar: clean 35 | -debian/rules clean 36 | rm -rf $(TMPDIR) 37 | install -d $(TMPDIR) 38 | cp -p Makefile webbench.c socket.c webbench.1 $(TMPDIR) 39 | install -d $(TMPDIR)/debian 40 | -cp -p debian/* $(TMPDIR)/debian 41 | ln -sf debian/copyright $(TMPDIR)/COPYRIGHT 42 | ln -sf debian/changelog $(TMPDIR)/ChangeLog 43 | -cd $(TMPDIR) && cd .. && tar cozf webbench-$(VERSION).tar.gz webbench-$(VERSION) 44 | 45 | webbench.o: webbench.c socket.c Makefile 46 | 47 | .PHONY: clean install all tar 48 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/usr/bin/cc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "4.8.4") 5 | set(CMAKE_C_PLATFORM_ID "Linux") 6 | 7 | set(CMAKE_AR "/usr/bin/ar") 8 | set(CMAKE_RANLIB "/usr/bin/ranlib") 9 | set(CMAKE_LINKER "/usr/bin/ld") 10 | set(CMAKE_COMPILER_IS_GNUCC 1) 11 | set(CMAKE_C_COMPILER_LOADED 1) 12 | set(CMAKE_C_COMPILER_WORKS TRUE) 13 | set(CMAKE_C_ABI_COMPILED TRUE) 14 | set(CMAKE_COMPILER_IS_MINGW ) 15 | set(CMAKE_COMPILER_IS_CYGWIN ) 16 | if(CMAKE_COMPILER_IS_CYGWIN) 17 | set(CYGWIN 1) 18 | set(UNIX 1) 19 | endif() 20 | 21 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 22 | 23 | if(CMAKE_COMPILER_IS_MINGW) 24 | set(MINGW 1) 25 | endif() 26 | set(CMAKE_C_COMPILER_ID_RUN 1) 27 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c) 28 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 29 | set(CMAKE_C_LINKER_PREFERENCE 10) 30 | 31 | # Save compiler ABI information. 32 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 33 | set(CMAKE_C_COMPILER_ABI "ELF") 34 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 35 | 36 | if(CMAKE_C_SIZEOF_DATA_PTR) 37 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 38 | endif() 39 | 40 | if(CMAKE_C_COMPILER_ABI) 41 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 42 | endif() 43 | 44 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 45 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 46 | endif() 47 | 48 | 49 | 50 | 51 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") 52 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/4.8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 53 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /WebServer/EventLoop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base/Thread.h" 3 | #include "Epoll.h" 4 | #include "Channel.h" 5 | #include "base/CurrentThread.h" 6 | #include "Util.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | using namespace std; 13 | 14 | class EventLoop 15 | { 16 | public: 17 | typedef std::function Functor; // 异步回调函数 18 | EventLoop(); 19 | ~EventLoop(); 20 | void loop(); // 线程的事件循环 21 | void quit(); // 退出事件循环 22 | void runInLoop(Functor&& cb); // 主要是解决非本线程问题,在当前线程则执行回调函数否则queueInLoop 23 | void queueInLoop(Functor&& cb); // 将回调函数加入到工作队列上面 24 | bool isInLoopThread() const { return threadId_ == CurrentThread::tid(); } // 判断是否在本线程运行 25 | void assertInLoopThread() 26 | { 27 | assert(isInLoopThread()); 28 | } 29 | void shutdown(shared_ptr channel) 30 | { 31 | shutDownWR(channel->getFd()); 32 | } 33 | // epoll关于事件的一些操作 34 | void removeFromPoller(shared_ptr channel) 35 | { 36 | poller_->epoll_del(channel); 37 | } 38 | void updatePoller(shared_ptr channel, int timeout = 0) 39 | { 40 | poller_->epoll_mod(channel, timeout); 41 | } 42 | void addToPoller(shared_ptr channel, int timeout = 0) 43 | { 44 | poller_->epoll_add(channel, timeout); 45 | } 46 | 47 | private: 48 | bool looping_; 49 | shared_ptr poller_; // epoll类封装了一系列的功能 50 | int wakeupFd_; // 线程间异步唤醒eventfd 51 | bool quit_; 52 | bool eventHandling_; 53 | mutable MutexLock mutex_; 54 | std::vector pendingFunctors_; // 任务队列 55 | bool callingPendingFunctors_; // 互斥访问任务队列的布尔量 56 | const pid_t threadId_; // 线程的ID 57 | shared_ptr pwakeupChannel_; // 用于唤醒工作的事件类 58 | 59 | void wakeup(); // 唤醒函数,发送eventfd唤醒阻塞的任务队列 60 | void handleRead(); // 处理读 61 | void doPendingFunctors(); // 任务队列函数的执行 62 | void handleConn(); // 处理连接 63 | }; -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CMakeCXXCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_COMPILER "/usr/bin/c++") 2 | set(CMAKE_CXX_COMPILER_ARG1 "") 3 | set(CMAKE_CXX_COMPILER_ID "GNU") 4 | set(CMAKE_CXX_COMPILER_VERSION "4.8.4") 5 | set(CMAKE_CXX_PLATFORM_ID "Linux") 6 | 7 | set(CMAKE_AR "/usr/bin/ar") 8 | set(CMAKE_RANLIB "/usr/bin/ranlib") 9 | set(CMAKE_LINKER "/usr/bin/ld") 10 | set(CMAKE_COMPILER_IS_GNUCXX 1) 11 | set(CMAKE_CXX_COMPILER_LOADED 1) 12 | set(CMAKE_CXX_COMPILER_WORKS TRUE) 13 | set(CMAKE_CXX_ABI_COMPILED TRUE) 14 | set(CMAKE_COMPILER_IS_MINGW ) 15 | set(CMAKE_COMPILER_IS_CYGWIN ) 16 | if(CMAKE_COMPILER_IS_CYGWIN) 17 | set(CYGWIN 1) 18 | set(UNIX 1) 19 | endif() 20 | 21 | set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") 22 | 23 | if(CMAKE_COMPILER_IS_MINGW) 24 | set(MINGW 1) 25 | endif() 26 | set(CMAKE_CXX_COMPILER_ID_RUN 1) 27 | set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) 28 | set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) 29 | set(CMAKE_CXX_LINKER_PREFERENCE 30) 30 | set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) 31 | 32 | # Save compiler ABI information. 33 | set(CMAKE_CXX_SIZEOF_DATA_PTR "8") 34 | set(CMAKE_CXX_COMPILER_ABI "ELF") 35 | set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 36 | 37 | if(CMAKE_CXX_SIZEOF_DATA_PTR) 38 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") 39 | endif() 40 | 41 | if(CMAKE_CXX_COMPILER_ABI) 42 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") 43 | endif() 44 | 45 | if(CMAKE_CXX_LIBRARY_ARCHITECTURE) 46 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 47 | endif() 48 | 49 | 50 | 51 | 52 | set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c") 53 | set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/4.8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 54 | set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /WebBench/debian/changelog: -------------------------------------------------------------------------------- 1 | webbench (1.5) unstable; urgency=low 2 | 3 | * allow building with both Gnu and BSD make 4 | 5 | -- Radim Kolar Fri, Jun 25 12:00:20 CEST 2004 6 | 7 | webbench (1.4) unstable; urgency=low 8 | 9 | * check if url is not too long 10 | * report correct program version number 11 | * use yield() when waiting for test start 12 | * corrected error codes 13 | * check availability of test server first 14 | * do not abort test if first request failed 15 | * report when some childrens are dead. 16 | * use alarm, not time() for lower syscal use by bench 17 | * use mode 644 for installed doc 18 | * makefile cleaned for better freebsd ports integration 19 | 20 | -- Radim Kolar Thu, 15 Jan 2004 11:15:52 +0100 21 | 22 | webbench (1.3) unstable; urgency=low 23 | 24 | * Build fixes for freeBSD 25 | * Default benchmark time 60 -> 30 26 | * generate tar with subdirectory 27 | * added to freeBSD ports collection 28 | 29 | -- Radim Kolar Mon, 12 Jan 2004 17:00:24 +0100 30 | 31 | webbench (1.2) unstable; urgency=low 32 | 33 | * Only debian-related bugfixes 34 | * Updated Debian/rules 35 | * Adapted to fit new directory system 36 | * moved from debstd to dh_* 37 | 38 | -- Radim Kolar Fri, 18 Jan 2002 12:33:04 +0100 39 | 40 | webbench (1.1) unstable; urgency=medium 41 | 42 | * Program debianized 43 | * added support for multiple methods (GET, HEAD, OPTIONS, TRACE) 44 | * added support for multiple HTTP versions (0.9 -- 1.1) 45 | * added long options 46 | * added multiple clients 47 | * wait for start of second before test 48 | * test time can be specified 49 | * better error checking when reading reply from server 50 | * FIX: tests was one second longer than expected 51 | 52 | -- Radim Kolar Thu, 16 Sep 1999 18:48:00 +0200 53 | 54 | Local variables: 55 | mode: debian-changelog 56 | End: 57 | -------------------------------------------------------------------------------- /WebBench/share/doc/webbench/changelog: -------------------------------------------------------------------------------- 1 | webbench (1.5) unstable; urgency=low 2 | 3 | * allow building with both Gnu and BSD make 4 | 5 | -- Radim Kolar Fri, Jun 25 12:00:20 CEST 2004 6 | 7 | webbench (1.4) unstable; urgency=low 8 | 9 | * check if url is not too long 10 | * report correct program version number 11 | * use yield() when waiting for test start 12 | * corrected error codes 13 | * check availability of test server first 14 | * do not abort test if first request failed 15 | * report when some childrens are dead. 16 | * use alarm, not time() for lower syscal use by bench 17 | * use mode 644 for installed doc 18 | * makefile cleaned for better freebsd ports integration 19 | 20 | -- Radim Kolar Thu, 15 Jan 2004 11:15:52 +0100 21 | 22 | webbench (1.3) unstable; urgency=low 23 | 24 | * Build fixes for freeBSD 25 | * Default benchmark time 60 -> 30 26 | * generate tar with subdirectory 27 | * added to freeBSD ports collection 28 | 29 | -- Radim Kolar Mon, 12 Jan 2004 17:00:24 +0100 30 | 31 | webbench (1.2) unstable; urgency=low 32 | 33 | * Only debian-related bugfixes 34 | * Updated Debian/rules 35 | * Adapted to fit new directory system 36 | * moved from debstd to dh_* 37 | 38 | -- Radim Kolar Fri, 18 Jan 2002 12:33:04 +0100 39 | 40 | webbench (1.1) unstable; urgency=medium 41 | 42 | * Program debianized 43 | * added support for multiple methods (GET, HEAD, OPTIONS, TRACE) 44 | * added support for multiple HTTP versions (0.9 -- 1.1) 45 | * added long options 46 | * added multiple clients 47 | * wait for start of second before test 48 | * test time can be specified 49 | * better error checking when reading reply from server 50 | * FIX: tests was one second longer than expected 51 | 52 | -- Radim Kolar Thu, 16 Sep 1999 18:48:00 +0200 53 | 54 | Local variables: 55 | mode: debian-changelog 56 | End: 57 | -------------------------------------------------------------------------------- /WebBench/socket.c: -------------------------------------------------------------------------------- 1 | /* $Id: socket.c 1.1 1995/01/01 07:11:14 cthuang Exp $ 2 | * 3 | * This module has been modified by Radim Kolar for OS/2 emx 4 | */ 5 | 6 | /*********************************************************************** 7 | module: socket.c 8 | program: popclient 9 | SCCS ID: @(#)socket.c 1.5 4/1/94 10 | programmer: Virginia Tech Computing Center 11 | compiler: DEC RISC C compiler (Ultrix 4.1) 12 | environment: DEC Ultrix 4.3 13 | description: UNIX sockets code. 14 | ***********************************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int Socket(const char *host, int clientPort) 30 | { 31 | int sock; 32 | unsigned long inaddr; 33 | struct sockaddr_in ad; 34 | struct hostent *hp; 35 | 36 | memset(&ad, 0, sizeof(ad)); 37 | ad.sin_family = AF_INET; 38 | 39 | inaddr = inet_addr(host); 40 | if (inaddr != INADDR_NONE) 41 | memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr)); 42 | else 43 | { 44 | hp = gethostbyname(host); 45 | if (hp == NULL) 46 | return -1; 47 | memcpy(&ad.sin_addr, hp->h_addr, hp->h_length); 48 | } 49 | ad.sin_port = htons(clientPort); 50 | 51 | sock = socket(AF_INET, SOCK_STREAM, 0); 52 | 53 | 54 | if (sock < 0) 55 | return sock; 56 | 57 | // int optval = 1; 58 | // if(setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) == -1) 59 | // return -1; 60 | if (connect(sock, (struct sockaddr *)&ad, sizeof(ad)) < 0) 61 | return -1; 62 | 63 | return sock; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /WebServer/Server.cpp: -------------------------------------------------------------------------------- 1 | #include "Server.h" 2 | #include "Util.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | Server::Server(EventLoop *loop, int threadNum, int port) 10 | : loop_(loop), 11 | threadNum_(threadNum), 12 | eventLoopThreadPool_(new EventLoopThreadPool(loop_, threadNum)), 13 | started_(false), 14 | acceptChannel_(new Channel(loop_)), 15 | port_(port), 16 | listenFd_(socket_bind_listen(port_)) 17 | { 18 | acceptChannel_->setFd(listenFd_); 19 | handle_for_sigpipe(); 20 | if(setSocketNonBlocking(listenFd_) < 0) 21 | { 22 | perror("set socket non block failed"); 23 | abort(); 24 | } 25 | } 26 | 27 | void Server::start() 28 | { 29 | eventLoopThreadPool_->start(); 30 | acceptChannel_->setEvents(EPOLLIN | EPOLLET); 31 | acceptChannel_->setReadHandler(bind(&Server::handNewConn, this)); 32 | acceptChannel_->setConnHandler(bind(&Server::handThisConn, this)); 33 | loop_->addToPoller(acceptChannel_, 0); 34 | started_ = true; 35 | } 36 | 37 | void Server::handNewConn() 38 | { 39 | struct sockaddr_in client_addr; 40 | memset(&client_addr, 0 ,sizeof(struct sockaddr_in)); 41 | socklen_t client_addr_len = sizeof(client_addr); 42 | int accept_fd = 0; 43 | while((accept_fd = accept(listenFd_, (struct sockaddr*)&client_addr, &client_addr_len)) > 0) 44 | { 45 | EventLoop *loop = eventLoopThreadPool_->getNextLoop(); 46 | //LOG << "New connection from " << inet_ntoa(client_addr.sin_addr) << ":" << ntohs(client_addr.sin_port); 47 | 48 | 49 | if(accept_fd >= MAXFDS) 50 | { 51 | close(accept_fd); 52 | continue; 53 | } 54 | // set nonblocking 55 | if(setSocketNonBlocking(accept_fd) < 0) 56 | { 57 | //LOG << "Set non block failed!"; 58 | return ; 59 | } 60 | 61 | setSocketNodelay(accept_fd); 62 | 63 | shared_ptr req_info(new HttpData(loop, accept_fd)); 64 | req_info->getChannel()->setHolder(req_info); 65 | loop->queueInLoop(std::bind(&HttpData::newEvent, req_info)); 66 | } 67 | acceptChannel_->setEvents(EPOLLIN | EPOLLET); 68 | } -------------------------------------------------------------------------------- /WebServer/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | TimerNode::TimerNode(std::shared_ptr requestData, int timeout) 8 | : deleted_(false), 9 | SPHttpData(requestData) 10 | { 11 | struct timeval now; 12 | gettimeofday(&now, NULL); 13 | // 计算超时到期时间 14 | expiredTime_ = (((now.tv_sec % 10000) * 1000) + (now.tv_usec / 1000)) + timeout; 15 | } 16 | 17 | TimerNode::~TimerNode() // close the binded HttpData when TimerNode was deleted 18 | { 19 | if(SPHttpData) 20 | SPHttpData->handleClose(); 21 | } 22 | 23 | TimerNode::TimerNode(TimerNode &tn) 24 | : SPHttpData(tn.SPHttpData) 25 | { } 26 | 27 | void TimerNode::update(int timeout) // update excally time 28 | { 29 | struct timeval now; 30 | gettimeofday(&now, NULL); 31 | expiredTime_ = (((now.tv_sec % 10000) * 1000) + (now.tv_usec / 1000)) + timeout; 32 | } 33 | 34 | // 判断当前时间是否超时 35 | bool TimerNode::isValid() 36 | { 37 | struct timeval now; 38 | gettimeofday(&now, NULL); 39 | size_t temp = (((now.tv_sec % 10000) * 1000) + (now.tv_usec / 1000)); 40 | if(temp < expiredTime_) 41 | return true; 42 | else 43 | { 44 | this->setDeleted(); 45 | return false; 46 | } 47 | } 48 | 49 | // 清除请求http数据报文 50 | void TimerNode::clearReq() 51 | { 52 | SPHttpData.reset(); 53 | this->setDeleted(); 54 | } 55 | 56 | 57 | TimerManager::TimerManager() 58 | { } 59 | 60 | TimerManager::~TimerManager() 61 | { } 62 | 63 | // 向时间管理器添加新的节点 64 | void TimerManager::addTimer(std::shared_ptr SPHttpData, int timeout) 65 | { 66 | SPTimerNode new_node(new TimerNode(SPHttpData, timeout)); 67 | timerNodeQueue.push(new_node); 68 | SPHttpData->linkTimer(new_node); // HttpData assosiate TimerNode 69 | } 70 | 71 | // 72 | void TimerManager::handleExpiredEvent() // building with least queue, delete old timernode 73 | { // 时间管理器,通过小根堆的方式来删除堆顶超时的节点 74 | while(!timerNodeQueue.empty()) 75 | { 76 | SPTimerNode ptimer_now = timerNodeQueue.top(); 77 | if(ptimer_now->isDeleted()) 78 | timerNodeQueue.pop(); 79 | else if(ptimer_now->isValid()==false) 80 | timerNodeQueue.pop(); 81 | else break; 82 | } 83 | } -------------------------------------------------------------------------------- /WebBench/webbench.1: -------------------------------------------------------------------------------- 1 | -.TH WEBBENCH 1 "14 Jan 2004" 2 | -.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection 3 | -.\" other parms are allowed: see man(7), man(1) 4 | -.SH NAME 5 | -webbench \- simple forking web benchmark 6 | -.SH SYNOPSIS 7 | -.B webbench 8 | -.I "[options] URL" 9 | -.br 10 | -.SH "AUTHOR" 11 | -This program and manual page was written by Radim Kolar, 12 | -for the 13 | -.B Supreme Personality of Godhead 14 | -(but may be used by others). 15 | -.SH "DESCRIPTION" 16 | -.B webbench 17 | -is simple program for benchmarking HTTP servers or any 18 | -other servers, which can be accessed via HTTP proxy. Unlike others 19 | -benchmarks, 20 | -.B webbench 21 | -uses multiple processes for simulating traffic 22 | -generated by multiple users. This allows better operating 23 | -on SMP systems and on systems with slow or buggy implementation 24 | -of select(). 25 | -.SH OPTIONS 26 | -The programs follow the usual GNU command line syntax, with long 27 | -options starting with two dashes (`-'). 28 | -A summary of options are included below. 29 | -.TP 30 | -.B \-?, \-h, \-\-help 31 | -Show summary of options. 32 | -.TP 33 | -.B \-v, \-\-version 34 | -Show version of program. 35 | -.TP 36 | -.B \-f, \-\-force 37 | -Do not wait for any response from server. Close connection after 38 | -request is send. This option produce quite a good denial of service 39 | -attack. 40 | -.TP 41 | -.B \-9, \-\-http09 42 | -Use HTTP/0.9 protocol, if possible. 43 | -.TP 44 | -.B \-1, \-\-http10 45 | -Use HTTP/1.0 protocol, if possible. 46 | -.TP 47 | -.B \-2, \-\-http11 48 | -Use HTTP/1.1 protocol (without 49 | -.I Keep-Alive 50 | -), if possible. 51 | -.TP 52 | -.B \-r, \-\-reload 53 | -Forces proxy to reload document. If proxy is not 54 | -set, option has no effect. 55 | -.TP 56 | -.B \-t, \-\-time 57 | -Run benchmark for 58 | -.I 59 | -seconds. Default value is 30. 60 | -.TP 61 | -.B \-p, \-\-proxy 62 | -Send request via proxy server. Needed for supporting others protocols 63 | -than HTTP. 64 | -.TP 65 | -.B \-\-get 66 | -Use GET request method. 67 | -.TP 68 | -.B \-\-head 69 | -Use HEAD request method. 70 | -.TP 71 | -.B \-\-options 72 | -Use OPTIONS request method. 73 | -.TP 74 | -.B \-\-trace 75 | -Use TRACE request method. 76 | -.TP 77 | -.B \-c, \-\-clients 78 | -Use 79 | -.I 80 | -multiple clients for benchmark. Default value 81 | -is 1. 82 | -.SH "EXIT STATUS" 83 | -.TP 84 | -0 - sucess 85 | -.TP 86 | -1 - benchmark failed, can not connect to server 87 | -.TP 88 | -2 - bad command line argument(s) 89 | -.TP 90 | -3 - internal error, i.e. fork failed 91 | -.SH "TODO" 92 | -Include support for using 93 | -.I Keep-Alive 94 | -HTTP/1.1 connections. 95 | -.SH "COPYING" 96 | -Webbench is distributed under GPL. Copyright 1997-2004 97 | -Radim Kolar (hsn@netmag.cz). 98 | -UNIX sockets code taken from popclient 1.5 4/1/94 99 | -public domain code, created by Virginia Tech Computing Center. 100 | -.BR 101 | -This man page is public domain. 102 | -------------------------------------------------------------------------------- /WebBench/man/man1/webbench.1: -------------------------------------------------------------------------------- 1 | -.TH WEBBENCH 1 "14 Jan 2004" 2 | -.\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection 3 | -.\" other parms are allowed: see man(7), man(1) 4 | -.SH NAME 5 | -webbench \- simple forking web benchmark 6 | -.SH SYNOPSIS 7 | -.B webbench 8 | -.I "[options] URL" 9 | -.br 10 | -.SH "AUTHOR" 11 | -This program and manual page was written by Radim Kolar, 12 | -for the 13 | -.B Supreme Personality of Godhead 14 | -(but may be used by others). 15 | -.SH "DESCRIPTION" 16 | -.B webbench 17 | -is simple program for benchmarking HTTP servers or any 18 | -other servers, which can be accessed via HTTP proxy. Unlike others 19 | -benchmarks, 20 | -.B webbench 21 | -uses multiple processes for simulating traffic 22 | -generated by multiple users. This allows better operating 23 | -on SMP systems and on systems with slow or buggy implementation 24 | -of select(). 25 | -.SH OPTIONS 26 | -The programs follow the usual GNU command line syntax, with long 27 | -options starting with two dashes (`-'). 28 | -A summary of options are included below. 29 | -.TP 30 | -.B \-?, \-h, \-\-help 31 | -Show summary of options. 32 | -.TP 33 | -.B \-v, \-\-version 34 | -Show version of program. 35 | -.TP 36 | -.B \-f, \-\-force 37 | -Do not wait for any response from server. Close connection after 38 | -request is send. This option produce quite a good denial of service 39 | -attack. 40 | -.TP 41 | -.B \-9, \-\-http09 42 | -Use HTTP/0.9 protocol, if possible. 43 | -.TP 44 | -.B \-1, \-\-http10 45 | -Use HTTP/1.0 protocol, if possible. 46 | -.TP 47 | -.B \-2, \-\-http11 48 | -Use HTTP/1.1 protocol (without 49 | -.I Keep-Alive 50 | -), if possible. 51 | -.TP 52 | -.B \-r, \-\-reload 53 | -Forces proxy to reload document. If proxy is not 54 | -set, option has no effect. 55 | -.TP 56 | -.B \-t, \-\-time 57 | -Run benchmark for 58 | -.I 59 | -seconds. Default value is 30. 60 | -.TP 61 | -.B \-p, \-\-proxy 62 | -Send request via proxy server. Needed for supporting others protocols 63 | -than HTTP. 64 | -.TP 65 | -.B \-\-get 66 | -Use GET request method. 67 | -.TP 68 | -.B \-\-head 69 | -Use HEAD request method. 70 | -.TP 71 | -.B \-\-options 72 | -Use OPTIONS request method. 73 | -.TP 74 | -.B \-\-trace 75 | -Use TRACE request method. 76 | -.TP 77 | -.B \-c, \-\-clients 78 | -Use 79 | -.I 80 | -multiple clients for benchmark. Default value 81 | -is 1. 82 | -.SH "EXIT STATUS" 83 | -.TP 84 | -0 - sucess 85 | -.TP 86 | -1 - benchmark failed, can not connect to server 87 | -.TP 88 | -2 - bad command line argument(s) 89 | -.TP 90 | -3 - internal error, i.e. fork failed 91 | -.SH "TODO" 92 | -Include support for using 93 | -.I Keep-Alive 94 | -HTTP/1.1 connections. 95 | -.SH "COPYING" 96 | -Webbench is distributed under GPL. Copyright 1997-2004 97 | -Radim Kolar (hsn@netmag.cz). 98 | -UNIX sockets code taken from popclient 1.5 4/1/94 99 | -public domain code, created by Virginia Tech Computing Center. 100 | -.BR 101 | -This man page is public domain. 102 | -------------------------------------------------------------------------------- /WebServer/Channel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Timer.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class EventLoop; // 核心的事件循环函数,one thread per loop 11 | class HttpData; // HttpData类封装了http报文的解析以及读写等 12 | 13 | // I/O注册函数,I/O多路复用,用来分发主线程的I/O事件;通过异步回调的机制正确的处理I/O事件。 14 | // 设置一个通用的Channel注册相对应的事件处理回调函数,当然Channel也有事件处理方法来统一处理事件 15 | class Channel 16 | { 17 | private: 18 | typedef std::function CallBack; // 异步回调函数 19 | EventLoop *loop_; // 关键的事件循环 20 | int fd_; // 事件相关的文件描述符 21 | __uint32_t events_; // 相关的事件 22 | __uint32_t revents_; 23 | __uint32_t lastEvents_; 24 | 25 | std::weak_ptr holder_; // 虚指针 26 | 27 | private: 28 | int parse_URI(); 29 | int parse_Headers(); 30 | int analysisRequest(); 31 | 32 | // 各回调函数机制 33 | CallBack readHandler_; 34 | CallBack writeHandler_; 35 | CallBack errorHandler_; 36 | CallBack connHandler_; 37 | 38 | public: 39 | Channel(EventLoop *loop); 40 | Channel(EventLoop *loop, int fd); 41 | ~Channel(); 42 | int getFd(); 43 | void setFd(int fd); 44 | 45 | void setHolder(std::shared_ptr holder) 46 | { 47 | holder_ = holder; 48 | } 49 | std::shared_ptr getHolder() 50 | { 51 | std::shared_ptr ret(holder_.lock()); 52 | return ret; 53 | } 54 | 55 | // 设置相应的回调函数 56 | void setReadHandler(CallBack &&readHandler) 57 | { 58 | readHandler_ = readHandler; 59 | } 60 | void setWriteHandler(CallBack &&writeHandler) 61 | { 62 | writeHandler_ = writeHandler; 63 | } 64 | void setErrorHandler(CallBack &&errorHandler) 65 | { 66 | errorHandler_ = errorHandler; 67 | } 68 | void setConnHandler(CallBack &&connHandler) 69 | { 70 | connHandler_ = connHandler; 71 | } 72 | 73 | // Channel的事件处理方法 74 | void handleEvents() 75 | { 76 | events_ = 0; 77 | if((revents_ & EPOLLHUP) && !(revents_ & EPOLLIN)) 78 | { 79 | events_ = 0; 80 | return ; 81 | } 82 | if(revents_ & EPOLLERR) 83 | { 84 | if(errorHandler_) errorHandler_(); 85 | events_ = 0; 86 | return; 87 | } 88 | if(revents_ & (EPOLLIN | EPOLLPRI | EPOLLHUP)) 89 | { 90 | handleRead(); 91 | } 92 | if(revents_ & EPOLLOUT) 93 | { 94 | handleWrite(); 95 | } 96 | handleConn(); 97 | } 98 | void handleRead(); 99 | void handleWrite(); 100 | void handError(int fd, int err_num, std::string short_msg); 101 | void handleConn(); 102 | 103 | void setRevents(__uint32_t ev) 104 | { 105 | revents_ = ev; 106 | } 107 | 108 | void setEvents(__uint32_t ev) 109 | { 110 | events_ = ev; 111 | } 112 | __uint32_t& getEvents() 113 | { 114 | return events_; 115 | } 116 | 117 | bool EqualAndUpdateLastEvents() 118 | { 119 | bool ret = (lastEvents_ == events_); 120 | lastEvents_ = events_; 121 | return ret; 122 | } 123 | 124 | __uint32_t getLastEvents() 125 | { 126 | return lastEvents_; 127 | } 128 | 129 | }; 130 | 131 | typedef std::shared_ptr SP_Channel; -------------------------------------------------------------------------------- /WebServer/HttpData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Timer.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class EventLoop; 12 | class TimerNode; 13 | class Channel; 14 | 15 | enum ProcessState 16 | { 17 | STATE_PARSE_URI = 1, 18 | STATE_PARSE_HEADERS, 19 | STATE_RECV_BODY, 20 | STATE_ANALYSIS, 21 | STATE_FINISH 22 | }; 23 | 24 | enum URIState 25 | { 26 | PARSE_URI_AGAIN = 1, 27 | PARSE_URI_ERROR, 28 | PARSE_URI_SUCCESS 29 | }; 30 | 31 | enum HeaderState 32 | { 33 | PARSE_HEADER_SUCCESS = 1, 34 | PARSE_HEADER_AGAIN, 35 | PARSE_HEADER_ERROR 36 | }; 37 | 38 | enum AnalysisState 39 | { 40 | ANALYSIS_SUCCESS = 1, 41 | ANALYSIS_ERROR 42 | }; 43 | 44 | enum ParseState 45 | { 46 | H_START = 0, 47 | H_KEY, 48 | H_COLON, 49 | H_SPACES_AFTER_COLON, 50 | H_VALUE, 51 | H_CR, 52 | H_LF, 53 | H_END_CR, 54 | H_END_LF 55 | }; 56 | 57 | enum ConnectionState 58 | { 59 | H_CONNECTED = 0, 60 | H_DISCONNECTING, 61 | H_DISCONNECTED 62 | }; 63 | 64 | enum HttpMethod 65 | { 66 | METHOD_POST = 1, 67 | METHOD_GET 68 | }; 69 | 70 | enum HttpVersion 71 | { 72 | HTTP_10 = 1, 73 | HTTP_11 74 | }; 75 | 76 | class MimeType 77 | { 78 | private: 79 | static void init(); 80 | static std::unordered_map mime; 81 | MimeType(); 82 | MimeType(const MimeType &m); 83 | 84 | public: 85 | static std::string getMime(const std::string &suffix); 86 | 87 | private: 88 | static pthread_once_t once_control; // just initial once 89 | }; 90 | 91 | class HttpData: public std::enable_shared_from_this // enable asyn callback 92 | { 93 | public: 94 | HttpData(EventLoop *loop, int connfd); 95 | ~HttpData() { close(fd_); } 96 | void reset(); 97 | void seperateTimer(); 98 | void linkTimer(std::shared_ptr mtimer) 99 | { 100 | timer_ = mtimer; 101 | } 102 | std::shared_ptr getChannel() { return channel_; } 103 | EventLoop *getLoop() { return loop_; } 104 | void handleClose(); 105 | void newEvent(); 106 | 107 | private: 108 | EventLoop *loop_; 109 | std::shared_ptr channel_; 110 | int fd_; 111 | std::string inBuffer_; 112 | std::string outBuffer_; 113 | bool error_; 114 | ConnectionState connectionState_; 115 | 116 | HttpMethod method_; 117 | HttpVersion HTTPVersion_; 118 | std::string fileName_; 119 | std::string path_; 120 | int nowReadPos_; 121 | ProcessState state_; 122 | ParseState hState_; 123 | bool keepAlive_; // http connect long or short option 124 | std::map headers_; // record http head key-value messages 125 | std::weak_ptr timer_; //easier to be callback in under as a observer 126 | 127 | void handleRead(); 128 | void handleWrite(); 129 | void handleConn(); 130 | void handleError(int fd, int err_num, std::string short_msg); 131 | URIState parseURI(); 132 | HeaderState parseHeaders(); 133 | AnalysisState analysisRequest(); 134 | }; -------------------------------------------------------------------------------- /WebServer/base/Thread.cpp: -------------------------------------------------------------------------------- 1 | #include "Thread.h" 2 | #include "CurrentThread.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | using namespace std; 15 | 16 | namespace CurrentThread 17 | { 18 | __thread int t_cachedTid = 0; //__thread : thread local storage 19 | __thread char t_tidString[32]; 20 | __thread int t_tidStringLength = 6; 21 | __thread const char* t_threadName = "unknow"; 22 | } 23 | 24 | pid_t gettid() 25 | { 26 | return static_cast(::syscall(SYS_gettid)); 27 | } 28 | 29 | void CurrentThread::cacheTid() // current thread 30 | { 31 | if(t_cachedTid == 0){ 32 | t_cachedTid = gettid(); 33 | t_tidStringLength = snprintf(t_tidString, sizeof t_tidString, "%5d", t_cachedTid); 34 | } 35 | } 36 | 37 | // save name ,tid in the thread 38 | struct ThreadData 39 | { 40 | typedef Thread::ThreadFunc ThreadFunc; 41 | ThreadFunc func_; 42 | string name_; 43 | pid_t* tid_; 44 | CountDownLatch* latch_; 45 | 46 | ThreadData(const ThreadFunc& func, const string& name, pid_t *tid, CountDownLatch *latch) 47 | : func_(func), 48 | name_(name), 49 | tid_(tid), 50 | latch_(latch) 51 | { } 52 | 53 | void runInThread() 54 | { 55 | *tid_ = CurrentThread::tid(); // get the current tid in thread 56 | tid_ = NULL; 57 | latch_->countDown(); //make sure ThreadFunc ready 58 | latch_ = NULL; 59 | 60 | CurrentThread::t_threadName = name_.empty() ? "Thread" : name_.c_str(); 61 | prctl(PR_SET_NAME, CurrentThread::t_threadName); 62 | 63 | func_(); 64 | CurrentThread::t_threadName = "finished"; 65 | } 66 | }; 67 | 68 | void* startThread(void* obj) 69 | { 70 | ThreadData* data = static_cast(obj); 71 | data->runInThread(); 72 | delete data; 73 | return NULL; 74 | } 75 | 76 | Thread::Thread(const ThreadFunc& func, const string& n) 77 | : started_(false), 78 | joined_(false), 79 | pthreadId_(0), 80 | tid_(0), 81 | func_(func), 82 | name_(n), 83 | latch_(1) 84 | { 85 | setDefaultName(); 86 | } 87 | 88 | Thread::~Thread() 89 | { 90 | if(started_ && !joined_){ 91 | pthread_detach(pthreadId_); 92 | } 93 | } 94 | 95 | void Thread::setDefaultName() 96 | { 97 | if(name_.empty()) 98 | { 99 | char buf[32]; 100 | snprintf(buf, sizeof buf, "Thread"); 101 | name_ = buf; 102 | } 103 | } 104 | 105 | void Thread::start() // start the thread 106 | { 107 | assert(!started_); 108 | started_ = true; 109 | ThreadData* data = new ThreadData(func_, name_, &tid_, &latch_); 110 | if(pthread_create(&pthreadId_, NULL, &startThread, data)) // function in thread 111 | { 112 | started_ = false; 113 | delete data; 114 | }else{ 115 | latch_.wait(); 116 | assert(tid_ > 0); 117 | } 118 | } 119 | 120 | int Thread::join() 121 | { 122 | assert(started_); 123 | assert(!joined_); 124 | joined_ = true; 125 | return pthread_join(pthreadId_, NULL); 126 | } 127 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Determining if the pthread_create exist failed with the following output: 2 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 3 | 4 | Run Build Command:/usr/bin/make "cmTryCompileExec2725160972/fast" 5 | /usr/bin/make -f CMakeFiles/cmTryCompileExec2725160972.dir/build.make CMakeFiles/cmTryCompileExec2725160972.dir/build 6 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 7 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 8 | Building C object CMakeFiles/cmTryCompileExec2725160972.dir/CheckSymbolExists.c.o 9 | /usr/bin/cc -o CMakeFiles/cmTryCompileExec2725160972.dir/CheckSymbolExists.c.o -c /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CheckSymbolExists.c 10 | Linking C executable cmTryCompileExec2725160972 11 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec2725160972.dir/link.txt --verbose=1 12 | /usr/bin/cc CMakeFiles/cmTryCompileExec2725160972.dir/CheckSymbolExists.c.o -o cmTryCompileExec2725160972 -rdynamic 13 | CMakeFiles/cmTryCompileExec2725160972.dir/CheckSymbolExists.c.o: In function `main': 14 | CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create' 15 | collect2: error: ld returned 1 exit status 16 | make[1]: *** [cmTryCompileExec2725160972] Error 1 17 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 18 | make: *** [cmTryCompileExec2725160972/fast] Error 2 19 | 20 | File /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CheckSymbolExists.c: 21 | /* */ 22 | #include 23 | 24 | int main(int argc, char** argv) 25 | { 26 | (void)argv; 27 | #ifndef pthread_create 28 | return ((int*)(&pthread_create))[argc]; 29 | #else 30 | (void)argc; 31 | return 0; 32 | #endif 33 | } 34 | 35 | Determining if the function pthread_create exists in the pthreads failed with the following output: 36 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 37 | 38 | Run Build Command:/usr/bin/make "cmTryCompileExec2469824604/fast" 39 | /usr/bin/make -f CMakeFiles/cmTryCompileExec2469824604.dir/build.make CMakeFiles/cmTryCompileExec2469824604.dir/build 40 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 41 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 42 | Building C object CMakeFiles/cmTryCompileExec2469824604.dir/CheckFunctionExists.c.o 43 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec2469824604.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c 44 | Linking C executable cmTryCompileExec2469824604 45 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec2469824604.dir/link.txt --verbose=1 46 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec2469824604.dir/CheckFunctionExists.c.o -o cmTryCompileExec2469824604 -rdynamic -lpthreads 47 | /usr/bin/ld: cannot find -lpthreads 48 | collect2: error: ld returned 1 exit status 49 | make[1]: *** [cmTryCompileExec2469824604] Error 1 50 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 51 | make: *** [cmTryCompileExec2469824604/fast] Error 2 52 | 53 | 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # High-performance multi-threaded tcp network server 2 | 3 | [![](https://img.shields.io/travis/grasslog/WebServer/master.svg)](https://travis-ci.org/grasslog/WebServer) 4 | [![](https://img.shields.io/badge/language-c++-orange.svg)](http://www.cplusplus.com/) 5 | [![](https://img.shields.io/github/license/grasslog/WebServer.svg)](https://github.com/grasslog/WebServer/blob/master/LICENSE) 6 | [![](https://img.shields.io/badge/github.io-@pages-inactive.svg)](https://grasslog.github.io/WebServer/) 7 | [![](https://img.shields.io/badge/blog-@grass-red.svg)](https://blog.csdn.net/qq_42381849) 8 | [![](https://img.shields.io/badge/Gmail-@bookish00grass-important.svg)](https://www.google.com/intl/zh-CN_cn/gmail/about/) 9 | 10 | ## Introduction 11 | 12 | 此项目借鉴《muduo网络库》思想,实现了一个网络库轮子web服务器,语言为c++11,并发模型使用Reactor+非阻塞IO+主线程和工作线程的事件循环,思想遵循one loop per thread。可处理静态资源,解析了get、HTTPhead请求,支持HTTP连接,支持管线化请求,并用webBench进行压测。 13 | 14 | ## Environment 15 | 16 | - OS:CentOS 7 17 | - complier:g++4.8 18 | 19 | ## Build 20 | 21 | ./build.sh 22 | 23 | ## Start server 24 | 25 | ./WebServer [-t thread_numbers] [-p port] 26 | 27 | ## Example main.cpp 28 | 29 | #include "EventLoop.h" 30 | #include "Server.h" 31 | #include 32 | #include 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | int threadNum = 4; 37 | int port = 8888; 38 | std::string logPath = "./WebServer.log"; 39 | 40 | int opt; 41 | const char *str = "t:p:"; 42 | while((opt = getopt(argc, argv, str)) != -1) 43 | { 44 | switch(opt) 45 | { 46 | case 't': 47 | { 48 | threadNum = atoi(optarg); 49 | break; 50 | } 51 | case 'p': 52 | { 53 | port = atoi(optarg); 54 | break; 55 | } 56 | default: break; 57 | } 58 | } 59 | 60 | #ifndef _PTHREADS 61 | //LOG << "_PTHREADS is not defined !"; 62 | #endif 63 | EventLoop mainLoop; 64 | Server myHTTPServer(&mainLoop, threadNum, port); 65 | myHTTPServer.start(); 66 | mainLoop.loop(); 67 | return 0; 68 | } 69 | 70 | ## Technical 71 | 72 | - 服务器框架采用Reactor模式,采用epoll边沿触发模式作为IO复用技术作为IO分配器,分发IO事件 73 | - 对于IO密集型请求使用多线程充分利用多核CPU并行处理,创建了线程池避免线程频繁创建销毁的开销 74 | - 主线程只负责accept请求,并以轮回的方式分发给其它IO线程,然后执行read->decode->compute->encode->write 75 | - 使用基于小根堆的定时器关闭超时请求 76 | - 主线程和工作线程各自维持了一个事件循环(eventloop) 77 | - TLS,使用了线程的本地局部存储功能,维护各个线程的运行状态以及运行信息等 78 | - 设计了任务队列的缓冲区机制,避免了请求陷入死锁循环 79 | - 线程间的高效通信,使用eventfd实现了线程的异步唤醒 80 | - 为减少内存泄漏的可能,使用智能指针等RAII机制 81 | - 使用状态机解析了HTTP请求,支持http管线化请求 82 | - 支持优雅关闭连接 83 | 84 | ## WebServer demo 85 | 86 | 87 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190602114909245.PNG?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyMzgxODQ5,size_16,color_FFFFFF,t_70) 88 | 89 | ## Code statistics 90 | 91 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190604115528778.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyMzgxODQ5,size_16,color_FFFFFF,t_70) 92 | 93 | ## Project imagines 94 | 95 | Show more details in CSDN [my blog](https://blog.csdn.net/qq_42381849/article/details/90766452) -------------------------------------------------------------------------------- /WebServer/tests/HTTPClient.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace std; 15 | 16 | #define MAXSIZE 1024 17 | #define IPADDRESS "127.0.0.1" 18 | #define SERV_PORT 8888 19 | #define FDSIZE 1024 20 | #define EPOLLEVENTS 20 21 | 22 | 23 | int setSocketNonBlocking1(int fd) 24 | { 25 | int flag = fcntl(fd, F_GETFL, 0); 26 | if(flag == -1) 27 | return -1; 28 | 29 | flag |= O_NONBLOCK; 30 | if(fcntl(fd, F_SETFL, flag) == -1) 31 | return -1; 32 | return 0; 33 | } 34 | int main(int argc,char *argv[]) 35 | { 36 | int sockfd; 37 | struct sockaddr_in servaddr; 38 | sockfd = socket(AF_INET,SOCK_STREAM,0); 39 | bzero(&servaddr,sizeof(servaddr)); 40 | servaddr.sin_family = AF_INET; 41 | servaddr.sin_port = htons(SERV_PORT); 42 | inet_pton(AF_INET,IPADDRESS,&servaddr.sin_addr); 43 | char buff[4096]; 44 | buff[0] = '\0'; 45 | // 发空串 46 | const char *p = " "; 47 | if (connect(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)) == 0 ) 48 | { 49 | setSocketNonBlocking1(sockfd); 50 | cout << "1:" << endl; 51 | ssize_t n = write(sockfd, p, strlen(p)); 52 | cout << "strlen(p) = " << strlen(p) << endl; 53 | sleep(1); 54 | n = read(sockfd, buff, 4096); 55 | cout << "n=" << n << endl; 56 | printf("%s", buff); 57 | close(sockfd); 58 | } 59 | else{ 60 | perror("err1"); 61 | } 62 | sleep(1); 63 | 64 | // 发"GET HTTP/1.1" 65 | p = "GET HTTP/1.1"; 66 | sockfd = socket(AF_INET,SOCK_STREAM,0); 67 | if (connect(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)) == 0) 68 | { 69 | setSocketNonBlocking1(sockfd); 70 | cout << "2:" << endl; 71 | ssize_t n = write(sockfd, p, strlen(p)); 72 | cout << "strlen(p) = " << strlen(p) << endl; 73 | sleep(1); 74 | n = read(sockfd, buff, 4096); 75 | cout << "n=" << n << endl; 76 | printf("%s", buff); 77 | close(sockfd); 78 | } 79 | else 80 | { 81 | perror("err2"); 82 | } 83 | sleep(1); 84 | 85 | // 发 86 | // GET HTTP/1.1 87 | // Host: 127.0.0.1:8888 88 | // Content-Type: application/x-www-form-urlencoded 89 | // Connection: Keep-Alive 90 | p = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8888\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: Keep-Alive\r\n\r\n"; 91 | sockfd = socket(AF_INET,SOCK_STREAM,0); 92 | if (connect(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)) == 0) 93 | { 94 | setSocketNonBlocking1(sockfd); 95 | cout << "3:" << endl; 96 | ssize_t n = write(sockfd, p, strlen(p)); 97 | cout << "strlen(p) = " << strlen(p) << endl; 98 | sleep(1); 99 | n = read(sockfd, buff, 4096); 100 | cout << "n=" << n << endl; 101 | printf("%s", buff); 102 | close(sockfd); 103 | } 104 | else 105 | { 106 | perror("err3"); 107 | } 108 | return 0; 109 | } 110 | 111 | 112 | -------------------------------------------------------------------------------- /WebServer/EventLoop.cpp: -------------------------------------------------------------------------------- 1 | #include "EventLoop.h" 2 | #include "Util.h" 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | __thread EventLoop* t_loopInThisThread = 0; 9 | 10 | int createEventfd() 11 | { // 线程的异步唤醒eventfd 12 | int evtfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); 13 | if(evtfd < 0) 14 | { 15 | //LOG << "Failed in eventfd"; 16 | abort(); 17 | } 18 | return evtfd; 19 | } 20 | 21 | EventLoop::EventLoop() 22 | : looping_(false), 23 | poller_(new Epoll()), 24 | wakeupFd_(createEventfd()), 25 | quit_(false), 26 | eventHandling_(false), 27 | callingPendingFunctors_(false), 28 | threadId_(CurrentThread::tid()), 29 | pwakeupChannel_(new Channel(this, wakeupFd_)) 30 | { 31 | if(t_loopInThisThread) 32 | { 33 | //LOG << "Another EventLoop " << " exists in this thread " <setEvents(EPOLLIN | EPOLLET); 40 | pwakeupChannel_->setReadHandler(bind(&EventLoop::handleRead, this)); // 注册读处理回调函数 41 | pwakeupChannel_->setConnHandler(bind(&EventLoop::handleConn, this)); // 注册连接处理函数 42 | poller_->epoll_add(pwakeupChannel_, 0); // 注册I/O函数 43 | } 44 | 45 | void EventLoop::handleConn() // 有点玄学 46 | { 47 | updatePoller(pwakeupChannel_, 0); 48 | } 49 | 50 | EventLoop::~EventLoop() 51 | { 52 | close(wakeupFd_); 53 | t_loopInThisThread = NULL; 54 | } 55 | 56 | void EventLoop::wakeup() 57 | { 58 | uint64_t one = 1; 59 | ssize_t n = write(wakeupFd_, (char*)(&one), sizeof one); // write 唤醒任务队列 60 | if(n != sizeof one) 61 | { 62 | //LOG << "EventLoop::wakeup() writes " << n << " bytes instead of 8"; 63 | } 64 | } 65 | 66 | void EventLoop::handleRead() 67 | { 68 | uint64_t one = 1; 69 | ssize_t n = readn(wakeupFd_, &one, sizeof one); 70 | if(n != sizeof one) 71 | { 72 | //LOG << "EventLoop::handleRead() reads " << n << " bytes instead of 8"; 73 | } 74 | pwakeupChannel_->setEvents(EPOLLIN | EPOLLET); // 设置EPOLLIN 和 EPOLLET 75 | } 76 | 77 | // 处理是否在本线程处理 78 | void EventLoop::runInLoop(Functor&& cb) 79 | { 80 | if(isInLoopThread()) 81 | cb(); 82 | else 83 | queueInLoop(std::move(cb)); 84 | } 85 | 86 | void EventLoop::queueInLoop(Functor&& cb) 87 | { // 加入到任务队列 88 | { 89 | MutexLockGuard lock(mutex_); 90 | pendingFunctors_.emplace_back(std::move(cb)); 91 | } 92 | if(!isInLoopThread() || callingPendingFunctors_) 93 | wakeup(); 94 | } 95 | 96 | void EventLoop::loop() 97 | { // 线程的事件循环函数 98 | assert(!looping_); 99 | assert(isInLoopThread()); 100 | looping_ = true; 101 | quit_ = false; 102 | std::vector ret; 103 | while(!quit_) 104 | { 105 | ret.clear(); 106 | ret = poller_->poll(); // epoll_wait检测事件描述符 107 | eventHandling_ = true; 108 | for(auto &it : ret) 109 | it->handleEvents(); // 根据注册的回调函数处理相应的动作 110 | eventHandling_ = false; 111 | doPendingFunctors(); // 处理任务队列中封装的回调函数任务 112 | poller_->handleExpired(); // 定时器处理超时的请求 113 | } 114 | looping_ = false; 115 | } 116 | 117 | void EventLoop::doPendingFunctors() 118 | { // 任务队列的相应的处理流程 119 | std::vector functors; // 局部缓冲区,避免任务队列调用的死循环 120 | callingPendingFunctors_ = true; 121 | { 122 | MutexLockGuard lock(mutex_); 123 | functors.swap(pendingFunctors_); 124 | } 125 | 126 | for(size_t i=0; i 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | const int EVENTSNUM = 4096; 17 | const int EPOLLWAIT_TIME = 10000; 18 | 19 | typedef shared_ptr SP_Channel; 20 | 21 | Epoll::Epoll() 22 | : epollFd_(epoll_create1(EPOLL_CLOEXEC)), 23 | events_(EVENTSNUM) 24 | { 25 | assert(epollFd_ > 0); 26 | } 27 | Epoll::~Epoll() 28 | { } 29 | 30 | // 借助fd2http_[]和fd2chan_[]来记录httpdata和channel 31 | 32 | // register fd 33 | void Epoll::epoll_add(SP_Channel request, int timeout) 34 | { 35 | int fd = request->getFd(); 36 | if(timeout > 0) 37 | { 38 | add_timer(request, timeout); 39 | fd2http_[fd] = request->getHolder(); 40 | } 41 | struct epoll_event event; 42 | event.data.fd = fd; 43 | event.events = request->getEvents(); 44 | 45 | request->EqualAndUpdateLastEvents(); 46 | 47 | fd2chan_[fd] = request; 48 | if(epoll_ctl(epollFd_, EPOLL_CTL_ADD, fd, &event) < 0) 49 | { 50 | perror("epoll_add error"); 51 | fd2chan_[fd].reset(); 52 | } 53 | } 54 | 55 | // mod fd 56 | void Epoll::epoll_mod(SP_Channel request, int timeout) 57 | { 58 | if(timeout > 0) 59 | add_timer(request, timeout); 60 | int fd = request->getFd(); 61 | if(!request->EqualAndUpdateLastEvents()) 62 | { 63 | struct epoll_event event; 64 | event.data.fd = fd; 65 | event.events = request->getEvents(); 66 | if(epoll_ctl(epollFd_, EPOLL_CTL_MOD, fd, &event) < 0) 67 | { 68 | perror("epoll_mod error"); 69 | fd2chan_[fd].reset(); 70 | } 71 | } 72 | } 73 | 74 | // delete fd 75 | void Epoll::epoll_del(SP_Channel request) 76 | { 77 | int fd = request->getFd(); 78 | struct epoll_event event; 79 | event.data.fd = fd; 80 | event.events = request->getLastEvents(); 81 | if(epoll_ctl(epollFd_, EPOLL_CTL_DEL, fd, &event) < 0) 82 | { 83 | perror("epoll_del error"); 84 | } 85 | fd2chan_[fd].reset(); 86 | fd2http_[fd].reset(); 87 | } 88 | 89 | 90 | 91 | // return active events 92 | std::vector Epoll::poll() 93 | { 94 | while(true) 95 | { 96 | int event_count = epoll_wait(epollFd_, &*events_.begin(), events_.size(), EPOLLWAIT_TIME); 97 | if(event_count < 0) 98 | perror("epoll wait error"); 99 | std::vector req_data = getEventsRequest(event_count); 100 | if(req_data.size() > 0) 101 | return req_data; 102 | } 103 | } 104 | 105 | void Epoll::handleExpired() 106 | { 107 | timerManager_.handleExpiredEvent(); 108 | } 109 | 110 | // 根据events_num返回活跃事件数量和缓存的channel和httpdata,最终返回req_data(channel share_ptr)向量集合 111 | std::vector Epoll::getEventsRequest(int events_num) 112 | { 113 | std::vector req_data; 114 | for(int i=0; isetRevents(events_[i].events); // 根据返回的活跃事件注册添加到结果集合中 123 | cur_req->setEvents(0); 124 | req_data.push_back(cur_req); 125 | }else{ 126 | //LOG << "SP cur_req is invalid"; 127 | } 128 | } 129 | return req_data; 130 | } 131 | 132 | // 将请求添加到TimerManager_中 133 | void Epoll::add_timer(SP_Channel request_data, int timeout) 134 | { 135 | shared_ptr t = request_data->getHolder(); 136 | if(t) 137 | timerManager_.addTimer(t, timeout); 138 | else 139 | { 140 | //LOG << "timer add fail"; 141 | } 142 | } -------------------------------------------------------------------------------- /WebServer/ThreadPool.cpp: -------------------------------------------------------------------------------- 1 | #include "ThreadPool.h" 2 | 3 | 4 | pthread_mutex_t ThreadPool::lock = PTHREAD_MUTEX_INITIALIZER; 5 | pthread_cond_t ThreadPool::notify = PTHREAD_COND_INITIALIZER; 6 | std::vector ThreadPool::threads; 7 | std::vector ThreadPool::queue; 8 | int ThreadPool::thread_count = 0; 9 | int ThreadPool::queue_size = 0; 10 | int ThreadPool::head = 0; 11 | int ThreadPool::tail = 0; 12 | int ThreadPool::count = 0; 13 | int ThreadPool::shutdown = 0; 14 | int ThreadPool::started = 0; 15 | 16 | int ThreadPool::threadpool_create(int _thread_count, int _queue_size) 17 | { 18 | bool err = false; 19 | do 20 | { 21 | if(_thread_count <= 0 || _thread_count > MAX_THREADS || _queue_size <= 0 || _queue_size > MAX_QUEUE) 22 | { 23 | _thread_count = 4; 24 | _queue_size = 1024; 25 | } 26 | 27 | thread_count = 0; 28 | queue_size = _queue_size; 29 | head = tail = count = 0; 30 | shutdown = started = 0; 31 | 32 | threads.resize(_thread_count); 33 | queue.resize(_queue_size); 34 | 35 | // start worker threads 36 | for(int i=0; i<_thread_count; ++i) 37 | { 38 | if(pthread_create(&threads[i], NULL, threadpool_thread, (void*)(0)) != 0) 39 | { 40 | return -1; 41 | } 42 | ++thread_count; 43 | ++started; 44 | } 45 | }while(false); 46 | 47 | if(err) 48 | { 49 | return -1; 50 | } 51 | return 0; 52 | } 53 | 54 | int ThreadPool::threadpool_add(std::shared_ptr args, std::function)> fun) 55 | { 56 | int next, err = 0; 57 | if(pthread_mutex_lock(&lock) != 0) 58 | return THREADPOOL_LOCK_FAILURE; 59 | do 60 | { 61 | next = (tail + 1) % queue_size; 62 | if(count == queue_size) 63 | { 64 | err = THREADPOOL_QUEUE_FULL; 65 | break; 66 | } 67 | if(shutdown) 68 | { 69 | err = THREADPOOL_SHUTDOWN; 70 | break; 71 | } 72 | queue[tail].fun = fun; 73 | queue[tail].args = args; 74 | tail = next; 75 | ++ count; 76 | 77 | /* pthread_cond_broadcast */ 78 | if(pthread_cond_signal(¬ify) != 0) 79 | { 80 | err = THREADPOOL_LOCK_FAILURE; 81 | break; 82 | } 83 | }while(false); 84 | 85 | if(pthread_mutex_unlock(&lock) != 0) 86 | err = THREADPOOL_LOCK_FAILURE; 87 | return err; 88 | } 89 | 90 | int ThreadPool::threadpool_destroy(ShutDownOption shutdown_option) 91 | { 92 | printf("Thread pool destroy !\n"); 93 | int i, err = 0; 94 | 95 | if(pthread_mutex_lock(&lock) != 0) 96 | { 97 | return THREADPOOL_LOCK_FAILURE; 98 | } 99 | do 100 | { 101 | if(shutdown) 102 | { 103 | err = THREADPOOL_SHUTDOWN; 104 | break; 105 | } 106 | shutdown = shutdown_option; 107 | 108 | if((pthread_cond_broadcast(¬ify) != 0) || (pthread_mutex_unlock(&lock) != 0)) 109 | { 110 | err = THREADPOOL_LOCK_FAILURE; 111 | break; 112 | } 113 | 114 | for(int i=0; i 0) 133 | return -1; 134 | pthread_mutex_lock(&lock); 135 | pthread_mutex_destroy(&lock); 136 | pthread_cond_destroy(¬ify); 137 | return 0; 138 | } 139 | 140 | void *ThreadPool::threadpool_thread(void *args) 141 | { 142 | while(true) 143 | { 144 | ThreadPoolTask task; 145 | pthread_mutex_lock(&lock); 146 | while((count == 0) && (!shutdown)) 147 | { 148 | pthread_cond_wait(¬ify, &lock); 149 | } 150 | if((shutdown == immediate_shutdown) || ((shutdown == graceful_shutdown) && (count == 0))) 151 | { 152 | break; 153 | } 154 | task.fun = queue[head].fun; 155 | task.args = queue[head].args; 156 | queue[head].fun = NULL; 157 | queue[head].args.reset(); 158 | head = (head + 1) % queue_size; 159 | --count; 160 | pthread_mutex_unlock(&lock); 161 | (task.fun)(task.args); 162 | } 163 | --started; 164 | pthread_mutex_unlock(&lock); 165 | printf("This threadpool thread finishs!\n"); 166 | pthread_exit(NULL); 167 | return (NULL); 168 | } -------------------------------------------------------------------------------- /WebBench/tags: -------------------------------------------------------------------------------- 1 | !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ 2 | !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ 3 | !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ 4 | !_TAG_PROGRAM_NAME Exuberant Ctags // 5 | !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ 6 | !_TAG_PROGRAM_VERSION 5.9~svn20110310 // 7 | METHOD_GET webbench.c 38;" d file: 8 | METHOD_GET webbench1.c 38;" d file: 9 | METHOD_GET webbench2.c 38;" d file: 10 | METHOD_HEAD webbench.c 39;" d file: 11 | METHOD_HEAD webbench1.c 39;" d file: 12 | METHOD_HEAD webbench2.c 39;" d file: 13 | METHOD_OPTIONS webbench.c 40;" d file: 14 | METHOD_OPTIONS webbench1.c 40;" d file: 15 | METHOD_OPTIONS webbench2.c 40;" d file: 16 | METHOD_TRACE webbench.c 41;" d file: 17 | METHOD_TRACE webbench1.c 41;" d file: 18 | METHOD_TRACE webbench2.c 41;" d file: 19 | PROGRAM_VERSION webbench.c 42;" d file: 20 | PROGRAM_VERSION webbench1.c 42;" d file: 21 | PROGRAM_VERSION webbench2.c 42;" d file: 22 | REQUEST_SIZE webbench.c 56;" d file: 23 | REQUEST_SIZE webbench1.c 56;" d file: 24 | REQUEST_SIZE webbench2.c 56;" d file: 25 | Socket socket.c /^int Socket(const char *host, int clientPort)$/;" f 26 | alarm_handler webbench.c /^static void alarm_handler(int signal)$/;" f file: 27 | alarm_handler webbench1.c /^static void alarm_handler(int signal)$/;" f file: 28 | alarm_handler webbench2.c /^static void alarm_handler(int signal)$/;" f file: 29 | bench webbench.c /^static int bench(void)$/;" f file: 30 | bench webbench1.c /^static int bench(void)$/;" f file: 31 | bench webbench2.c /^static int bench(void)$/;" f file: 32 | benchcore webbench.c /^void benchcore(const char *host,const int port,const char *req)$/;" f 33 | benchcore webbench1.c /^void benchcore(const char *host,const int port,const char *req)$/;" f 34 | benchcore webbench2.c /^void benchcore(const char *host,const int port,const char *req)$/;" f 35 | benchtime webbench.c /^int benchtime=30;$/;" v 36 | benchtime webbench1.c /^int benchtime=30;$/;" v 37 | benchtime webbench2.c /^int benchtime=30;$/;" v 38 | build_request webbench.c /^void build_request(const char *url)$/;" f 39 | build_request webbench1.c /^void build_request(const char *url)$/;" f 40 | build_request webbench2.c /^void build_request(const char *url)$/;" f 41 | bytes webbench.c /^int bytes=0;$/;" v 42 | bytes webbench1.c /^int bytes=0;$/;" v 43 | bytes webbench2.c /^int bytes=0;$/;" v 44 | clients webbench.c /^int clients=1;$/;" v 45 | clients webbench1.c /^int clients=1;$/;" v 46 | clients webbench2.c /^int clients=1;$/;" v 47 | failed webbench.c /^int failed=0;$/;" v 48 | failed webbench1.c /^int failed=0;$/;" v 49 | failed webbench2.c /^int failed=0;$/;" v 50 | force webbench.c /^int force=0;$/;" v 51 | force webbench1.c /^int force=0;$/;" v 52 | force webbench2.c /^int force=0;$/;" v 53 | force_reload webbench.c /^int force_reload=0;$/;" v 54 | force_reload webbench1.c /^int force_reload=0;$/;" v 55 | force_reload webbench2.c /^int force_reload=0;$/;" v 56 | host webbench.c /^char host[MAXHOSTNAMELEN];$/;" v 57 | host webbench1.c /^char host[MAXHOSTNAMELEN];$/;" v 58 | host webbench2.c /^char host[MAXHOSTNAMELEN];$/;" v 59 | http10 webbench.c /^int http10=1; \/* 0 - http\/0.9, 1 - http\/1.0, 2 - http\/1.1 *\/$/;" v 60 | http10 webbench1.c /^int http10=1; \/* 0 - http\/0.9, 1 - http\/1.0, 2 - http\/1.1 *\/$/;" v 61 | http10 webbench2.c /^int http10=1; \/* 0 - http\/0.9, 1 - http\/1.0, 2 - http\/1.1 *\/$/;" v 62 | keep_alive webbench.c /^bool keep_alive = false;$/;" v 63 | keep_alive webbench1.c /^bool keep_alive = false;$/;" v 64 | keep_alive webbench2.c /^bool keep_alive = false;$/;" v 65 | long_options webbench.c /^static const struct option long_options[]=$/;" v typeref:struct:option file: 66 | long_options webbench1.c /^static const struct option long_options[]=$/;" v typeref:struct:option file: 67 | long_options webbench2.c /^static const struct option long_options[]=$/;" v typeref:struct:option file: 68 | main webbench.c /^int main(int argc, char *argv[])$/;" f 69 | main webbench1.c /^int main(int argc, char *argv[])$/;" f 70 | main webbench2.c /^int main(int argc, char *argv[])$/;" f 71 | method webbench.c /^int method=METHOD_GET;$/;" v 72 | method webbench1.c /^int method=METHOD_GET;$/;" v 73 | method webbench2.c /^int method=METHOD_GET;$/;" v 74 | mypipe webbench.c /^int mypipe[2];$/;" v 75 | mypipe webbench1.c /^int mypipe[2];$/;" v 76 | mypipe webbench2.c /^int mypipe[2];$/;" v 77 | proxyhost webbench.c /^char *proxyhost=NULL;$/;" v 78 | proxyhost webbench1.c /^char *proxyhost=NULL;$/;" v 79 | proxyhost webbench2.c /^char *proxyhost=NULL;$/;" v 80 | proxyport webbench.c /^int proxyport=80;$/;" v 81 | proxyport webbench1.c /^int proxyport=80;$/;" v 82 | proxyport webbench2.c /^int proxyport=80;$/;" v 83 | request webbench.c /^char request[REQUEST_SIZE];$/;" v 84 | request webbench1.c /^char request[REQUEST_SIZE];$/;" v 85 | request webbench2.c /^char request[REQUEST_SIZE];$/;" v 86 | speed webbench.c /^int speed=0;$/;" v 87 | speed webbench1.c /^int speed=0;$/;" v 88 | speed webbench2.c /^int speed=0;$/;" v 89 | timerexpired webbench.c /^volatile int timerexpired=0;$/;" v 90 | timerexpired webbench1.c /^volatile int timerexpired=0;$/;" v 91 | timerexpired webbench2.c /^volatile int timerexpired=0;$/;" v 92 | usage webbench.c /^static void usage(void)$/;" f file: 93 | usage webbench1.c /^static void usage(void)$/;" f file: 94 | usage webbench2.c /^static void usage(void)$/;" f file: 95 | -------------------------------------------------------------------------------- /WebServer/Util.cpp: -------------------------------------------------------------------------------- 1 | #include "Util.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | const int MAX_BUFF = 4096; 12 | ssize_t readn(int fd, void *buff, size_t n) 13 | { 14 | size_t nleft = n; 15 | ssize_t nread = 0; 16 | ssize_t readSum = 0; 17 | char *ptr = (char*)buff; 18 | while(nleft > 0) 19 | { 20 | if((nread = read(fd, ptr, nleft)) < 0) 21 | { 22 | if(errno == EINTR) 23 | nread = 0; 24 | else if(errno == EAGAIN) 25 | { 26 | return readSum; 27 | } 28 | else 29 | { 30 | return -1; 31 | } 32 | } 33 | else if(nread == 0) 34 | break; 35 | readSum += nread; 36 | nleft -= nread; 37 | ptr += nread; 38 | } 39 | return readSum; 40 | } 41 | 42 | 43 | ssize_t readn(int fd, std::string &inBuffer, bool &zero) 44 | { 45 | ssize_t nread = 0; 46 | ssize_t readSum = 0; 47 | while(true) 48 | { 49 | char buff[MAX_BUFF]; 50 | if((nread = read(fd, buff, MAX_BUFF)) < 0) 51 | { 52 | if(errno == EINTR) 53 | continue; 54 | else if(errno == EAGAIN) 55 | { 56 | return readSum; 57 | } 58 | else 59 | { 60 | perror("read error"); 61 | return -1; 62 | } 63 | } 64 | else if(nread == 0) 65 | { 66 | zero = true; 67 | break; 68 | } 69 | 70 | readSum += nread; 71 | inBuffer += std::string(buff, buff + nread); 72 | } 73 | return readSum; 74 | } 75 | 76 | ssize_t readn(int fd, std::string &inBuffer) 77 | { 78 | ssize_t nread = 0; 79 | ssize_t readSum = 0; 80 | while(true) 81 | { 82 | char buff[MAX_BUFF]; 83 | if((nread = read(fd, buff, MAX_BUFF)) < 0) 84 | { 85 | if(errno == EINTR) 86 | continue; 87 | else if(errno == EAGAIN) 88 | { 89 | return readSum; 90 | } 91 | else 92 | { 93 | perror("read error"); 94 | return - 1; 95 | } 96 | } 97 | else if(nread == 0) 98 | { 99 | break; 100 | } 101 | readSum += nread; 102 | inBuffer += std::string(buff, buff + nread); 103 | } 104 | return readSum; 105 | } 106 | 107 | ssize_t writen(int fd, void *buff, size_t n) 108 | { 109 | size_t nleft = n; 110 | ssize_t nwritten = 0; 111 | ssize_t writeSum = 0; 112 | char *ptr = (char*)buff; 113 | while(nleft > 0) 114 | { 115 | if((nwritten = write(fd, ptr, nleft)) <= 0) 116 | { 117 | if(nwritten < 0) 118 | { 119 | if(errno == EINTR) 120 | { 121 | nwritten = 0; 122 | continue; 123 | } 124 | else if(errno == EAGAIN) 125 | { 126 | return writeSum; 127 | } 128 | else 129 | return -1; 130 | } 131 | } 132 | writeSum += nwritten; 133 | nleft -= nwritten; 134 | ptr += nwritten; 135 | } 136 | 137 | return writeSum; 138 | } 139 | 140 | ssize_t writen(int fd, std::string &sbuff) 141 | { 142 | size_t nleft = sbuff.size(); 143 | ssize_t nwritten = 0; 144 | ssize_t writeSum = 0; 145 | const char *ptr = sbuff.c_str(); 146 | while(nleft > 0) 147 | { 148 | if((nwritten = write(fd, ptr, nleft)) <= 0) 149 | { 150 | if(nwritten < 0) 151 | { 152 | if(errno == EINTR) 153 | { 154 | nwritten = 0; 155 | continue; 156 | } 157 | else if(errno == EAGAIN) 158 | { 159 | return writeSum; 160 | } 161 | else 162 | return -1; 163 | } 164 | } 165 | writeSum += nwritten; 166 | nleft -= nwritten; 167 | ptr += nwritten; 168 | } 169 | if(writeSum == static_cast(sbuff.size())) 170 | sbuff.clear(); 171 | else 172 | sbuff = sbuff.substr(writeSum); 173 | return writeSum; 174 | } 175 | 176 | void handle_for_sigpipe() 177 | { 178 | struct sigaction sa; 179 | memset(&sa, '\0', sizeof(sa)); 180 | sa.sa_handler = SIG_IGN; 181 | sa.sa_flags = 0; 182 | if(sigaction(SIGPIPE, &sa, NULL)) 183 | return; 184 | } 185 | 186 | int setSocketNonBlocking(int fd) 187 | { 188 | int flag = fcntl(fd, F_GETFL, 0); 189 | if(flag == -1) 190 | return -1; 191 | 192 | flag |= O_NONBLOCK; 193 | if(fcntl(fd, F_SETFL, flag) == -1) 194 | return -1; 195 | return 0; 196 | } 197 | 198 | void setSocketNodelay(int fd) 199 | { 200 | int enable = 1; 201 | setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&enable, sizeof(enable)); 202 | } 203 | 204 | void setSocketNoLinger(int fd) 205 | { 206 | struct linger linger_; 207 | linger_.l_onoff = 1; 208 | linger_.l_linger = 30; 209 | setsockopt(fd, SOL_SOCKET, SO_LINGER, (const char*) &linger_, sizeof(linger_)); 210 | } 211 | 212 | void shutDownWR(int fd) 213 | { 214 | shutdown(fd, SHUT_WR); 215 | } 216 | 217 | int socket_bind_listen(int port) 218 | { 219 | if(port < 1024 || port > 65535) 220 | return -1; 221 | 222 | int listen_fd = 0; 223 | if((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) 224 | return -1; 225 | 226 | // clear error in bind :"Address already in use" 227 | int optval = 1; 228 | if(setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1) 229 | return -1; 230 | // Linux version >= 3.7 ip and port multiplexing 231 | if(setsockopt(listen_fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) == -1) 232 | return -1; 233 | 234 | // set wen server IP and Port listenfd 235 | struct sockaddr_in server_addr; 236 | bzero((char*)&server_addr, sizeof(server_addr)); 237 | server_addr.sin_family = AF_INET; 238 | server_addr.sin_addr.s_addr = htonl(INADDR_ANY); 239 | server_addr.sin_port = htons((unsigned short)port); 240 | if(bind(listen_fd, (struct sockaddr*)&server_addr, sizeof(server_addr)) == -1) 241 | return -1; 242 | 243 | if(listen(listen_fd, 2048) == -1) 244 | return -1; 245 | 246 | if(listen_fd == -1) 247 | { 248 | close(listen_fd); 249 | return -1; 250 | } 251 | return listen_fd; 252 | } -------------------------------------------------------------------------------- /webserver_test.jmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | false 7 | true 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | WebServer 17 | continue 18 | 19 | false 20 | 1 21 | 22 | 100 23 | 1 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | false 34 | 35 | = 36 | true 37 | 38 | 39 | 40 | 127.0.0.1 41 | 8080 42 | http 43 | 44 | /hello 45 | GET 46 | true 47 | false 48 | true 49 | false 50 | 51 | 52 | 53 | 54 | 55 | 56 | false 57 | 58 | saveConfig 59 | 60 | 61 | true 62 | true 63 | true 64 | 65 | true 66 | true 67 | true 68 | true 69 | false 70 | true 71 | true 72 | false 73 | false 74 | false 75 | true 76 | false 77 | false 78 | false 79 | true 80 | 0 81 | true 82 | true 83 | true 84 | true 85 | true 86 | true 87 | 88 | 89 | /usr/local/JMeter/test.jmx 90 | 91 | 92 | 93 | false 94 | 95 | saveConfig 96 | 97 | 98 | true 99 | true 100 | true 101 | 102 | true 103 | true 104 | true 105 | true 106 | false 107 | true 108 | true 109 | false 110 | false 111 | false 112 | true 113 | false 114 | false 115 | false 116 | true 117 | 0 118 | true 119 | true 120 | true 121 | true 122 | true 123 | true 124 | 125 | 126 | 127 | 128 | 129 | 130 | false 131 | 132 | saveConfig 133 | 134 | 135 | true 136 | true 137 | true 138 | 139 | true 140 | true 141 | true 142 | true 143 | false 144 | true 145 | true 146 | false 147 | false 148 | false 149 | true 150 | false 151 | false 152 | false 153 | true 154 | 0 155 | true 156 | true 157 | true 158 | true 159 | true 160 | true 161 | 162 | 163 | 164 | 165 | 166 | 167 | false 168 | 169 | saveConfig 170 | 171 | 172 | true 173 | true 174 | true 175 | 176 | true 177 | true 178 | true 179 | true 180 | false 181 | true 182 | true 183 | false 184 | false 185 | false 186 | true 187 | false 188 | false 189 | false 190 | true 191 | 0 192 | true 193 | true 194 | true 195 | true 196 | true 197 | true 198 | 199 | 200 | 201 | 202 | 203 | 204 | false 205 | 206 | saveConfig 207 | 208 | 209 | true 210 | true 211 | true 212 | 213 | true 214 | true 215 | true 216 | true 217 | false 218 | true 219 | true 220 | false 221 | false 222 | false 223 | true 224 | false 225 | false 226 | false 227 | true 228 | 0 229 | true 230 | true 231 | true 232 | true 233 | true 234 | true 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CompilerIdCXX/CMakeCXXCompilerId.cpp: -------------------------------------------------------------------------------- 1 | /* This source file must have a .cpp extension so that all C++ compilers 2 | recognize the extension without flags. Borland does not know .cxx for 3 | example. */ 4 | #ifndef __cplusplus 5 | # error "A C compiler has been selected for C++." 6 | #endif 7 | 8 | /* Version number components: V=Version, R=Revision, P=Patch 9 | Version date components: YYYY=Year, MM=Month, DD=Day */ 10 | 11 | #if defined(__COMO__) 12 | # define COMPILER_ID "Comeau" 13 | /* __COMO_VERSION__ = VRR */ 14 | # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) 15 | # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) 16 | 17 | #elif defined(__INTEL_COMPILER) || defined(__ICC) 18 | # define COMPILER_ID "Intel" 19 | /* __INTEL_COMPILER = VRP */ 20 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 21 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 22 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 23 | # if defined(__INTEL_COMPILER_BUILD_DATE) 24 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 25 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 26 | # endif 27 | 28 | #elif defined(__PATHCC__) 29 | # define COMPILER_ID "PathScale" 30 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 31 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 32 | # if defined(__PATHCC_PATCHLEVEL__) 33 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 34 | # endif 35 | 36 | #elif defined(__clang__) 37 | # define COMPILER_ID "Clang" 38 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 39 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 40 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 41 | 42 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 43 | # define COMPILER_ID "Embarcadero" 44 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 45 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 46 | # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF) 47 | 48 | #elif defined(__BORLANDC__) 49 | # define COMPILER_ID "Borland" 50 | /* __BORLANDC__ = 0xVRR */ 51 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 52 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 53 | 54 | #elif defined(__WATCOMC__) 55 | # define COMPILER_ID "Watcom" 56 | /* __WATCOMC__ = VVRR */ 57 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 58 | # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) 59 | 60 | #elif defined(__SUNPRO_CC) 61 | # define COMPILER_ID "SunPro" 62 | # if __SUNPRO_CC >= 0x5100 63 | /* __SUNPRO_CC = 0xVRRP */ 64 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) 65 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) 66 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 67 | # else 68 | /* __SUNPRO_CC = 0xVRP */ 69 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) 70 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) 71 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 72 | # endif 73 | 74 | #elif defined(__HP_aCC) 75 | # define COMPILER_ID "HP" 76 | /* __HP_aCC = VVRRPP */ 77 | # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) 78 | # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) 79 | # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) 80 | 81 | #elif defined(__DECCXX) 82 | # define COMPILER_ID "Compaq" 83 | /* __DECCXX_VER = VVRRTPPPP */ 84 | # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) 85 | # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) 86 | # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) 87 | 88 | #elif defined(__IBMCPP__) 89 | # if defined(__COMPILER_VER__) 90 | # define COMPILER_ID "zOS" 91 | # else 92 | # if __IBMCPP__ >= 800 93 | # define COMPILER_ID "XL" 94 | # else 95 | # define COMPILER_ID "VisualAge" 96 | # endif 97 | /* __IBMCPP__ = VRP */ 98 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 99 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 100 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 101 | # endif 102 | 103 | #elif defined(__PGI) 104 | # define COMPILER_ID "PGI" 105 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 106 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 107 | # if defined(__PGIC_PATCHLEVEL__) 108 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 109 | # endif 110 | 111 | #elif defined(_CRAYC) 112 | # define COMPILER_ID "Cray" 113 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE) 114 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 115 | 116 | #elif defined(__TI_COMPILER_VERSION__) 117 | # define COMPILER_ID "TI" 118 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 119 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 120 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 121 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 122 | 123 | #elif defined(__SCO_VERSION__) 124 | # define COMPILER_ID "SCO" 125 | 126 | #elif defined(__GNUC__) 127 | # define COMPILER_ID "GNU" 128 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 129 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 130 | # if defined(__GNUC_PATCHLEVEL__) 131 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 132 | # endif 133 | 134 | #elif defined(_MSC_VER) 135 | # define COMPILER_ID "MSVC" 136 | /* _MSC_VER = VVRR */ 137 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 138 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 139 | # if defined(_MSC_FULL_VER) 140 | # if _MSC_VER >= 1400 141 | /* _MSC_FULL_VER = VVRRPPPPP */ 142 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 143 | # else 144 | /* _MSC_FULL_VER = VVRRPPPP */ 145 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 146 | # endif 147 | # endif 148 | # if defined(_MSC_BUILD) 149 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 150 | # endif 151 | 152 | /* Analog VisualDSP++ >= 4.5.6 */ 153 | #elif defined(__VISUALDSPVERSION__) 154 | # define COMPILER_ID "ADSP" 155 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 156 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 157 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 158 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 159 | 160 | /* Analog VisualDSP++ < 4.5.6 */ 161 | #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 162 | # define COMPILER_ID "ADSP" 163 | 164 | /* IAR Systems compiler for embedded systems. 165 | http://www.iar.com */ 166 | #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) 167 | # define COMPILER_ID "IAR" 168 | 169 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 170 | # define COMPILER_ID "MIPSpro" 171 | # if defined(_SGI_COMPILER_VERSION) 172 | /* _SGI_COMPILER_VERSION = VRP */ 173 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 174 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 175 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 176 | # else 177 | /* _COMPILER_VERSION = VRP */ 178 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 179 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 180 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 181 | # endif 182 | 183 | /* This compiler is either not known or is too old to define an 184 | identification macro. Try to identify the platform and guess that 185 | it is the native compiler. */ 186 | #elif defined(__sgi) 187 | # define COMPILER_ID "MIPSpro" 188 | 189 | #elif defined(__hpux) || defined(__hpua) 190 | # define COMPILER_ID "HP" 191 | 192 | #else /* unknown compiler */ 193 | # define COMPILER_ID "" 194 | 195 | #endif 196 | 197 | /* Construct the string literal in pieces to prevent the source from 198 | getting matched. Store it in a pointer rather than an array 199 | because some compilers will just produce instructions to fill the 200 | array rather than assigning a pointer to a static array. */ 201 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 202 | 203 | /* Identify known platforms by name. */ 204 | #if defined(__linux) || defined(__linux__) || defined(linux) 205 | # define PLATFORM_ID "Linux" 206 | 207 | #elif defined(__CYGWIN__) 208 | # define PLATFORM_ID "Cygwin" 209 | 210 | #elif defined(__MINGW32__) 211 | # define PLATFORM_ID "MinGW" 212 | 213 | #elif defined(__APPLE__) 214 | # define PLATFORM_ID "Darwin" 215 | 216 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 217 | # define PLATFORM_ID "Windows" 218 | 219 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 220 | # define PLATFORM_ID "FreeBSD" 221 | 222 | #elif defined(__NetBSD__) || defined(__NetBSD) 223 | # define PLATFORM_ID "NetBSD" 224 | 225 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 226 | # define PLATFORM_ID "OpenBSD" 227 | 228 | #elif defined(__sun) || defined(sun) 229 | # define PLATFORM_ID "SunOS" 230 | 231 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 232 | # define PLATFORM_ID "AIX" 233 | 234 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 235 | # define PLATFORM_ID "IRIX" 236 | 237 | #elif defined(__hpux) || defined(__hpux__) 238 | # define PLATFORM_ID "HP-UX" 239 | 240 | #elif defined(__HAIKU__) 241 | # define PLATFORM_ID "Haiku" 242 | 243 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 244 | # define PLATFORM_ID "BeOS" 245 | 246 | #elif defined(__QNX__) || defined(__QNXNTO__) 247 | # define PLATFORM_ID "QNX" 248 | 249 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 250 | # define PLATFORM_ID "Tru64" 251 | 252 | #elif defined(__riscos) || defined(__riscos__) 253 | # define PLATFORM_ID "RISCos" 254 | 255 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 256 | # define PLATFORM_ID "SINIX" 257 | 258 | #elif defined(__UNIX_SV__) 259 | # define PLATFORM_ID "UNIX_SV" 260 | 261 | #elif defined(__bsdos__) 262 | # define PLATFORM_ID "BSDOS" 263 | 264 | #elif defined(_MPRAS) || defined(MPRAS) 265 | # define PLATFORM_ID "MP-RAS" 266 | 267 | #elif defined(__osf) || defined(__osf__) 268 | # define PLATFORM_ID "OSF1" 269 | 270 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 271 | # define PLATFORM_ID "SCO_SV" 272 | 273 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 274 | # define PLATFORM_ID "ULTRIX" 275 | 276 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 277 | # define PLATFORM_ID "Xenix" 278 | 279 | #else /* unknown platform */ 280 | # define PLATFORM_ID "" 281 | 282 | #endif 283 | 284 | /* For windows compilers MSVC and Intel we can determine 285 | the architecture of the compiler being used. This is because 286 | the compilers do not have flags that can change the architecture, 287 | but rather depend on which compiler is being used 288 | */ 289 | #if defined(_WIN32) && defined(_MSC_VER) 290 | # if defined(_M_IA64) 291 | # define ARCHITECTURE_ID "IA64" 292 | 293 | # elif defined(_M_X64) || defined(_M_AMD64) 294 | # define ARCHITECTURE_ID "x64" 295 | 296 | # elif defined(_M_IX86) 297 | # define ARCHITECTURE_ID "X86" 298 | 299 | # elif defined(_M_ARM) 300 | # define ARCHITECTURE_ID "ARM" 301 | 302 | # elif defined(_M_MIPS) 303 | # define ARCHITECTURE_ID "MIPS" 304 | 305 | # elif defined(_M_SH) 306 | # define ARCHITECTURE_ID "SHx" 307 | 308 | # else /* unknown architecture */ 309 | # define ARCHITECTURE_ID "" 310 | # endif 311 | 312 | #else 313 | # define ARCHITECTURE_ID "" 314 | #endif 315 | 316 | /* Convert integer to decimal digit literals. */ 317 | #define DEC(n) \ 318 | ('0' + (((n) / 10000000)%10)), \ 319 | ('0' + (((n) / 1000000)%10)), \ 320 | ('0' + (((n) / 100000)%10)), \ 321 | ('0' + (((n) / 10000)%10)), \ 322 | ('0' + (((n) / 1000)%10)), \ 323 | ('0' + (((n) / 100)%10)), \ 324 | ('0' + (((n) / 10)%10)), \ 325 | ('0' + ((n) % 10)) 326 | 327 | /* Convert integer to hex digit literals. */ 328 | #define HEX(n) \ 329 | ('0' + ((n)>>28 & 0xF)), \ 330 | ('0' + ((n)>>24 & 0xF)), \ 331 | ('0' + ((n)>>20 & 0xF)), \ 332 | ('0' + ((n)>>16 & 0xF)), \ 333 | ('0' + ((n)>>12 & 0xF)), \ 334 | ('0' + ((n)>>8 & 0xF)), \ 335 | ('0' + ((n)>>4 & 0xF)), \ 336 | ('0' + ((n) & 0xF)) 337 | 338 | /* Construct a string literal encoding the version number components. */ 339 | #ifdef COMPILER_VERSION_MAJOR 340 | char const info_version[] = { 341 | 'I', 'N', 'F', 'O', ':', 342 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 343 | COMPILER_VERSION_MAJOR, 344 | # ifdef COMPILER_VERSION_MINOR 345 | '.', COMPILER_VERSION_MINOR, 346 | # ifdef COMPILER_VERSION_PATCH 347 | '.', COMPILER_VERSION_PATCH, 348 | # ifdef COMPILER_VERSION_TWEAK 349 | '.', COMPILER_VERSION_TWEAK, 350 | # endif 351 | # endif 352 | # endif 353 | ']','\0'}; 354 | #endif 355 | 356 | /* Construct the string literal in pieces to prevent the source from 357 | getting matched. Store it in a pointer rather than an array 358 | because some compilers will just produce instructions to fill the 359 | array rather than assigning a pointer to a static array. */ 360 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 361 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 362 | 363 | 364 | 365 | /*--------------------------------------------------------------------------*/ 366 | 367 | int main(int argc, char* argv[]) 368 | { 369 | int require = 0; 370 | require += info_compiler[argc]; 371 | require += info_platform[argc]; 372 | #ifdef COMPILER_VERSION_MAJOR 373 | require += info_version[argc]; 374 | #endif 375 | (void)argv; 376 | return require; 377 | } 378 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/2.8.12.2/CompilerIdC/CMakeCCompilerId.c: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | # error "A C++ compiler has been selected for C." 3 | #endif 4 | 5 | /* Version number components: V=Version, R=Revision, P=Patch 6 | Version date components: YYYY=Year, MM=Month, DD=Day */ 7 | 8 | #if defined(__18CXX) 9 | # define ID_VOID_MAIN 10 | #endif 11 | 12 | #if defined(__INTEL_COMPILER) || defined(__ICC) 13 | # define COMPILER_ID "Intel" 14 | /* __INTEL_COMPILER = VRP */ 15 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 16 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 17 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 18 | # if defined(__INTEL_COMPILER_BUILD_DATE) 19 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 20 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 21 | # endif 22 | 23 | #elif defined(__PATHCC__) 24 | # define COMPILER_ID "PathScale" 25 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 26 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 27 | # if defined(__PATHCC_PATCHLEVEL__) 28 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 29 | # endif 30 | 31 | #elif defined(__clang__) 32 | # define COMPILER_ID "Clang" 33 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 34 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 35 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 36 | 37 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 38 | # define COMPILER_ID "Embarcadero" 39 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 40 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 41 | # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF) 42 | 43 | #elif defined(__BORLANDC__) 44 | # define COMPILER_ID "Borland" 45 | /* __BORLANDC__ = 0xVRR */ 46 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 47 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 48 | 49 | #elif defined(__WATCOMC__) 50 | # define COMPILER_ID "Watcom" 51 | /* __WATCOMC__ = VVRR */ 52 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 53 | # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) 54 | 55 | #elif defined(__SUNPRO_C) 56 | # define COMPILER_ID "SunPro" 57 | # if __SUNPRO_C >= 0x5100 58 | /* __SUNPRO_C = 0xVRRP */ 59 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) 60 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) 61 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 62 | # else 63 | /* __SUNPRO_C = 0xVRP */ 64 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) 65 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) 66 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 67 | # endif 68 | 69 | #elif defined(__HP_cc) 70 | # define COMPILER_ID "HP" 71 | /* __HP_cc = VVRRPP */ 72 | # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) 73 | # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) 74 | # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) 75 | 76 | #elif defined(__DECC) 77 | # define COMPILER_ID "Compaq" 78 | /* __DECC_VER = VVRRTPPPP */ 79 | # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) 80 | # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) 81 | # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) 82 | 83 | #elif defined(__IBMC__) 84 | # if defined(__COMPILER_VER__) 85 | # define COMPILER_ID "zOS" 86 | # else 87 | # if __IBMC__ >= 800 88 | # define COMPILER_ID "XL" 89 | # else 90 | # define COMPILER_ID "VisualAge" 91 | # endif 92 | /* __IBMC__ = VRP */ 93 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 94 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 95 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 96 | # endif 97 | 98 | #elif defined(__PGI) 99 | # define COMPILER_ID "PGI" 100 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 101 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 102 | # if defined(__PGIC_PATCHLEVEL__) 103 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 104 | # endif 105 | 106 | #elif defined(_CRAYC) 107 | # define COMPILER_ID "Cray" 108 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE) 109 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 110 | 111 | #elif defined(__TI_COMPILER_VERSION__) 112 | # define COMPILER_ID "TI" 113 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 114 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 115 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 116 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 117 | 118 | #elif defined(__TINYC__) 119 | # define COMPILER_ID "TinyCC" 120 | 121 | #elif defined(__SCO_VERSION__) 122 | # define COMPILER_ID "SCO" 123 | 124 | #elif defined(__GNUC__) 125 | # define COMPILER_ID "GNU" 126 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 127 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 128 | # if defined(__GNUC_PATCHLEVEL__) 129 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 130 | # endif 131 | 132 | #elif defined(_MSC_VER) 133 | # define COMPILER_ID "MSVC" 134 | /* _MSC_VER = VVRR */ 135 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 136 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 137 | # if defined(_MSC_FULL_VER) 138 | # if _MSC_VER >= 1400 139 | /* _MSC_FULL_VER = VVRRPPPPP */ 140 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 141 | # else 142 | /* _MSC_FULL_VER = VVRRPPPP */ 143 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 144 | # endif 145 | # endif 146 | # if defined(_MSC_BUILD) 147 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 148 | # endif 149 | 150 | /* Analog VisualDSP++ >= 4.5.6 */ 151 | #elif defined(__VISUALDSPVERSION__) 152 | # define COMPILER_ID "ADSP" 153 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 154 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 155 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 156 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 157 | 158 | /* Analog VisualDSP++ < 4.5.6 */ 159 | #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 160 | # define COMPILER_ID "ADSP" 161 | 162 | /* IAR Systems compiler for embedded systems. 163 | http://www.iar.com */ 164 | #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) 165 | # define COMPILER_ID "IAR" 166 | 167 | /* sdcc, the small devices C compiler for embedded systems, 168 | http://sdcc.sourceforge.net */ 169 | #elif defined(SDCC) 170 | # define COMPILER_ID "SDCC" 171 | /* SDCC = VRP */ 172 | # define COMPILER_VERSION_MAJOR DEC(SDCC/100) 173 | # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) 174 | # define COMPILER_VERSION_PATCH DEC(SDCC % 10) 175 | 176 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 177 | # define COMPILER_ID "MIPSpro" 178 | # if defined(_SGI_COMPILER_VERSION) 179 | /* _SGI_COMPILER_VERSION = VRP */ 180 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 181 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 182 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 183 | # else 184 | /* _COMPILER_VERSION = VRP */ 185 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 186 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 187 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 188 | # endif 189 | 190 | /* This compiler is either not known or is too old to define an 191 | identification macro. Try to identify the platform and guess that 192 | it is the native compiler. */ 193 | #elif defined(__sgi) 194 | # define COMPILER_ID "MIPSpro" 195 | 196 | #elif defined(__hpux) || defined(__hpua) 197 | # define COMPILER_ID "HP" 198 | 199 | #else /* unknown compiler */ 200 | # define COMPILER_ID "" 201 | 202 | #endif 203 | 204 | /* Construct the string literal in pieces to prevent the source from 205 | getting matched. Store it in a pointer rather than an array 206 | because some compilers will just produce instructions to fill the 207 | array rather than assigning a pointer to a static array. */ 208 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 209 | 210 | /* Identify known platforms by name. */ 211 | #if defined(__linux) || defined(__linux__) || defined(linux) 212 | # define PLATFORM_ID "Linux" 213 | 214 | #elif defined(__CYGWIN__) 215 | # define PLATFORM_ID "Cygwin" 216 | 217 | #elif defined(__MINGW32__) 218 | # define PLATFORM_ID "MinGW" 219 | 220 | #elif defined(__APPLE__) 221 | # define PLATFORM_ID "Darwin" 222 | 223 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 224 | # define PLATFORM_ID "Windows" 225 | 226 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 227 | # define PLATFORM_ID "FreeBSD" 228 | 229 | #elif defined(__NetBSD__) || defined(__NetBSD) 230 | # define PLATFORM_ID "NetBSD" 231 | 232 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 233 | # define PLATFORM_ID "OpenBSD" 234 | 235 | #elif defined(__sun) || defined(sun) 236 | # define PLATFORM_ID "SunOS" 237 | 238 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 239 | # define PLATFORM_ID "AIX" 240 | 241 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 242 | # define PLATFORM_ID "IRIX" 243 | 244 | #elif defined(__hpux) || defined(__hpux__) 245 | # define PLATFORM_ID "HP-UX" 246 | 247 | #elif defined(__HAIKU__) 248 | # define PLATFORM_ID "Haiku" 249 | 250 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 251 | # define PLATFORM_ID "BeOS" 252 | 253 | #elif defined(__QNX__) || defined(__QNXNTO__) 254 | # define PLATFORM_ID "QNX" 255 | 256 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 257 | # define PLATFORM_ID "Tru64" 258 | 259 | #elif defined(__riscos) || defined(__riscos__) 260 | # define PLATFORM_ID "RISCos" 261 | 262 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 263 | # define PLATFORM_ID "SINIX" 264 | 265 | #elif defined(__UNIX_SV__) 266 | # define PLATFORM_ID "UNIX_SV" 267 | 268 | #elif defined(__bsdos__) 269 | # define PLATFORM_ID "BSDOS" 270 | 271 | #elif defined(_MPRAS) || defined(MPRAS) 272 | # define PLATFORM_ID "MP-RAS" 273 | 274 | #elif defined(__osf) || defined(__osf__) 275 | # define PLATFORM_ID "OSF1" 276 | 277 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 278 | # define PLATFORM_ID "SCO_SV" 279 | 280 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 281 | # define PLATFORM_ID "ULTRIX" 282 | 283 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 284 | # define PLATFORM_ID "Xenix" 285 | 286 | #else /* unknown platform */ 287 | # define PLATFORM_ID "" 288 | 289 | #endif 290 | 291 | /* For windows compilers MSVC and Intel we can determine 292 | the architecture of the compiler being used. This is because 293 | the compilers do not have flags that can change the architecture, 294 | but rather depend on which compiler is being used 295 | */ 296 | #if defined(_WIN32) && defined(_MSC_VER) 297 | # if defined(_M_IA64) 298 | # define ARCHITECTURE_ID "IA64" 299 | 300 | # elif defined(_M_X64) || defined(_M_AMD64) 301 | # define ARCHITECTURE_ID "x64" 302 | 303 | # elif defined(_M_IX86) 304 | # define ARCHITECTURE_ID "X86" 305 | 306 | # elif defined(_M_ARM) 307 | # define ARCHITECTURE_ID "ARM" 308 | 309 | # elif defined(_M_MIPS) 310 | # define ARCHITECTURE_ID "MIPS" 311 | 312 | # elif defined(_M_SH) 313 | # define ARCHITECTURE_ID "SHx" 314 | 315 | # else /* unknown architecture */ 316 | # define ARCHITECTURE_ID "" 317 | # endif 318 | 319 | #else 320 | # define ARCHITECTURE_ID "" 321 | #endif 322 | 323 | /* Convert integer to decimal digit literals. */ 324 | #define DEC(n) \ 325 | ('0' + (((n) / 10000000)%10)), \ 326 | ('0' + (((n) / 1000000)%10)), \ 327 | ('0' + (((n) / 100000)%10)), \ 328 | ('0' + (((n) / 10000)%10)), \ 329 | ('0' + (((n) / 1000)%10)), \ 330 | ('0' + (((n) / 100)%10)), \ 331 | ('0' + (((n) / 10)%10)), \ 332 | ('0' + ((n) % 10)) 333 | 334 | /* Convert integer to hex digit literals. */ 335 | #define HEX(n) \ 336 | ('0' + ((n)>>28 & 0xF)), \ 337 | ('0' + ((n)>>24 & 0xF)), \ 338 | ('0' + ((n)>>20 & 0xF)), \ 339 | ('0' + ((n)>>16 & 0xF)), \ 340 | ('0' + ((n)>>12 & 0xF)), \ 341 | ('0' + ((n)>>8 & 0xF)), \ 342 | ('0' + ((n)>>4 & 0xF)), \ 343 | ('0' + ((n) & 0xF)) 344 | 345 | /* Construct a string literal encoding the version number components. */ 346 | #ifdef COMPILER_VERSION_MAJOR 347 | char const info_version[] = { 348 | 'I', 'N', 'F', 'O', ':', 349 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 350 | COMPILER_VERSION_MAJOR, 351 | # ifdef COMPILER_VERSION_MINOR 352 | '.', COMPILER_VERSION_MINOR, 353 | # ifdef COMPILER_VERSION_PATCH 354 | '.', COMPILER_VERSION_PATCH, 355 | # ifdef COMPILER_VERSION_TWEAK 356 | '.', COMPILER_VERSION_TWEAK, 357 | # endif 358 | # endif 359 | # endif 360 | ']','\0'}; 361 | #endif 362 | 363 | /* Construct the string literal in pieces to prevent the source from 364 | getting matched. Store it in a pointer rather than an array 365 | because some compilers will just produce instructions to fill the 366 | array rather than assigning a pointer to a static array. */ 367 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 368 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 369 | 370 | 371 | 372 | /*--------------------------------------------------------------------------*/ 373 | 374 | #ifdef ID_VOID_MAIN 375 | void main() {} 376 | #else 377 | int main(int argc, char* argv[]) 378 | { 379 | int require = 0; 380 | require += info_compiler[argc]; 381 | require += info_platform[argc]; 382 | require += info_arch[argc]; 383 | #ifdef COMPILER_VERSION_MAJOR 384 | require += info_version[argc]; 385 | #endif 386 | (void)argv; 387 | return require; 388 | } 389 | #endif 390 | -------------------------------------------------------------------------------- /WebBench/webbench.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Radim Kolar 1997-2004 3 | * This is free software, see GNU Public License version 2 for 4 | * details. 5 | * 6 | * Simple forking WWW Server benchmark: 7 | * 8 | * Usage: 9 | * webbench --help 10 | * 11 | * Return codes: 12 | * 0 - sucess 13 | * 1 - benchmark failed (server is not on-line) 14 | * 2 - bad param 15 | * 3 - internal error, fork failed 16 | * 17 | */ 18 | 19 | #include "socket.c" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | /* values */ 30 | volatile int timerexpired=0; 31 | int speed=0; 32 | int failed=0; 33 | int bytes=0; 34 | 35 | /* globals */ 36 | int http10=1; /* 0 - http/0.9, 1 - http/1.0, 2 - http/1.1 */ 37 | /* Allow: GET, HEAD, OPTIONS, TRACE */ 38 | #define METHOD_GET 0 39 | #define METHOD_HEAD 1 40 | #define METHOD_OPTIONS 2 41 | #define METHOD_TRACE 3 42 | #define PROGRAM_VERSION "1.5" 43 | int method=METHOD_GET; 44 | int clients=1; 45 | int force=0; 46 | int force_reload=0; 47 | int proxyport=80; 48 | char *proxyhost=NULL; 49 | int benchtime=30; 50 | 51 | bool keep_alive = false; 52 | 53 | /* internal */ 54 | int mypipe[2]; 55 | char host[MAXHOSTNAMELEN]; 56 | #define REQUEST_SIZE 2048 57 | char request[REQUEST_SIZE]; 58 | 59 | static const struct option long_options[]= 60 | { 61 | {"force",no_argument,&force,1}, 62 | {"reload",no_argument,&force_reload,1}, 63 | {"time",required_argument,NULL,'t'}, 64 | {"help",no_argument,NULL,'?'}, 65 | {"http09",no_argument,NULL,'9'}, 66 | {"http10",no_argument,NULL,'1'}, 67 | {"http11",no_argument,NULL,'2'}, 68 | {"get",no_argument,&method,METHOD_GET}, 69 | {"head",no_argument,&method,METHOD_HEAD}, 70 | {"options",no_argument,&method,METHOD_OPTIONS}, 71 | {"trace",no_argument,&method,METHOD_TRACE}, 72 | {"version",no_argument,NULL,'V'}, 73 | {"proxy",required_argument,NULL,'p'}, 74 | {"clients",required_argument,NULL,'c'}, 75 | {NULL,0,NULL,0} 76 | }; 77 | 78 | /* prototypes */ 79 | static void benchcore(const char* host,const int port, const char *request); 80 | static int bench(void); 81 | static void build_request(const char *url); 82 | 83 | static void alarm_handler(int signal) 84 | { 85 | timerexpired=1; 86 | } 87 | 88 | static void usage(void) 89 | { 90 | fprintf(stderr, 91 | "webbench [option]... URL\n" 92 | " -f|--force Don't wait for reply from server.\n" 93 | " -r|--reload Send reload request - Pragma: no-cache.\n" 94 | " -t|--time Run benchmark for seconds. Default 30.\n" 95 | " -p|--proxy Use proxy server for request.\n" 96 | " -c|--clients Run HTTP clients at once. Default one.\n" 97 | " -k|--keep Keep-Alive\n" 98 | " -9|--http09 Use HTTP/0.9 style requests.\n" 99 | " -1|--http10 Use HTTP/1.0 protocol.\n" 100 | " -2|--http11 Use HTTP/1.1 protocol.\n" 101 | " --get Use GET request method.\n" 102 | " --head Use HEAD request method.\n" 103 | " --options Use OPTIONS request method.\n" 104 | " --trace Use TRACE request method.\n" 105 | " -?|-h|--help This information.\n" 106 | " -V|--version Display program version.\n" 107 | ); 108 | } 109 | 110 | int main(int argc, char *argv[]) 111 | { 112 | int opt=0; 113 | int options_index=0; 114 | char *tmp=NULL; 115 | 116 | if(argc==1) 117 | { 118 | usage(); 119 | return 2; 120 | } 121 | 122 | while((opt=getopt_long(argc,argv,"912Vfrt:p:c:?hk",long_options,&options_index))!=EOF ) 123 | { 124 | switch(opt) 125 | { 126 | case 0 : break; 127 | case 'f': force=1;break; 128 | case 'r': force_reload=1;break; 129 | case '9': http10=0;break; 130 | case '1': http10=1;break; 131 | case '2': http10=2;break; 132 | case 'V': printf(PROGRAM_VERSION"\n");exit(0); 133 | case 't': benchtime=atoi(optarg);break; 134 | case 'k': keep_alive = true;break; 135 | case 'p': 136 | /* proxy server parsing server:port */ 137 | tmp=strrchr(optarg,':'); 138 | proxyhost=optarg; 139 | if(tmp==NULL) 140 | { 141 | break; 142 | } 143 | if(tmp==optarg) 144 | { 145 | fprintf(stderr,"Error in option --proxy %s: Missing hostname.\n",optarg); 146 | return 2; 147 | } 148 | if(tmp==optarg+strlen(optarg)-1) 149 | { 150 | fprintf(stderr,"Error in option --proxy %s Port number is missing.\n",optarg); 151 | return 2; 152 | } 153 | *tmp='\0'; 154 | proxyport=atoi(tmp+1);break; 155 | case ':': 156 | case 'h': 157 | case '?': usage();return 2;break; 158 | case 'c': clients=atoi(optarg);break; 159 | } 160 | } 161 | 162 | if(optind==argc) { 163 | fprintf(stderr,"webbench: Missing URL!\n"); 164 | usage(); 165 | return 2; 166 | } 167 | 168 | if(clients==0) clients=1; 169 | if(benchtime==0) benchtime=30; 170 | 171 | /* Copyright */ 172 | fprintf(stderr,"Webbench - Simple Web Benchmark "PROGRAM_VERSION"\n" 173 | "Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.\n" 174 | ); 175 | 176 | build_request(argv[optind]); 177 | 178 | // print request info ,do it in function build_request 179 | /*printf("Benchmarking: "); 180 | 181 | switch(method) 182 | { 183 | case METHOD_GET: 184 | default: 185 | printf("GET");break; 186 | case METHOD_OPTIONS: 187 | printf("OPTIONS");break; 188 | case METHOD_HEAD: 189 | printf("HEAD");break; 190 | case METHOD_TRACE: 191 | printf("TRACE");break; 192 | } 193 | 194 | printf(" %s",argv[optind]); 195 | 196 | switch(http10) 197 | { 198 | case 0: printf(" (using HTTP/0.9)");break; 199 | case 2: printf(" (using HTTP/1.1)");break; 200 | } 201 | 202 | printf("\n"); 203 | */ 204 | 205 | printf("Runing info: "); 206 | 207 | if(clients==1) 208 | printf("1 client"); 209 | else 210 | printf("%d clients",clients); 211 | 212 | printf(", running %d sec", benchtime); 213 | 214 | if(force) printf(", early socket close"); 215 | if(proxyhost!=NULL) printf(", via proxy server %s:%d",proxyhost,proxyport); 216 | if(force_reload) printf(", forcing reload"); 217 | 218 | printf(".\n"); 219 | 220 | return bench(); 221 | } 222 | 223 | void build_request(const char *url) 224 | { 225 | char tmp[10]; 226 | int i; 227 | 228 | //bzero(host,MAXHOSTNAMELEN); 229 | //bzero(request,REQUEST_SIZE); 230 | memset(host,0,MAXHOSTNAMELEN); 231 | memset(request,0,REQUEST_SIZE); 232 | 233 | if(force_reload && proxyhost!=NULL && http10<1) http10=1; 234 | if(method==METHOD_HEAD && http10<1) http10=1; 235 | if(method==METHOD_OPTIONS && http10<2) http10=2; 236 | if(method==METHOD_TRACE && http10<2) http10=2; 237 | 238 | switch(method) 239 | { 240 | default: 241 | case METHOD_GET: strcpy(request,"GET");break; 242 | case METHOD_HEAD: strcpy(request,"HEAD");break; 243 | case METHOD_OPTIONS: strcpy(request,"OPTIONS");break; 244 | case METHOD_TRACE: strcpy(request,"TRACE");break; 245 | } 246 | 247 | strcat(request," "); 248 | 249 | if(NULL==strstr(url,"://")) 250 | { 251 | fprintf(stderr, "\n%s: is not a valid URL.\n",url); 252 | exit(2); 253 | } 254 | if(strlen(url)>1500) 255 | { 256 | fprintf(stderr,"URL is too long.\n"); 257 | exit(2); 258 | } 259 | if (0!=strncasecmp("http://",url,7)) 260 | { 261 | fprintf(stderr,"\nOnly HTTP protocol is directly supported, set --proxy for others.\n"); 262 | exit(2); 263 | } 264 | 265 | /* protocol/host delimiter */ 266 | i=strstr(url,"://")-url+3; 267 | 268 | if(strchr(url+i,'/')==NULL) { 269 | fprintf(stderr,"\nInvalid URL syntax - hostname don't ends with '/'.\n"); 270 | exit(2); 271 | } 272 | 273 | if(proxyhost==NULL) 274 | { 275 | /* get port from hostname */ 276 | if(index(url+i,':')!=NULL && index(url+i,':')0) 307 | strcat(request,"User-Agent: WebBench "PROGRAM_VERSION"\r\n"); 308 | if(proxyhost==NULL && http10>0) 309 | { 310 | strcat(request,"Host: "); 311 | strcat(request,host); 312 | strcat(request,"\r\n"); 313 | } 314 | 315 | if(force_reload && proxyhost!=NULL) 316 | { 317 | strcat(request,"Pragma: no-cache\r\n"); 318 | } 319 | 320 | if(http10>1) 321 | { 322 | if (!keep_alive) 323 | strcat(request,"Connection: close\r\n"); 324 | else 325 | strcat(request,"Connection: Keep-Alive\r\n"); 326 | } 327 | 328 | 329 | /* add empty line at end */ 330 | if(http10>0) strcat(request,"\r\n"); 331 | 332 | printf("\nRequest:\n%s\n",request); 333 | } 334 | 335 | /* vraci system rc error kod */ 336 | static int bench(void) 337 | { 338 | int i,j,k; 339 | pid_t pid=0; 340 | FILE *f; 341 | 342 | /* check avaibility of target server */ 343 | i=Socket(proxyhost==NULL?host:proxyhost,proxyport); 344 | if(i<0) { 345 | fprintf(stderr,"\nConnect to server failed. Aborting benchmark.\n"); 346 | return 1; 347 | } 348 | close(i); 349 | 350 | /* create pipe */ 351 | if(pipe(mypipe)) 352 | { 353 | perror("pipe failed."); 354 | return 3; 355 | } 356 | 357 | /* not needed, since we have alarm() in childrens */ 358 | /* wait 4 next system clock tick */ 359 | /* 360 | cas=time(NULL); 361 | while(time(NULL)==cas) 362 | sched_yield(); 363 | */ 364 | 365 | /* fork childs */ 366 | for(i=0;i0) 483 | { 484 | /* fprintf(stderr,"Correcting failed by signal\n"); */ 485 | failed--; 486 | } 487 | return; 488 | } 489 | 490 | if(s<0) { failed++;continue;} 491 | if(rlen!=write(s,req,rlen)) { 492 | failed++; 493 | close(s); 494 | while ((s = Socket(host,port)) == -1); 495 | continue; 496 | } 497 | if(force==0) 498 | { 499 | /* read all available data from socket */ 500 | while(1) 501 | { 502 | if(timerexpired) break; 503 | i=read(s,buf,1500); 504 | /* fprintf(stderr,"%d\n",i); */ 505 | if(i<0) 506 | { 507 | failed++; 508 | close(s); 509 | //while ((s = Socket(host,port)) == -1); 510 | goto nexttry1; 511 | } 512 | else 513 | if(i==0) break; 514 | else 515 | bytes+=i; 516 | // Supposed reveived bytes were less than 1500 517 | //if (i < 1500) 518 | break; 519 | } 520 | } 521 | speed++; 522 | } 523 | } 524 | else 525 | { 526 | nexttry:while(1) 527 | { 528 | if(timerexpired) 529 | { 530 | if(failed>0) 531 | { 532 | /* fprintf(stderr,"Correcting failed by signal\n"); */ 533 | failed--; 534 | } 535 | return; 536 | } 537 | s=Socket(host,port); 538 | if(s<0) { failed++;continue;} 539 | if(rlen!=write(s,req,rlen)) {failed++;close(s);continue;} 540 | if(http10==0) 541 | if(shutdown(s,1)) { failed++;close(s);continue;} 542 | if(force==0) 543 | { 544 | /* read all available data from socket */ 545 | while(1) 546 | { 547 | if(timerexpired) break; 548 | i=read(s,buf,1500); 549 | if(i<0) 550 | { 551 | failed++; 552 | close(s); 553 | goto nexttry; 554 | } 555 | else 556 | if(i==0) break; 557 | else 558 | bytes+=i; 559 | } 560 | } 561 | if(close(s)) {failed++; continue;} 562 | speed++; 563 | } 564 | } 565 | 566 | 567 | } -------------------------------------------------------------------------------- /WebServer/HttpData.cpp: -------------------------------------------------------------------------------- 1 | #include "HttpData.h" 2 | #include "time.h" 3 | #include "Channel.h" 4 | #include "Util.h" 5 | #include "EventLoop.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | pthread_once_t MimeType::once_control = PTHREAD_ONCE_INIT; 14 | std::unordered_map MimeType::mime; 15 | 16 | 17 | const __uint32_t DEFAULT_EVENT = EPOLLIN | EPOLLET | EPOLLONESHOT; 18 | const int DEFAULT_EXPIRED_TIME = 2000; // ms tcp默认超时时间 19 | const int DEFAULT_KEEP_ALIVE_TIME = 5 * 60 * 1000; // ms tcp长连接保活机制 20 | 21 | 22 | 23 | void MimeType::init() 24 | { 25 | mime[".html"] = "text/html"; 26 | mime[".avi"] = "video/x-msvideo"; 27 | mime[".bmp"] = "image/bmp"; 28 | mime[".c"] = "text/plain"; 29 | mime[".doc"] = "application/msword"; 30 | mime[".gif"] = "image/gif"; 31 | mime[".gz"] = "application/x-gzip"; 32 | mime[".htm"] = "text/html"; 33 | mime[".ico"] = "application/x-ico"; 34 | mime[".jpg"] = "image/jpeg"; 35 | mime[".png"] = "image/png"; 36 | mime[".txt"] = "text/plain"; 37 | mime[".mp3"] = "audio/mp3"; 38 | mime["default"] = "text/html"; 39 | } 40 | 41 | std::string MimeType::getMime(const std::string &suffix) 42 | { 43 | pthread_once(&once_control, MimeType::init); 44 | if (mime.find(suffix) == mime.end()) 45 | return mime["default"]; 46 | else 47 | return mime[suffix]; 48 | } 49 | 50 | 51 | HttpData::HttpData(EventLoop *loop, int connfd): 52 | loop_(loop), 53 | channel_(new Channel(loop, connfd)), 54 | fd_(connfd), 55 | error_(false), 56 | connectionState_(H_CONNECTED), 57 | method_(METHOD_GET), 58 | HTTPVersion_(HTTP_11), 59 | nowReadPos_(0), 60 | state_(STATE_PARSE_URI), 61 | hState_(H_START), 62 | keepAlive_(false) 63 | { 64 | //Channel注册http协议的具体处理方法(注册回调函数) 65 | channel_->setReadHandler(bind(&HttpData::handleRead, this)); 66 | channel_->setWriteHandler(bind(&HttpData::handleWrite, this)); 67 | channel_->setConnHandler(bind(&HttpData::handleConn, this)); 68 | } 69 | 70 | // http报文复位,重新设置 71 | void HttpData::reset() 72 | { 73 | inBuffer_.clear(); 74 | fileName_.clear(); 75 | path_.clear(); 76 | nowReadPos_ = 0; 77 | state_ = STATE_PARSE_URI; 78 | hState_ = H_START; 79 | headers_.clear(); 80 | //keepAlive_ = false; 81 | if (timer_.lock()) //timer_ is the weak_ptr 82 | { 83 | shared_ptr my_timer(timer_.lock()); 84 | my_timer->clearReq(); 85 | timer_.reset(); 86 | } 87 | } 88 | 89 | // 脱离时间计时器 90 | void HttpData::seperateTimer() 91 | { 92 | //cout << "seperateTimer" << endl; 93 | if (timer_.lock()) 94 | { 95 | shared_ptr my_timer(timer_.lock()); 96 | my_timer->clearReq(); 97 | timer_.reset(); 98 | } 99 | } 100 | 101 | void HttpData::handleRead() 102 | { 103 | __uint32_t &events_ = channel_->getEvents(); 104 | do 105 | { 106 | bool zero = false; 107 | int read_num = readn(fd_, inBuffer_, zero); 108 | if (connectionState_ == H_DISCONNECTING) 109 | { 110 | inBuffer_.clear(); 111 | break; 112 | } 113 | //cout << inBuffer_ << endl; 114 | if (read_num < 0) 115 | { 116 | perror("1"); 117 | error_ = true; 118 | handleError(fd_, 400, "Bad Request"); 119 | break; 120 | } 121 | // else if (read_num == 0) 122 | // { 123 | // error_ = true; 124 | // break; 125 | // } 126 | else if (zero) 127 | { 128 | // 有请求出现但是读不到数据,可能是Request Aborted,或者来自网络的数据没有达到等原因 129 | // 最可能是对端已经关闭了,统一按照对端已经关闭处理 130 | //error_ = true; 131 | connectionState_ = H_DISCONNECTING; 132 | if (read_num == 0) 133 | { 134 | //error_ = true; 135 | break; 136 | } 137 | //cout << "readnum == 0" << endl; 138 | } 139 | 140 | 141 | if (state_ == STATE_PARSE_URI) 142 | { 143 | URIState flag = this->parseURI(); 144 | if (flag == PARSE_URI_AGAIN) 145 | break; 146 | else if (flag == PARSE_URI_ERROR) 147 | { 148 | perror("2"); 149 | //LOG << "FD = " << fd_ << "," << inBuffer_ << "******"; 150 | inBuffer_.clear(); 151 | error_ = true; 152 | handleError(fd_, 400, "Bad Request"); 153 | break; 154 | } 155 | else 156 | state_ = STATE_PARSE_HEADERS; 157 | } 158 | if (state_ == STATE_PARSE_HEADERS) 159 | { 160 | HeaderState flag = this->parseHeaders(); 161 | if (flag == PARSE_HEADER_AGAIN) 162 | break; 163 | else if (flag == PARSE_HEADER_ERROR) 164 | { 165 | perror("3"); 166 | error_ = true; 167 | handleError(fd_, 400, "Bad Request"); 168 | break; 169 | } 170 | if(method_ == METHOD_POST) 171 | { 172 | // POST方法准备 173 | state_ = STATE_RECV_BODY; 174 | } 175 | else 176 | { 177 | state_ = STATE_ANALYSIS; 178 | } 179 | } 180 | if (state_ == STATE_RECV_BODY) 181 | { 182 | int content_length = -1; 183 | if (headers_.find("Content-length") != headers_.end()) 184 | { 185 | content_length = stoi(headers_["Content-length"]); 186 | } 187 | else 188 | { 189 | //cout << "(state_ == STATE_RECV_BODY)" << endl; 190 | error_ = true; 191 | handleError(fd_, 400, "Bad Request: Lack of argument (Content-length)"); 192 | break; 193 | } 194 | if (static_cast(inBuffer_.size()) < content_length) 195 | break; 196 | state_ = STATE_ANALYSIS; 197 | } 198 | if (state_ == STATE_ANALYSIS) 199 | { 200 | AnalysisState flag = this->analysisRequest(); 201 | if (flag == ANALYSIS_SUCCESS) 202 | { 203 | state_ = STATE_FINISH; 204 | break; 205 | } 206 | else 207 | { 208 | //cout << "state_ == STATE_ANALYSIS" << endl; 209 | error_ = true; 210 | break; 211 | } 212 | } 213 | } while (false); 214 | //cout << "state_=" << state_ << endl; 215 | if (!error_) 216 | { 217 | if (outBuffer_.size() > 0) 218 | { 219 | handleWrite(); 220 | //events_ |= EPOLLOUT; 221 | } 222 | // error_ may change 223 | if (!error_ && state_ == STATE_FINISH) 224 | { 225 | 226 | if (keepAlive_ && connectionState_ == H_CONNECTED) 227 | { 228 | this->reset(); 229 | events_ |= EPOLLIN; 230 | } 231 | else 232 | return; 233 | } 234 | else if (!error_ && connectionState_ != H_DISCONNECTED) 235 | events_ |= EPOLLIN; 236 | } 237 | } 238 | 239 | void HttpData::handleWrite() 240 | { 241 | if (!error_ && connectionState_ != H_DISCONNECTED) 242 | { 243 | __uint32_t &events_ = channel_->getEvents(); 244 | if (writen(fd_, outBuffer_) < 0) 245 | { 246 | perror("writen"); 247 | events_ = 0; 248 | error_ = true; 249 | } 250 | if (outBuffer_.size() > 0) 251 | events_ |= EPOLLOUT; 252 | } 253 | } 254 | 255 | void HttpData::handleConn() 256 | { 257 | seperateTimer(); 258 | __uint32_t &events_ = channel_->getEvents(); 259 | if (!error_ && connectionState_ == H_CONNECTED) 260 | { 261 | if (events_ != 0) 262 | { 263 | int timeout = DEFAULT_EXPIRED_TIME; 264 | if (keepAlive_) 265 | timeout = DEFAULT_KEEP_ALIVE_TIME; 266 | if ((events_ & EPOLLIN) && (events_ & EPOLLOUT)) 267 | { 268 | events_ = __uint32_t(0); 269 | events_ |= EPOLLOUT; 270 | } 271 | //events_ |= (EPOLLET | EPOLLONESHOT); 272 | events_ |= EPOLLET; 273 | loop_->updatePoller(channel_, timeout); 274 | 275 | } 276 | else if (keepAlive_) // 长连接 277 | { 278 | events_ |= (EPOLLIN | EPOLLET); 279 | //events_ |= (EPOLLIN | EPOLLET | EPOLLONESHOT); 280 | int timeout = DEFAULT_KEEP_ALIVE_TIME; 281 | loop_->updatePoller(channel_, timeout); 282 | } 283 | else //短连接,立即关闭 284 | { 285 | //cout << "close normally" << endl; 286 | loop_->shutdown(channel_); 287 | loop_->runInLoop(bind(&HttpData::handleClose, shared_from_this())); //enable_shared_from_this 分享安全的新建的对象 288 | } 289 | } 290 | else if (!error_ && connectionState_ == H_DISCONNECTING && (events_ & EPOLLOUT)) 291 | { 292 | events_ = (EPOLLOUT | EPOLLET); 293 | } 294 | else 295 | { 296 | //cout << "close with errors" << endl; 297 | loop_->runInLoop(bind(&HttpData::handleClose, shared_from_this())); //enable_shared_from_this 分享安全的新建的对象 298 | } 299 | } 300 | 301 | 302 | URIState HttpData::parseURI() 303 | { 304 | string &str = inBuffer_; 305 | string cop = str; 306 | // 读到完整的请求行再开始解析请求 307 | size_t pos = str.find('\r', nowReadPos_); 308 | if (pos < 0) 309 | { 310 | return PARSE_URI_AGAIN; 311 | } 312 | // 去掉请求行所占的空间,节省空间 313 | string request_line = str.substr(0, pos); 314 | if (str.size() > pos + 1) 315 | str = str.substr(pos + 1); 316 | else 317 | str.clear(); 318 | // Method 319 | pos = request_line.find("GET"); 320 | if (pos < 0) 321 | { 322 | pos = request_line.find("POST"); 323 | if (pos < 0) 324 | return PARSE_URI_ERROR; 325 | else 326 | method_ = METHOD_POST; 327 | } 328 | else 329 | method_ = METHOD_GET; 330 | //printf("method_ = %d\n", method_); 331 | // filename 332 | pos = request_line.find("/", pos); 333 | if (pos < 0) 334 | { 335 | fileName_ = "index.html"; 336 | HTTPVersion_ = HTTP_11; 337 | return PARSE_URI_SUCCESS; 338 | } 339 | else 340 | { 341 | size_t _pos = request_line.find(' ', pos); 342 | if (_pos < 0) 343 | return PARSE_URI_ERROR; 344 | else 345 | { 346 | if (_pos - pos > 1) 347 | { 348 | fileName_ = request_line.substr(pos + 1, _pos - pos - 1); 349 | size_t __pos = fileName_.find('?'); 350 | if (__pos >= 0) 351 | { 352 | fileName_ = fileName_.substr(0, __pos); 353 | } 354 | } 355 | 356 | else 357 | fileName_ = "index.html"; 358 | } 359 | pos = _pos; 360 | } 361 | //cout << "fileName_: " << fileName_ << endl; 362 | // HTTP 版本号 363 | pos = request_line.find("/", pos); 364 | if (pos < 0) 365 | return PARSE_URI_ERROR; 366 | else 367 | { 368 | if (request_line.size() - pos <= 3) 369 | return PARSE_URI_ERROR; 370 | else 371 | { 372 | string ver = request_line.substr(pos + 1, 3); 373 | if (ver == "1.0") 374 | HTTPVersion_ = HTTP_10; 375 | else if (ver == "1.1") 376 | HTTPVersion_ = HTTP_11; 377 | else 378 | return PARSE_URI_ERROR; 379 | } 380 | } 381 | return PARSE_URI_SUCCESS; 382 | } 383 | 384 | HeaderState HttpData::parseHeaders() 385 | { 386 | string &str = inBuffer_; 387 | int key_start = -1, key_end = -1, value_start = -1, value_end = -1; 388 | int now_read_line_begin = 0; 389 | bool notFinish = true; 390 | for (size_t i = 0; i < str.size() && notFinish; ++i) 391 | { 392 | switch(hState_) 393 | { 394 | case H_START: 395 | { 396 | if (str[i] == '\n' || str[i] == '\r') 397 | break; 398 | hState_ = H_KEY; 399 | key_start = i; 400 | now_read_line_begin = i; 401 | break; 402 | } 403 | case H_KEY: 404 | { 405 | if (str[i] == ':') 406 | { 407 | key_end = i; 408 | if (key_end - key_start <= 0) 409 | return PARSE_HEADER_ERROR; 410 | hState_ = H_COLON; 411 | } 412 | else if (str[i] == '\n' || str[i] == '\r') 413 | return PARSE_HEADER_ERROR; 414 | break; 415 | } 416 | case H_COLON: 417 | { 418 | if (str[i] == ' ') 419 | { 420 | hState_ = H_SPACES_AFTER_COLON; 421 | } 422 | else 423 | return PARSE_HEADER_ERROR; 424 | break; 425 | } 426 | case H_SPACES_AFTER_COLON: 427 | { 428 | hState_ = H_VALUE; 429 | value_start = i; 430 | break; 431 | } 432 | case H_VALUE: 433 | { 434 | if (str[i] == '\r') 435 | { 436 | hState_ = H_CR; 437 | value_end = i; 438 | if (value_end - value_start <= 0) 439 | return PARSE_HEADER_ERROR; 440 | } 441 | else if (i - value_start > 255) 442 | return PARSE_HEADER_ERROR; 443 | break; 444 | } 445 | case H_CR: 446 | { 447 | if (str[i] == '\n') 448 | { 449 | hState_ = H_LF; 450 | string key(str.begin() + key_start, str.begin() + key_end); 451 | string value(str.begin() + value_start, str.begin() + value_end); 452 | headers_[key] = value; 453 | now_read_line_begin = i; 454 | } 455 | else 456 | return PARSE_HEADER_ERROR; 457 | break; 458 | } 459 | case H_LF: 460 | { 461 | if (str[i] == '\r') 462 | { 463 | hState_ = H_END_CR; 464 | } 465 | else 466 | { 467 | key_start = i; 468 | hState_ = H_KEY; 469 | } 470 | break; 471 | } 472 | case H_END_CR: 473 | { 474 | if (str[i] == '\n') 475 | { 476 | hState_ = H_END_LF; 477 | } 478 | else 479 | return PARSE_HEADER_ERROR; 480 | break; 481 | } 482 | case H_END_LF: 483 | { 484 | notFinish = false; 485 | key_start = i; 486 | now_read_line_begin = i; 487 | break; 488 | } 489 | } 490 | } 491 | if (hState_ == H_END_LF) 492 | { 493 | str = str.substr(now_read_line_begin); 494 | return PARSE_HEADER_SUCCESS; 495 | } 496 | str = str.substr(now_read_line_begin); 497 | return PARSE_HEADER_AGAIN; 498 | } 499 | 500 | AnalysisState HttpData::analysisRequest() 501 | { 502 | if (method_ == METHOD_POST) 503 | { 504 | 505 | } 506 | else if (method_ == METHOD_GET) 507 | { 508 | string header; 509 | header += "HTTP/1.1 200 OK\r\n"; 510 | if(headers_.find("Connection") != headers_.end() && headers_["Connection"] == "Keep-Alive") 511 | { 512 | keepAlive_ = true; 513 | header += string("Connection: Keep-Alive\r\n") + "Keep-Alive: timeout=" + to_string(DEFAULT_KEEP_ALIVE_TIME) + "\r\n"; 514 | } 515 | int dot_pos = fileName_.find('.'); 516 | string filetype; 517 | if (dot_pos < 0) 518 | filetype = MimeType::getMime("default"); 519 | else 520 | filetype = MimeType::getMime(fileName_.substr(dot_pos)); 521 | 522 | // echo test 523 | if (fileName_ == "hello") 524 | { 525 | outBuffer_ = "HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\nHello World"; 526 | return ANALYSIS_SUCCESS; 527 | } 528 | 529 | struct stat sbuf; 530 | if (stat(fileName_.c_str(), &sbuf) < 0) 531 | { 532 | header.clear(); 533 | handleError(fd_, 404, "Not Found!"); 534 | return ANALYSIS_ERROR; 535 | } 536 | header += "Content-type: " + filetype + "\r\n"; 537 | header += "Content-length: " + to_string(sbuf.st_size) + "\r\n"; 538 | header += "Host: www.gdl.pub\r\n"; 539 | // 头部结束 540 | header += "\r\n"; 541 | outBuffer_ += header; 542 | 543 | int src_fd = open(fileName_.c_str(), O_RDONLY, 0); 544 | char *src_addr = static_cast(mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, src_fd, 0)); 545 | close(src_fd); 546 | 547 | outBuffer_ += src_addr; 548 | munmap(src_addr, sbuf.st_size); 549 | return ANALYSIS_SUCCESS; 550 | } 551 | return ANALYSIS_ERROR; 552 | } 553 | 554 | void HttpData::handleError(int fd, int err_num, string short_msg) 555 | { 556 | short_msg = " " + short_msg; 557 | char send_buff[4096]; 558 | string body_buff, header_buff; 559 | body_buff += "哎~出错了"; 560 | body_buff += ""; 561 | body_buff += to_string(err_num) + short_msg; 562 | body_buff += "
GDL's Web Server\n"; 563 | 564 | header_buff += "HTTP/1.1 " + to_string(err_num) + short_msg + "\r\n"; 565 | header_buff += "Content-type: text/html\r\n"; 566 | header_buff += "Connection: close\r\n"; 567 | header_buff += "Content-length: " + to_string(body_buff.size()) + "\r\n"; 568 | header_buff += "Host: www.gdl.pub\r\n"; 569 | header_buff += "\r\n"; 570 | // 错误处理不考虑writen不完的情况 571 | sprintf(send_buff, "%s", header_buff.c_str()); 572 | writen(fd, send_buff, strlen(send_buff)); 573 | sprintf(send_buff, "%s", body_buff.c_str()); 574 | writen(fd, send_buff, strlen(send_buff)); 575 | } 576 | 577 | void HttpData::handleClose() 578 | { 579 | connectionState_ = H_DISCONNECTED; 580 | shared_ptr guard(shared_from_this()); 581 | loop_->removeFromPoller(channel_); 582 | } 583 | 584 | 585 | void HttpData::newEvent() 586 | { 587 | // 注册IO事件,并把任务事件添加到线程loop_中 588 | channel_->setEvents(DEFAULT_EVENT); 589 | loop_->addToPoller(channel_, DEFAULT_EXPIRED_TIME); 590 | } 591 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeCache.txt: -------------------------------------------------------------------------------- 1 | # This is the CMakeCache file. 2 | # For build in directory: /home/linya/beifen/myserver/tests/build/release 3 | # It was generated by CMake: /usr/bin/cmake 4 | # You can edit this file to change values found and used by cmake. 5 | # If you do not want to change any of the values, simply exit the editor. 6 | # If you do want to change a value, simply edit, save, and exit the editor. 7 | # The syntax for the file is as follows: 8 | # KEY:TYPE=VALUE 9 | # KEY is the name of a variable in the cache. 10 | # TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!. 11 | # VALUE is the current value for the KEY. 12 | 13 | ######################## 14 | # EXTERNAL cache entries 15 | ######################## 16 | 17 | //Path to a library. 18 | BOOSTPO_LIBRARY:FILEPATH=BOOSTPO_LIBRARY-NOTFOUND 19 | 20 | //Path to a library. 21 | BOOSTTEST_LIBRARY:FILEPATH=BOOSTTEST_LIBRARY-NOTFOUND 22 | 23 | //The directory containing a CMake configuration file for Boost. 24 | Boost_DIR:PATH=Boost_DIR-NOTFOUND 25 | 26 | //Path to a file. 27 | Boost_INCLUDE_DIR:PATH=Boost_INCLUDE_DIR-NOTFOUND 28 | 29 | //Path to a file. 30 | CARES_INCLUDE_DIR:PATH=CARES_INCLUDE_DIR-NOTFOUND 31 | 32 | //Path to a library. 33 | CARES_LIBRARY:FILEPATH=CARES_LIBRARY-NOTFOUND 34 | 35 | //Path to a program. 36 | CMAKE_AR:FILEPATH=/usr/bin/ar 37 | 38 | //No help, variable specified on the command line. 39 | CMAKE_BUILD_NO_EXAMPLES:UNINITIALIZED=0 40 | 41 | //Choose the type of build, options are: None(CMAKE_CXX_FLAGS or 42 | // CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. 43 | CMAKE_BUILD_TYPE:STRING=release 44 | 45 | //Enable/Disable color output during build. 46 | CMAKE_COLOR_MAKEFILE:BOOL=ON 47 | 48 | //CXX compiler. 49 | CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ 50 | 51 | //Flags used by the compiler during all build types. 52 | CMAKE_CXX_FLAGS:STRING= 53 | 54 | //Flags used by the compiler during debug builds. 55 | CMAKE_CXX_FLAGS_DEBUG:STRING=-g 56 | 57 | //Flags used by the compiler during release minsize builds. 58 | CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG 59 | 60 | //Flags used by the compiler during release builds (/MD /Ob1 /Oi 61 | // /Ot /Oy /Gs will produce slightly less optimized but smaller 62 | // files). 63 | CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG 64 | 65 | //Flags used by the compiler during Release with Debug Info builds. 66 | CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG 67 | 68 | //C compiler. 69 | CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc 70 | 71 | //Flags used by the compiler during all build types. 72 | CMAKE_C_FLAGS:STRING= 73 | 74 | //Flags used by the compiler during debug builds. 75 | CMAKE_C_FLAGS_DEBUG:STRING=-g 76 | 77 | //Flags used by the compiler during release minsize builds. 78 | CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG 79 | 80 | //Flags used by the compiler during release builds (/MD /Ob1 /Oi 81 | // /Ot /Oy /Gs will produce slightly less optimized but smaller 82 | // files). 83 | CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG 84 | 85 | //Flags used by the compiler during Release with Debug Info builds. 86 | CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG 87 | 88 | //Flags used by the linker. 89 | CMAKE_EXE_LINKER_FLAGS:STRING=' ' 90 | 91 | //Flags used by the linker during debug builds. 92 | CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= 93 | 94 | //Flags used by the linker during release minsize builds. 95 | CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= 96 | 97 | //Flags used by the linker during release builds. 98 | CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= 99 | 100 | //Flags used by the linker during Release with Debug Info builds. 101 | CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= 102 | 103 | //Enable/Disable output of compile commands during generation. 104 | CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF 105 | 106 | //Install path prefix, prepended onto install directories. 107 | CMAKE_INSTALL_PREFIX:PATH=/home/linya/beifen/myserver/tests/build/release-install 108 | 109 | //Path to a program. 110 | CMAKE_LINKER:FILEPATH=/usr/bin/ld 111 | 112 | //Path to a program. 113 | CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make 114 | 115 | //Flags used by the linker during the creation of modules. 116 | CMAKE_MODULE_LINKER_FLAGS:STRING=' ' 117 | 118 | //Flags used by the linker during debug builds. 119 | CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= 120 | 121 | //Flags used by the linker during release minsize builds. 122 | CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= 123 | 124 | //Flags used by the linker during release builds. 125 | CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= 126 | 127 | //Flags used by the linker during Release with Debug Info builds. 128 | CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= 129 | 130 | //Path to a program. 131 | CMAKE_NM:FILEPATH=/usr/bin/nm 132 | 133 | //Path to a program. 134 | CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy 135 | 136 | //Path to a program. 137 | CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump 138 | 139 | //Value Computed by CMake 140 | CMAKE_PROJECT_NAME:STATIC=muduo 141 | 142 | //Path to a program. 143 | CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib 144 | 145 | //Flags used by the linker during the creation of dll's. 146 | CMAKE_SHARED_LINKER_FLAGS:STRING=' ' 147 | 148 | //Flags used by the linker during debug builds. 149 | CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= 150 | 151 | //Flags used by the linker during release minsize builds. 152 | CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= 153 | 154 | //Flags used by the linker during release builds. 155 | CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= 156 | 157 | //Flags used by the linker during Release with Debug Info builds. 158 | CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= 159 | 160 | //If set, runtime paths are not added when installing shared libraries, 161 | // but are added when building. 162 | CMAKE_SKIP_INSTALL_RPATH:BOOL=NO 163 | 164 | //If set, runtime paths are not added when using shared libraries. 165 | CMAKE_SKIP_RPATH:BOOL=NO 166 | 167 | //Flags used by the linker during the creation of static libraries. 168 | CMAKE_STATIC_LINKER_FLAGS:STRING= 169 | 170 | //Flags used by the linker during debug builds. 171 | CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING= 172 | 173 | //Flags used by the linker during release minsize builds. 174 | CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING= 175 | 176 | //Flags used by the linker during release builds. 177 | CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING= 178 | 179 | //Flags used by the linker during Release with Debug Info builds. 180 | CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING= 181 | 182 | //Path to a program. 183 | CMAKE_STRIP:FILEPATH=/usr/bin/strip 184 | 185 | //If true, cmake will use relative paths in makefiles and projects. 186 | CMAKE_USE_RELATIVE_PATHS:BOOL=OFF 187 | 188 | //If this value is on, makefiles will be generated without the 189 | // .SILENT directive, and all commands will be echoed to the console 190 | // during the make. This is useful for debugging only. With Visual 191 | // Studio IDE projects all commands are done without /nologo. 192 | CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE 193 | 194 | //Path to a file. 195 | CURL_INCLUDE_DIR:PATH=CURL_INCLUDE_DIR-NOTFOUND 196 | 197 | //Path to a library. 198 | CURL_LIBRARY:FILEPATH=CURL_LIBRARY-NOTFOUND 199 | 200 | //Path to a file. 201 | GD_INCLUDE_DIR:PATH=GD_INCLUDE_DIR-NOTFOUND 202 | 203 | //Path to a library. 204 | GD_LIBRARY:FILEPATH=GD_LIBRARY-NOTFOUND 205 | 206 | //Path to a file. 207 | HIREDIS_INCLUDE_DIR:PATH=HIREDIS_INCLUDE_DIR-NOTFOUND 208 | 209 | //Path to a library. 210 | HIREDIS_LIBRARY:FILEPATH=HIREDIS_LIBRARY-NOTFOUND 211 | 212 | //Path to a file. 213 | MHD_INCLUDE_DIR:PATH=MHD_INCLUDE_DIR-NOTFOUND 214 | 215 | //Path to a library. 216 | MHD_LIBRARY:FILEPATH=MHD_LIBRARY-NOTFOUND 217 | 218 | //Path to a file. 219 | PROTOBUF_INCLUDE_DIR:PATH=PROTOBUF_INCLUDE_DIR-NOTFOUND 220 | 221 | //Path to a library. 222 | PROTOBUF_LIBRARY:FILEPATH=PROTOBUF_LIBRARY-NOTFOUND 223 | 224 | //Path to a library. 225 | PROTOBUF_LIBRARY_DEBUG:FILEPATH=PROTOBUF_LIBRARY_DEBUG-NOTFOUND 226 | 227 | //Path to a library. 228 | PROTOBUF_LITE_LIBRARY:FILEPATH=PROTOBUF_LITE_LIBRARY-NOTFOUND 229 | 230 | //Path to a library. 231 | PROTOBUF_LITE_LIBRARY_DEBUG:FILEPATH=PROTOBUF_LITE_LIBRARY_DEBUG-NOTFOUND 232 | 233 | //The Google Protocol Buffers Compiler 234 | PROTOBUF_PROTOC_EXECUTABLE:FILEPATH=PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND 235 | 236 | //Path to a library. 237 | PROTOBUF_PROTOC_LIBRARY:FILEPATH=PROTOBUF_PROTOC_LIBRARY-NOTFOUND 238 | 239 | //Path to a library. 240 | PROTOBUF_PROTOC_LIBRARY_DEBUG:FILEPATH=PROTOBUF_PROTOC_LIBRARY_DEBUG-NOTFOUND 241 | 242 | //Path to a file. 243 | TCMALLOC_INCLUDE_DIR:PATH=TCMALLOC_INCLUDE_DIR-NOTFOUND 244 | 245 | //Path to a library. 246 | TCMALLOC_LIBRARY:FILEPATH=TCMALLOC_LIBRARY-NOTFOUND 247 | 248 | //Path to a program. 249 | THRIFT_COMPILER:FILEPATH=THRIFT_COMPILER-NOTFOUND 250 | 251 | //Path to a file. 252 | THRIFT_INCLUDE_DIR:PATH=THRIFT_INCLUDE_DIR-NOTFOUND 253 | 254 | //Path to a library. 255 | THRIFT_LIBRARY:FILEPATH=THRIFT_LIBRARY-NOTFOUND 256 | 257 | //Path to a file. 258 | ZLIB_INCLUDE_DIR:PATH=ZLIB_INCLUDE_DIR-NOTFOUND 259 | 260 | //Path to a library. 261 | ZLIB_LIBRARY:FILEPATH=ZLIB_LIBRARY-NOTFOUND 262 | 263 | //Dependencies for the target 264 | ace_logging_proto_LIB_DEPENDS:STATIC=general;protobuf;general;pthread; 265 | 266 | //Dependencies for the target 267 | echo_proto_LIB_DEPENDS:STATIC=general;protobuf;general;pthread; 268 | 269 | //Value Computed by CMake 270 | muduo_BINARY_DIR:STATIC=/home/linya/beifen/myserver/tests/build/release 271 | 272 | //Value Computed by CMake 273 | muduo_SOURCE_DIR:STATIC=/home/linya/beifen/myserver/tests/muduo 274 | 275 | //Dependencies for the target 276 | muduo_base_LIB_DEPENDS:STATIC=general;pthread;general;rt; 277 | 278 | //Dependencies for the target 279 | muduo_base_cpp11_LIB_DEPENDS:STATIC=general;pthread;general;rt; 280 | 281 | //Dependencies for the target 282 | muduo_cdns_LIB_DEPENDS:STATIC=general;muduo_net;general;cares; 283 | 284 | //Dependencies for the target 285 | muduo_curl_LIB_DEPENDS:STATIC=general;muduo_net;general;curl; 286 | 287 | //Dependencies for the target 288 | muduo_http_LIB_DEPENDS:STATIC=general;muduo_net; 289 | 290 | //Dependencies for the target 291 | muduo_inspect_LIB_DEPENDS:STATIC=general;muduo_http; 292 | 293 | //Dependencies for the target 294 | muduo_net_LIB_DEPENDS:STATIC=general;muduo_base; 295 | 296 | //Dependencies for the target 297 | muduo_net_cpp11_LIB_DEPENDS:STATIC=general;muduo_base_cpp11; 298 | 299 | //Dependencies for the target 300 | muduo_protobuf_codec_LIB_DEPENDS:STATIC=general;muduo_net;general;protobuf;general;z; 301 | 302 | //Dependencies for the target 303 | muduo_protobuf_codec_cpp11_LIB_DEPENDS:STATIC=general;muduo_net_cpp11;general;protobuf;general;z; 304 | 305 | //Dependencies for the target 306 | muduo_protorpc_LIB_DEPENDS:STATIC=general;muduo_protorpc_wire;general;muduo_protobuf_codec;general;muduo_net;general;protobuf;general;z; 307 | 308 | //Dependencies for target 309 | muduo_protorpc_wire_LIB_DEPENDS:STATIC= 310 | 311 | //Dependencies for target 312 | muduo_protorpc_wire_cpp11_LIB_DEPENDS:STATIC= 313 | 314 | //Dependencies for the target 315 | muduo_pubsub_LIB_DEPENDS:STATIC=general;muduo_net; 316 | 317 | //Dependencies for the target 318 | muduo_thrift_LIB_DEPENDS:STATIC=general;muduo_net;general;thrift; 319 | 320 | //Dependencies for the target 321 | protobuf_codec_LIB_DEPENDS:STATIC=general;protobuf;general;muduo_net;general;z; 322 | 323 | //Dependencies for the target 324 | query_proto_LIB_DEPENDS:STATIC=general;protobuf;general;pthread; 325 | 326 | //Dependencies for the target 327 | resolver_proto_LIB_DEPENDS:STATIC=general;protobuf;general;pthread; 328 | 329 | //Dependencies for the target 330 | sudoku_proto_LIB_DEPENDS:STATIC=general;protobuf;general;pthread; 331 | 332 | 333 | ######################## 334 | # INTERNAL cache entries 335 | ######################## 336 | 337 | //ADVANCED property for variable: Boost_DIR 338 | Boost_DIR-ADVANCED:INTERNAL=1 339 | //ADVANCED property for variable: Boost_INCLUDE_DIR 340 | Boost_INCLUDE_DIR-ADVANCED:INTERNAL=1 341 | //ADVANCED property for variable: CMAKE_AR 342 | CMAKE_AR-ADVANCED:INTERNAL=1 343 | //ADVANCED property for variable: CMAKE_BUILD_TOOL 344 | CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1 345 | //What is the target build tool cmake is generating for. 346 | CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make 347 | //This is the directory where this CMakeCache.txt was created 348 | CMAKE_CACHEFILE_DIR:INTERNAL=/home/linya/beifen/myserver/tests/build/release 349 | //Major version of cmake used to create the current loaded cache 350 | CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2 351 | //Minor version of cmake used to create the current loaded cache 352 | CMAKE_CACHE_MINOR_VERSION:INTERNAL=8 353 | //Patch version of cmake used to create the current loaded cache 354 | CMAKE_CACHE_PATCH_VERSION:INTERNAL=12 355 | //ADVANCED property for variable: CMAKE_COLOR_MAKEFILE 356 | CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 357 | //Path to CMake executable. 358 | CMAKE_COMMAND:INTERNAL=/usr/bin/cmake 359 | //Path to cpack program executable. 360 | CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack 361 | //Path to ctest program executable. 362 | CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest 363 | //ADVANCED property for variable: CMAKE_CXX_COMPILER 364 | CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1 365 | //ADVANCED property for variable: CMAKE_CXX_FLAGS 366 | CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1 367 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG 368 | CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1 369 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL 370 | CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 371 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE 372 | CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1 373 | //ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO 374 | CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 375 | //ADVANCED property for variable: CMAKE_C_COMPILER 376 | CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 377 | //ADVANCED property for variable: CMAKE_C_FLAGS 378 | CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 379 | //ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG 380 | CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 381 | //ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL 382 | CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 383 | //ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE 384 | CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 385 | //ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO 386 | CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 387 | //Executable file format 388 | CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF 389 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS 390 | CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 391 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG 392 | CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 393 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL 394 | CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 395 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE 396 | CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 397 | //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO 398 | CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 399 | //ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS 400 | CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1 401 | //Name of generator. 402 | CMAKE_GENERATOR:INTERNAL=Unix Makefiles 403 | //Name of generator toolset. 404 | CMAKE_GENERATOR_TOOLSET:INTERNAL= 405 | //Have symbol pthread_create 406 | CMAKE_HAVE_LIBC_CREATE:INTERNAL= 407 | //Have library pthreads 408 | CMAKE_HAVE_PTHREADS_CREATE:INTERNAL= 409 | //Have library pthread 410 | CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1 411 | //Have include pthread.h 412 | CMAKE_HAVE_PTHREAD_H:INTERNAL=1 413 | //Start directory with the top level CMakeLists.txt file for this 414 | // project 415 | CMAKE_HOME_DIRECTORY:INTERNAL=/home/linya/beifen/myserver/tests/muduo 416 | //Install .so files without execute permission. 417 | CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1 418 | //ADVANCED property for variable: CMAKE_LINKER 419 | CMAKE_LINKER-ADVANCED:INTERNAL=1 420 | //ADVANCED property for variable: CMAKE_MAKE_PROGRAM 421 | CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 422 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS 423 | CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 424 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG 425 | CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 426 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL 427 | CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 428 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE 429 | CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 430 | //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO 431 | CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 432 | //ADVANCED property for variable: CMAKE_NM 433 | CMAKE_NM-ADVANCED:INTERNAL=1 434 | //number of local generators 435 | CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=46 436 | //ADVANCED property for variable: CMAKE_OBJCOPY 437 | CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 438 | //ADVANCED property for variable: CMAKE_OBJDUMP 439 | CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 440 | //ADVANCED property for variable: CMAKE_RANLIB 441 | CMAKE_RANLIB-ADVANCED:INTERNAL=1 442 | //Path to CMake installation. 443 | CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.8 444 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS 445 | CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 446 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG 447 | CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 448 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL 449 | CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 450 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE 451 | CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 452 | //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO 453 | CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 454 | //ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH 455 | CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1 456 | //ADVANCED property for variable: CMAKE_SKIP_RPATH 457 | CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 458 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS 459 | CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1 460 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG 461 | CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 462 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL 463 | CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 464 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE 465 | CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 466 | //ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO 467 | CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 468 | //ADVANCED property for variable: CMAKE_STRIP 469 | CMAKE_STRIP-ADVANCED:INTERNAL=1 470 | //uname command 471 | CMAKE_UNAME:INTERNAL=/bin/uname 472 | //ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS 473 | CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1 474 | //ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE 475 | CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 476 | //ADVANCED property for variable: CURL_INCLUDE_DIR 477 | CURL_INCLUDE_DIR-ADVANCED:INTERNAL=1 478 | //ADVANCED property for variable: CURL_LIBRARY 479 | CURL_LIBRARY-ADVANCED:INTERNAL=1 480 | //Details about finding Threads 481 | FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()] 482 | //Have function accept4 483 | HAVE_ACCEPT4:INTERNAL=1 484 | //ADVANCED property for variable: PROTOBUF_INCLUDE_DIR 485 | PROTOBUF_INCLUDE_DIR-ADVANCED:INTERNAL=1 486 | //ADVANCED property for variable: PROTOBUF_LIBRARY 487 | PROTOBUF_LIBRARY-ADVANCED:INTERNAL=1 488 | //ADVANCED property for variable: PROTOBUF_LIBRARY_DEBUG 489 | PROTOBUF_LIBRARY_DEBUG-ADVANCED:INTERNAL=1 490 | //ADVANCED property for variable: PROTOBUF_LITE_LIBRARY 491 | PROTOBUF_LITE_LIBRARY-ADVANCED:INTERNAL=1 492 | //ADVANCED property for variable: PROTOBUF_LITE_LIBRARY_DEBUG 493 | PROTOBUF_LITE_LIBRARY_DEBUG-ADVANCED:INTERNAL=1 494 | //ADVANCED property for variable: PROTOBUF_PROTOC_EXECUTABLE 495 | PROTOBUF_PROTOC_EXECUTABLE-ADVANCED:INTERNAL=1 496 | //ADVANCED property for variable: PROTOBUF_PROTOC_LIBRARY 497 | PROTOBUF_PROTOC_LIBRARY-ADVANCED:INTERNAL=1 498 | //ADVANCED property for variable: PROTOBUF_PROTOC_LIBRARY_DEBUG 499 | PROTOBUF_PROTOC_LIBRARY_DEBUG-ADVANCED:INTERNAL=1 500 | //ADVANCED property for variable: ZLIB_INCLUDE_DIR 501 | ZLIB_INCLUDE_DIR-ADVANCED:INTERNAL=1 502 | //ADVANCED property for variable: ZLIB_LIBRARY 503 | ZLIB_LIBRARY-ADVANCED:INTERNAL=1 504 | //Components requested for this build tree. 505 | _Boost_COMPONENTS_SEARCHED:INTERNAL= 506 | //Last used Boost_INCLUDE_DIR value. 507 | _Boost_INCLUDE_DIR_LAST:INTERNAL=Boost_INCLUDE_DIR-NOTFOUND 508 | //Last used Boost_USE_MULTITHREADED value. 509 | _Boost_USE_MULTITHREADED_LAST:INTERNAL=TRUE 510 | 511 | -------------------------------------------------------------------------------- /WebServer/tests/build/release/CMakeFiles/CMakeOutput.log: -------------------------------------------------------------------------------- 1 | The system is: Linux - 4.4.0-112-generic - x86_64 2 | Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. 3 | Compiler: /usr/bin/cc 4 | Build flags: 5 | Id flags: 6 | 7 | The output was: 8 | 0 9 | 10 | 11 | Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" 12 | 13 | The C compiler identification is GNU, found in "/home/linya/beifen/myserver/tests/build/release/CMakeFiles/2.8.12.2/CompilerIdC/a.out" 14 | 15 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. 16 | Compiler: /usr/bin/c++ 17 | Build flags: 18 | Id flags: 19 | 20 | The output was: 21 | 0 22 | 23 | 24 | Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" 25 | 26 | The CXX compiler identification is GNU, found in "/home/linya/beifen/myserver/tests/build/release/CMakeFiles/2.8.12.2/CompilerIdCXX/a.out" 27 | 28 | Determining if the C compiler works passed with the following output: 29 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 30 | 31 | Run Build Command:/usr/bin/make "cmTryCompileExec1048658521/fast" 32 | /usr/bin/make -f CMakeFiles/cmTryCompileExec1048658521.dir/build.make CMakeFiles/cmTryCompileExec1048658521.dir/build 33 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 34 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 35 | Building C object CMakeFiles/cmTryCompileExec1048658521.dir/testCCompiler.c.o 36 | /usr/bin/cc -o CMakeFiles/cmTryCompileExec1048658521.dir/testCCompiler.c.o -c /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/testCCompiler.c 37 | Linking C executable cmTryCompileExec1048658521 38 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1048658521.dir/link.txt --verbose=1 39 | /usr/bin/cc CMakeFiles/cmTryCompileExec1048658521.dir/testCCompiler.c.o -o cmTryCompileExec1048658521 -rdynamic 40 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 41 | 42 | 43 | Detecting C compiler ABI info compiled with the following output: 44 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 45 | 46 | Run Build Command:/usr/bin/make "cmTryCompileExec3864032145/fast" 47 | /usr/bin/make -f CMakeFiles/cmTryCompileExec3864032145.dir/build.make CMakeFiles/cmTryCompileExec3864032145.dir/build 48 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 49 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 50 | Building C object CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o 51 | /usr/bin/cc -o CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-2.8/Modules/CMakeCCompilerABI.c 52 | Linking C executable cmTryCompileExec3864032145 53 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3864032145.dir/link.txt --verbose=1 54 | /usr/bin/cc -v CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -o cmTryCompileExec3864032145 -rdynamic 55 | Using built-in specs. 56 | COLLECT_GCC=/usr/bin/cc 57 | COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 58 | Target: x86_64-linux-gnu 59 | Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 60 | Thread model: posix 61 | gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 62 | COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/ 63 | LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/ 64 | COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec3864032145' '-rdynamic' '-mtune=generic' '-march=x86-64' 65 | /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTryCompileExec3864032145 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o 66 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 67 | 68 | 69 | Parsed C implicit link information from above output: 70 | link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] 71 | ignore line: [Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp] 72 | ignore line: [] 73 | ignore line: [Run Build Command:/usr/bin/make "cmTryCompileExec3864032145/fast"] 74 | ignore line: [/usr/bin/make -f CMakeFiles/cmTryCompileExec3864032145.dir/build.make CMakeFiles/cmTryCompileExec3864032145.dir/build] 75 | ignore line: [make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp'] 76 | ignore line: [/usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1] 77 | ignore line: [Building C object CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o] 78 | ignore line: [/usr/bin/cc -o CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-2.8/Modules/CMakeCCompilerABI.c] 79 | ignore line: [Linking C executable cmTryCompileExec3864032145] 80 | ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3864032145.dir/link.txt --verbose=1] 81 | ignore line: [/usr/bin/cc -v CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -o cmTryCompileExec3864032145 -rdynamic ] 82 | ignore line: [Using built-in specs.] 83 | ignore line: [COLLECT_GCC=/usr/bin/cc] 84 | ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper] 85 | ignore line: [Target: x86_64-linux-gnu] 86 | ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu] 87 | ignore line: [Thread model: posix] 88 | ignore line: [gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ] 89 | ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/] 90 | ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/] 91 | ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec3864032145' '-rdynamic' '-mtune=generic' '-march=x86-64'] 92 | link line: [ /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTryCompileExec3864032145 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o] 93 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2] ==> ignore 94 | arg [--sysroot=/] ==> ignore 95 | arg [--build-id] ==> ignore 96 | arg [--eh-frame-hdr] ==> ignore 97 | arg [-m] ==> ignore 98 | arg [elf_x86_64] ==> ignore 99 | arg [--hash-style=gnu] ==> ignore 100 | arg [--as-needed] ==> ignore 101 | arg [-export-dynamic] ==> ignore 102 | arg [-dynamic-linker] ==> ignore 103 | arg [/lib64/ld-linux-x86-64.so.2] ==> ignore 104 | arg [-zrelro] ==> ignore 105 | arg [-o] ==> ignore 106 | arg [cmTryCompileExec3864032145] ==> ignore 107 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o] ==> ignore 108 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o] ==> ignore 109 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o] ==> ignore 110 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8] 111 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] 112 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] 113 | arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu] 114 | arg [-L/lib/../lib] ==> dir [/lib/../lib] 115 | arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu] 116 | arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib] 117 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] 118 | arg [CMakeFiles/cmTryCompileExec3864032145.dir/CMakeCCompilerABI.c.o] ==> ignore 119 | arg [-lgcc] ==> lib [gcc] 120 | arg [--as-needed] ==> ignore 121 | arg [-lgcc_s] ==> lib [gcc_s] 122 | arg [--no-as-needed] ==> ignore 123 | arg [-lc] ==> lib [c] 124 | arg [-lgcc] ==> lib [gcc] 125 | arg [--as-needed] ==> ignore 126 | arg [-lgcc_s] ==> lib [gcc_s] 127 | arg [--no-as-needed] ==> ignore 128 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o] ==> ignore 129 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o] ==> ignore 130 | remove lib [gcc] 131 | remove lib [gcc_s] 132 | remove lib [gcc] 133 | remove lib [gcc_s] 134 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8] ==> [/usr/lib/gcc/x86_64-linux-gnu/4.8] 135 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] 136 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] ==> [/usr/lib] 137 | collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu] 138 | collapse library dir [/lib/../lib] ==> [/lib] 139 | collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] 140 | collapse library dir [/usr/lib/../lib] ==> [/usr/lib] 141 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] ==> [/usr/lib] 142 | implicit libs: [c] 143 | implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/4.8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib] 144 | implicit fwks: [] 145 | 146 | 147 | Determining if the CXX compiler works passed with the following output: 148 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 149 | 150 | Run Build Command:/usr/bin/make "cmTryCompileExec3312599426/fast" 151 | /usr/bin/make -f CMakeFiles/cmTryCompileExec3312599426.dir/build.make CMakeFiles/cmTryCompileExec3312599426.dir/build 152 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 153 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 154 | Building CXX object CMakeFiles/cmTryCompileExec3312599426.dir/testCXXCompiler.cxx.o 155 | /usr/bin/c++ -o CMakeFiles/cmTryCompileExec3312599426.dir/testCXXCompiler.cxx.o -c /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx 156 | Linking CXX executable cmTryCompileExec3312599426 157 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3312599426.dir/link.txt --verbose=1 158 | /usr/bin/c++ CMakeFiles/cmTryCompileExec3312599426.dir/testCXXCompiler.cxx.o -o cmTryCompileExec3312599426 -rdynamic 159 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 160 | 161 | 162 | Detecting CXX compiler ABI info compiled with the following output: 163 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 164 | 165 | Run Build Command:/usr/bin/make "cmTryCompileExec1847169327/fast" 166 | /usr/bin/make -f CMakeFiles/cmTryCompileExec1847169327.dir/build.make CMakeFiles/cmTryCompileExec1847169327.dir/build 167 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 168 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 169 | Building CXX object CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o 170 | /usr/bin/c++ -o CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-2.8/Modules/CMakeCXXCompilerABI.cpp 171 | Linking CXX executable cmTryCompileExec1847169327 172 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1847169327.dir/link.txt --verbose=1 173 | /usr/bin/c++ -v CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -o cmTryCompileExec1847169327 -rdynamic 174 | Using built-in specs. 175 | COLLECT_GCC=/usr/bin/c++ 176 | COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 177 | Target: x86_64-linux-gnu 178 | Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 179 | Thread model: posix 180 | gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 181 | COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/ 182 | LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/ 183 | COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec1847169327' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64' 184 | /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTryCompileExec1847169327 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o 185 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 186 | 187 | 188 | Parsed CXX implicit link information from above output: 189 | link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] 190 | ignore line: [Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp] 191 | ignore line: [] 192 | ignore line: [Run Build Command:/usr/bin/make "cmTryCompileExec1847169327/fast"] 193 | ignore line: [/usr/bin/make -f CMakeFiles/cmTryCompileExec1847169327.dir/build.make CMakeFiles/cmTryCompileExec1847169327.dir/build] 194 | ignore line: [make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp'] 195 | ignore line: [/usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1] 196 | ignore line: [Building CXX object CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o] 197 | ignore line: [/usr/bin/c++ -o CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-2.8/Modules/CMakeCXXCompilerABI.cpp] 198 | ignore line: [Linking CXX executable cmTryCompileExec1847169327] 199 | ignore line: [/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1847169327.dir/link.txt --verbose=1] 200 | ignore line: [/usr/bin/c++ -v CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -o cmTryCompileExec1847169327 -rdynamic ] 201 | ignore line: [Using built-in specs.] 202 | ignore line: [COLLECT_GCC=/usr/bin/c++] 203 | ignore line: [COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper] 204 | ignore line: [Target: x86_64-linux-gnu] 205 | ignore line: [Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu] 206 | ignore line: [Thread model: posix] 207 | ignore line: [gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ] 208 | ignore line: [COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/] 209 | ignore line: [LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/] 210 | ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTryCompileExec1847169327' '-rdynamic' '-shared-libgcc' '-mtune=generic' '-march=x86-64'] 211 | link line: [ /usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o cmTryCompileExec1847169327 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o] 212 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2] ==> ignore 213 | arg [--sysroot=/] ==> ignore 214 | arg [--build-id] ==> ignore 215 | arg [--eh-frame-hdr] ==> ignore 216 | arg [-m] ==> ignore 217 | arg [elf_x86_64] ==> ignore 218 | arg [--hash-style=gnu] ==> ignore 219 | arg [--as-needed] ==> ignore 220 | arg [-export-dynamic] ==> ignore 221 | arg [-dynamic-linker] ==> ignore 222 | arg [/lib64/ld-linux-x86-64.so.2] ==> ignore 223 | arg [-zrelro] ==> ignore 224 | arg [-o] ==> ignore 225 | arg [cmTryCompileExec1847169327] ==> ignore 226 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o] ==> ignore 227 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o] ==> ignore 228 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o] ==> ignore 229 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8] 230 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] 231 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] 232 | arg [-L/lib/x86_64-linux-gnu] ==> dir [/lib/x86_64-linux-gnu] 233 | arg [-L/lib/../lib] ==> dir [/lib/../lib] 234 | arg [-L/usr/lib/x86_64-linux-gnu] ==> dir [/usr/lib/x86_64-linux-gnu] 235 | arg [-L/usr/lib/../lib] ==> dir [/usr/lib/../lib] 236 | arg [-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] ==> dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] 237 | arg [CMakeFiles/cmTryCompileExec1847169327.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore 238 | arg [-lstdc++] ==> lib [stdc++] 239 | arg [-lm] ==> lib [m] 240 | arg [-lgcc_s] ==> lib [gcc_s] 241 | arg [-lgcc] ==> lib [gcc] 242 | arg [-lc] ==> lib [c] 243 | arg [-lgcc_s] ==> lib [gcc_s] 244 | arg [-lgcc] ==> lib [gcc] 245 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o] ==> ignore 246 | arg [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o] ==> ignore 247 | remove lib [gcc_s] 248 | remove lib [gcc] 249 | remove lib [gcc_s] 250 | remove lib [gcc] 251 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8] ==> [/usr/lib/gcc/x86_64-linux-gnu/4.8] 252 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] 253 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib] ==> [/usr/lib] 254 | collapse library dir [/lib/x86_64-linux-gnu] ==> [/lib/x86_64-linux-gnu] 255 | collapse library dir [/lib/../lib] ==> [/lib] 256 | collapse library dir [/usr/lib/x86_64-linux-gnu] ==> [/usr/lib/x86_64-linux-gnu] 257 | collapse library dir [/usr/lib/../lib] ==> [/usr/lib] 258 | collapse library dir [/usr/lib/gcc/x86_64-linux-gnu/4.8/../../..] ==> [/usr/lib] 259 | implicit libs: [stdc++;m;c] 260 | implicit dirs: [/usr/lib/gcc/x86_64-linux-gnu/4.8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib] 261 | implicit fwks: [] 262 | 263 | 264 | Determining if files pthread.h exist passed with the following output: 265 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 266 | 267 | Run Build Command:/usr/bin/make "cmTryCompileExec928567820/fast" 268 | /usr/bin/make -f CMakeFiles/cmTryCompileExec928567820.dir/build.make CMakeFiles/cmTryCompileExec928567820.dir/build 269 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 270 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 271 | Building C object CMakeFiles/cmTryCompileExec928567820.dir/CheckIncludeFiles.c.o 272 | /usr/bin/cc -o CMakeFiles/cmTryCompileExec928567820.dir/CheckIncludeFiles.c.o -c /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CheckIncludeFiles.c 273 | Linking C executable cmTryCompileExec928567820 274 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec928567820.dir/link.txt --verbose=1 275 | /usr/bin/cc CMakeFiles/cmTryCompileExec928567820.dir/CheckIncludeFiles.c.o -o cmTryCompileExec928567820 -rdynamic 276 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 277 | 278 | 279 | Determining if the function pthread_create exists in the pthread passed with the following output: 280 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 281 | 282 | Run Build Command:/usr/bin/make "cmTryCompileExec2113051811/fast" 283 | /usr/bin/make -f CMakeFiles/cmTryCompileExec2113051811.dir/build.make CMakeFiles/cmTryCompileExec2113051811.dir/build 284 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 285 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 286 | Building C object CMakeFiles/cmTryCompileExec2113051811.dir/CheckFunctionExists.c.o 287 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec2113051811.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c 288 | Linking C executable cmTryCompileExec2113051811 289 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec2113051811.dir/link.txt --verbose=1 290 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec2113051811.dir/CheckFunctionExists.c.o -o cmTryCompileExec2113051811 -rdynamic -lpthread 291 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 292 | 293 | 294 | Determining if the function accept4 exists passed with the following output: 295 | Change Dir: /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp 296 | 297 | Run Build Command:/usr/bin/make "cmTryCompileExec3459516700/fast" 298 | /usr/bin/make -f CMakeFiles/cmTryCompileExec3459516700.dir/build.make CMakeFiles/cmTryCompileExec3459516700.dir/build 299 | make[1]: Entering directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 300 | /usr/bin/cmake -E cmake_progress_report /home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp/CMakeFiles 1 301 | Building C object CMakeFiles/cmTryCompileExec3459516700.dir/CheckFunctionExists.c.o 302 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=accept4 -o CMakeFiles/cmTryCompileExec3459516700.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c 303 | Linking C executable cmTryCompileExec3459516700 304 | /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3459516700.dir/link.txt --verbose=1 305 | /usr/bin/cc -DCHECK_FUNCTION_EXISTS=accept4 CMakeFiles/cmTryCompileExec3459516700.dir/CheckFunctionExists.c.o -o cmTryCompileExec3459516700 -rdynamic 306 | make[1]: Leaving directory `/home/linya/beifen/myserver/tests/build/release/CMakeFiles/CMakeTmp' 307 | 308 | 309 | --------------------------------------------------------------------------------