Skip to content

Commit

Permalink
Merge branch 'master' into i110/mruby-redis
Browse files Browse the repository at this point in the history
  • Loading branch information
i110 committed Oct 20, 2017
2 parents 80b8950 + 378a5e9 commit 66a627d
Show file tree
Hide file tree
Showing 65 changed files with 5,825 additions and 771 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ xcuserdata
!include/h2o
misc/test-ca/demoCA/newcerts/*.pem
tmp/
/doc/workdir/
5 changes: 5 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set nofen
27 changes: 21 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(ZLIB REQUIRED)

INCLUDE(CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <stdint.h>
int main(void) {
uint64_t a;
__sync_add_and_fetch(&a, 1);
return 0;
}" ARCH_SUPPORTS_64BIT_ATOMICS)

SET(WITH_BUNDLED_SSL_DEFAULT "ON")
IF ((NOT UNIX) OR CYGWIN)
SET(WITH_BUNDLED_SSL_DEFAULT "OFF")
Expand Down Expand Up @@ -462,7 +471,7 @@ IF (WITH_MRUBY)
ELSE ()
SET(MRUBY_TOOLCHAIN "gcc")
ENDIF ()
ADD_CUSTOM_TARGET(mruby MRUBY_TOOLCHAIN=${MRUBY_TOOLCHAIN} MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/misc/mruby_config.rb MRUBY_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/mruby ruby minirake
ADD_CUSTOM_TARGET(mruby MRUBY_TOOLCHAIN=${MRUBY_TOOLCHAIN} MRUBY_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/misc/mruby_config.rb MRUBY_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/mruby MRUBY_ADDITIONAL_CONFIG=${MRUBY_ADDITIONAL_CONFIG} ruby minirake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mruby)
LIST(APPEND STANDALONE_SOURCE_FILES
lib/handler/mruby.c
Expand Down Expand Up @@ -516,7 +525,9 @@ ENDIF ()
INSTALL(PROGRAMS share/h2o/annotate-backtrace-symbols share/h2o/fastcgi-cgi share/h2o/fetch-ocsp-response share/h2o/kill-on-close share/h2o/setuidgid share/h2o/start_server DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/h2o)
INSTALL(FILES share/h2o/ca-bundle.crt DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/h2o)
INSTALL(FILES share/h2o/status/index.html DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/h2o/status)
INSTALL(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/h2o PATTERN "Makefile" EXCLUDE PATTERN "README.md" EXCLUDE)
INSTALL(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/h2o PATTERN "Makefile" EXCLUDE PATTERN "h2o.8" EXCLUDE PATTERN "README.md" EXCLUDE)
INSTALL(FILES doc/h2o.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
INSTALL(FILES doc/h2o.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5/)
INSTALL(DIRECTORY examples/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/h2o/examples)
IF (WITH_MRUBY)
INSTALL(DIRECTORY share/h2o/mruby DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/h2o)
Expand Down Expand Up @@ -567,7 +578,7 @@ ELSE ()
ENDIF ()
ENDIF ()

ADD_CUSTOM_TARGET(check env H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -v t/*.t
ADD_CUSTOM_TARGET(check env H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -I. -v t/*.t
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS h2o t-00unit-evloop.t)
IF (LIBUV_FOUND)
Expand All @@ -591,7 +602,7 @@ IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/misc/h2get/CMakeLists.txt)
ADD_DEPENDENCIES(check h2get)
ENDIF ()

ADD_CUSTOM_TARGET(check-valgrind env H2O_VALGRIND=./misc/h2o_valgrind/ H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -v t/*.t
ADD_CUSTOM_TARGET(check-valgrind env H2O_VALGRIND=./misc/h2o_valgrind/ H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -I. -v t/*.t
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS h2o t-00unit-evloop.t)
IF (LIBUV_FOUND)
Expand All @@ -601,10 +612,10 @@ IF (LIBUV_FOUND)
ENDIF ()
ENDIF ()

ADD_CUSTOM_TARGET(check-as-root env H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -v t/90root-*.t
ADD_CUSTOM_TARGET(check-as-root env H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -I. -v t/90root-*.t
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

ADD_CUSTOM_TARGET(check-as-root-valgrind env H2O_VALGRIND=./misc/h2o_valgrind/ H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -v t/90root-*.t
ADD_CUSTOM_TARGET(check-as-root-valgrind env H2O_VALGRIND=./misc/h2o_valgrind/ H2O_ROOT=. BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} prove -I. -v t/90root-*.t
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})


Expand Down Expand Up @@ -641,6 +652,10 @@ IF (BUILD_FUZZER)

ENDIF (BUILD_FUZZER)

IF (NOT ARCH_SUPPORTS_64BIT_ATOMICS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DH2O_NO_64BIT_ATOMICS")
ENDIF (NOT ARCH_SUPPORTS_64BIT_ATOMICS)

# environment-specific tweaks
IF (APPLE)
SET_SOURCE_FILES_PROPERTIES(lib/socket.c lib/websocket.c src/main.c examples/simple.c examples/websocket.c PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
Expand Down
30 changes: 29 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
Revision history for H2O.

2.3.0-beta1 TBD
- [core] disable buffering of stdout, stderr #1347 (Yannick Koechlin)
- [access-log] log connections that closed prior to sending a response #1235 (Kazuho Oku)
- [expires] fix incorrect header emitted when units: month or year were used #1406 (Frederik Deweerdt)
- [fastcgi] never return 304 if the file is a dynamic handler #1385 (Kazuho Oku)
- [fastcgi] accept `default` as a keyword of the extensions attribute #1414 (Ichito Nagata)
- [http2] support `critical` attribute in preload link header #1436 (Kazuho Oku, Frederik Deweerdt)
- [http2] do not compress cookies less than 20 bytes long #1389 (Julien Benoist)
- [mime] add .mjs as javascript file type #1398 (Jxck)
- [mime] flush all existing mapping when file.mime.settypes is used #1416 (Ichito Nagata)
- [mruby] allow running asynchronous operations unbounded to the Rack request being processed #1173 (Ichito Nagata)
- [mruby] drop the link rel=preload header with a x-http2-push-only attribute #1310 (Frederik Deweerdt)
- [mruby] update mruby and modules #1320 #1338 #1413
- [mruby] implement sleep #1348 (Ichito Nagata)
- [mruby] implement Digest::SHA256 #1387 (Kazuho Oku)
- [mruby] expose `SERVER_PROTOCOL` #1353 (Frederik Deweerdt)
- [mruby] properly handle content-less response #1430 (Ichito Nagata)
- [mruby] add option to specify mrbgem dependencies out of tree #1446 (Satoshi Tagomori)
- [proxy] load balancing support (round-robin) #1277 (Justin Zhu)
- [proxy] cap the amount of request body being buffered #1357 (Frederik Deweerdt)
- [proxy] cap the amount of response body being buffered #1358 (Frederik Deweerdt)
- [proxy] do not drop the Date request header #1408 (Ichito Nagata)
- [proxy] introduce separate timeouts for connection establishment and first-byte #1402 (Frederik Deweerdt)
- [ssl] support redis as a data store for session cache / ticket #1087 (Ichito Nagata)
- [ssl] fix deadlock during lazy initialzation #1425 (Apollon Oikonomopoulos)
- [ssl] fix epoll-related crashes on OSCP updates #1427 (Apollon Oikonomopoulos)
- [ssl] avoid spurious session ticket renewals #1444 (Apollon Oikonomopoulos)
- [websocket] fix bug that might drop the first websocket frame #1276 (wuhanck)
- [libh2o] clear OpenSSL's error queue before using it #1448 (Apollon Oikonomopoulos)
- [doc] add documentation of `duration-stats` #1306 (Frederik Deweerdt)
- [misc] include process id in crash backtrace #1254 (Kazuho Oku)
- [misc] fix build issues on OpenIndiana #1300 (David Carlier)
- [misc] build on platforms without 64-bit atomics #1433 (Apollon Oikonomopoulos)

2.2.2 2017-04-23 03:24:00+0000
- [ssl] fix OCSP stapling error when LibreSSL is used #1275 (Ian Moone)


2.2.1 2017-04-22 22:43:00+0000
- [mruby] correct the line number reported on an exception #1239 #1251 (Ichito Nagata)
- [mruby] retain the order of request headers sharing a single name #1271 (Kazuho Oku)
Expand Down
18 changes: 13 additions & 5 deletions deps/mruby-io/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
mruby-io
========
[![Build Status](https://travis-ci.org/iij/mruby-io.svg?branch=master)](https://travis-ci.org/iij/mruby-io)

IO, File module for mruby

`IO` and `File` classes for mruby

## Installation
Add the line below to your `build_config.rb`:

```
conf.gem :github => 'iij/mruby-io'
```

## Implemented methods

Expand All @@ -16,7 +24,7 @@ IO, File module for mruby
| IO.copy_stream | | |
| IO.new, IO.for_fd, IO.open | o | |
| IO.foreach | | |
| IO.pipe | | |
| IO.pipe | o | |
| IO.popen | o | |
| IO.read | o | |
| IO.readlines | | |
Expand Down Expand Up @@ -56,7 +64,7 @@ IO, File module for mruby
| IO#gets | o | |
| IO#internal_encoding | | |
| IO#ioctl | | |
| IO#isatty, IO#tty? | | |
| IO#isatty, IO#tty? | o | |
| IO#lineno | | |
| IO#lineno= | | |
| IO#lines | | obsolete |
Expand Down Expand Up @@ -100,7 +108,7 @@ IO, File module for mruby
| File.basename | o | |
| File.blockdev? | | FileTest |
| File.chardev? | | FileTest |
| File.chmod | | |
| File.chmod | o | |
| File.chown | | |
| File.ctime | | |
| File.delete, File.unlink | o | |
Expand Down Expand Up @@ -128,7 +136,7 @@ IO, File module for mruby
| File.pipe? | o | FileTest |
| File.readable? | | FileTest |
| File.readable_real? | | FileTest |
| File.readlink | | |
| File.readlink | o | |
| File.realdirpath | | |
| File.realpath | o | |
| File.rename | o | |
Expand Down
3 changes: 2 additions & 1 deletion deps/mruby-io/include/mruby/ext/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ struct mrb_io {
int fd; /* file descriptor, or -1 */
int fd2; /* file descriptor to write if it's different from fd, or -1 */
int pid; /* child's pid (for pipes) */
unsigned int writable:1,
unsigned int readable:1,
writable:1,
sync:1;
};

Expand Down
97 changes: 66 additions & 31 deletions deps/mruby-io/mrblib/file.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class File < IO
include Enumerable

class FileError < Exception; end
class NoFileError < FileError; end
class UnableToStat < FileError; end
Expand All @@ -19,34 +17,47 @@ def initialize(fd_or_path, mode = "r", perm = 0666)
end

def self.join(*names)
if names.size == 0
""
elsif names.size == 1
names[0]
else
if names[0][-1] == File::SEPARATOR
s = names[0][0..-2]
else
s = names[0].dup
end
(1..names.size-2).each { |i|
t = names[i]
if t[0] == File::SEPARATOR and t[-1] == File::SEPARATOR
t = t[1..-2]
elsif t[0] == File::SEPARATOR
t = t[1..-1]
elsif t[-1] == File::SEPARATOR
t = t[0..-2]
return "" if names.empty?

names.map! do |name|
case name
when String
name
when Array
if names == name
raise ArgumentError, "recursive array"
end
s += File::SEPARATOR + t if t != ""
}
if names[-1][0] == File::SEPARATOR
s += File::SEPARATOR + names[-1][1..-1]
join(*name)
else
s += File::SEPARATOR + names[-1]
raise TypeError, "no implicit conversion of #{name.class} into String"
end
end

return names[0] if names.size == 1

if names[0][-1] == File::SEPARATOR
s = names[0][0..-2]
else
s = names[0].dup
end

(1..names.size-2).each { |i|
t = names[i]
if t[0] == File::SEPARATOR and t[-1] == File::SEPARATOR
t = t[1..-2]
elsif t[0] == File::SEPARATOR
t = t[1..-1]
elsif t[-1] == File::SEPARATOR
t = t[0..-2]
end
s
s += File::SEPARATOR + t if t != ""
}
if names[-1][0] == File::SEPARATOR
s += File::SEPARATOR + names[-1][1..-1]
else
s += File::SEPARATOR + names[-1]
end
s
end

def self.expand_path(path, default_dir = '.')
Expand Down Expand Up @@ -89,14 +100,21 @@ def concat_path(path, base_path)
end

expanded_path = concat_path(path, default_dir)
drive_prefix = ""
if File::ALT_SEPARATOR && expanded_path.size > 2 &&
("A".."Z").include?(expanded_path[0].upcase) && expanded_path[1] == ":"
drive_prefix = expanded_path[0, 2]
expanded_path = expanded_path[2, expanded_path.size]
end
expand_path_array = []
if File::ALT_SEPARATOR && expanded_path.include?(File::ALT_SEPARATOR)
expanded_path.gsub!(File::ALT_SEPARATOR, '/')
end
while expanded_path.include?('//')
expanded_path = expanded_path.gsub('//', '/')
end

if expanded_path == "/"
expanded_path
else
if expanded_path != "/"
expanded_path.split('/').each do |path_token|
if path_token == '..'
if expand_path_array.size > 1
Expand All @@ -109,8 +127,15 @@ def concat_path(path, base_path)
end
end

expand_path = expand_path_array.join("/")
expand_path.empty? ? '/' : expand_path
expanded_path = expand_path_array.join("/")
if expanded_path.empty?
expanded_path = '/'
end
end
if drive_prefix.empty?
expanded_path
else
drive_prefix + expanded_path.gsub("/", File::ALT_SEPARATOR)
end
end

Expand Down Expand Up @@ -170,4 +195,14 @@ def self.extname(filename)
ext = fname.split('.').last
ext.empty? ? '' : ".#{ext}"
end

def self.path(filename)
if filename.kind_of?(String)
filename
elsif filename.respond_to?(:to_path)
filename.to_path
else
raise TypeError, "no implicit conversion of #{filename.class} into String"
end
end
end

0 comments on commit 66a627d

Please sign in to comment.