passenger 5.0.8 → 5.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (168) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +20 -0
  5. data/CHANGELOG +21 -0
  6. data/bin/passenger-install-apache2-module +3 -1
  7. data/build/agents.rb +7 -5
  8. data/build/basics.rb +3 -3
  9. data/build/common_library.rb +52 -30
  10. data/build/cxx_tests.rb +20 -13
  11. data/build/misc.rb +5 -5
  12. data/doc/Design and Architecture.html +1 -1
  13. data/doc/Design and Architecture.txt +1 -1
  14. data/doc/Packaging.html +4 -4
  15. data/doc/Packaging.txt.md +4 -4
  16. data/doc/Users guide Apache.html +22 -9
  17. data/doc/Users guide Apache.idmap.txt +4 -2
  18. data/doc/Users guide Apache.txt +2 -0
  19. data/doc/Users guide Nginx.html +22 -9
  20. data/doc/Users guide Nginx.idmap.txt +4 -2
  21. data/doc/Users guide Nginx.txt +2 -0
  22. data/doc/Users guide Standalone.html +14 -9
  23. data/doc/Users guide Standalone.idmap.txt +4 -2
  24. data/doc/users_guide_snippets/installation.txt +10 -6
  25. data/ext/apache2/Hooks.cpp +13 -2
  26. data/ext/common/ApplicationPool2/Pool/Inspection.h +8 -3
  27. data/ext/common/BackgroundEventLoop.cpp +249 -67
  28. data/ext/common/BackgroundEventLoop.h +5 -5
  29. data/ext/common/Constants.h +1 -1
  30. data/ext/common/InstanceDirectory.h +8 -6
  31. data/ext/common/ServerKit/Context.h +8 -2
  32. data/ext/common/ServerKit/FileBufferedChannel.h +262 -226
  33. data/ext/common/ServerKit/HeaderTable.h +28 -3
  34. data/ext/common/ServerKit/HttpHeaderParser.h +37 -13
  35. data/ext/common/ServerKit/HttpServer.h +17 -1
  36. data/ext/common/ServerKit/Implementation.cpp +2 -0
  37. data/ext/common/ServerKit/Server.h +25 -28
  38. data/ext/common/Utils/IOUtils.cpp +11 -0
  39. data/ext/common/Utils/ProcessMetricsCollector.h +4 -0
  40. data/ext/common/Utils/StrIntUtils.cpp +11 -7
  41. data/ext/common/Utils/StrIntUtils.h +1 -1
  42. data/ext/common/Utils/StrIntUtilsNoStrictAliasing.cpp +21 -16
  43. data/ext/common/agents/Base.cpp +6 -0
  44. data/ext/common/agents/Base.h +2 -0
  45. data/ext/common/agents/HelperAgent/AdminServer.h +25 -25
  46. data/ext/common/agents/HelperAgent/Main.cpp +37 -12
  47. data/ext/common/agents/HelperAgent/RequestHandler.h +18 -20
  48. data/ext/common/agents/HelperAgent/RequestHandler/AppResponse.h +4 -0
  49. data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +10 -6
  50. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +2 -0
  51. data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +1 -1
  52. data/ext/common/agents/HelperAgent/RequestHandler/SendRequest.cpp +1 -1
  53. data/ext/common/agents/HelperAgent/RequestHandler/Utils.cpp +9 -2
  54. data/ext/common/agents/HelperAgent/ResponseCache.h +11 -11
  55. data/ext/common/agents/LoggingAgent/AdminServer.h +8 -8
  56. data/ext/common/agents/LoggingAgent/Main.cpp +6 -5
  57. data/ext/common/agents/Watchdog/AdminServer.h +13 -13
  58. data/ext/common/agents/Watchdog/Main.cpp +8 -3
  59. data/ext/libuv/.gitignore +72 -0
  60. data/ext/libuv/AUTHORS +199 -0
  61. data/ext/libuv/ChangeLog +2023 -0
  62. data/ext/libuv/LICENSE +46 -0
  63. data/ext/libuv/Makefile.am +336 -0
  64. data/ext/libuv/README.md +197 -0
  65. data/ext/libuv/checksparse.sh +233 -0
  66. data/ext/libuv/common.gypi +210 -0
  67. data/ext/libuv/configure.ac +67 -0
  68. data/ext/libuv/gyp_uv.py +96 -0
  69. data/ext/libuv/include/android-ifaddrs.h +54 -0
  70. data/ext/libuv/include/pthread-fixes.h +72 -0
  71. data/ext/libuv/include/tree.h +768 -0
  72. data/ext/libuv/include/uv-aix.h +32 -0
  73. data/ext/libuv/include/uv-bsd.h +34 -0
  74. data/ext/libuv/include/uv-darwin.h +61 -0
  75. data/ext/libuv/include/uv-errno.h +418 -0
  76. data/ext/libuv/include/uv-linux.h +34 -0
  77. data/ext/libuv/include/uv-sunos.h +44 -0
  78. data/ext/libuv/include/uv-threadpool.h +37 -0
  79. data/ext/libuv/include/uv-unix.h +383 -0
  80. data/ext/libuv/include/uv-version.h +39 -0
  81. data/ext/libuv/include/uv.h +1455 -0
  82. data/ext/libuv/libuv.pc.in +11 -0
  83. data/ext/libuv/m4/.gitignore +4 -0
  84. data/ext/libuv/m4/as_case.m4 +21 -0
  85. data/ext/libuv/m4/libuv-check-flags.m4 +319 -0
  86. data/ext/libuv/src/fs-poll.c +255 -0
  87. data/ext/libuv/src/heap-inl.h +245 -0
  88. data/ext/libuv/src/inet.c +313 -0
  89. data/ext/libuv/src/queue.h +92 -0
  90. data/ext/libuv/src/threadpool.c +303 -0
  91. data/ext/libuv/src/unix/aix.c +1240 -0
  92. data/ext/libuv/src/unix/android-ifaddrs.c +703 -0
  93. data/ext/libuv/src/unix/async.c +284 -0
  94. data/ext/libuv/src/unix/atomic-ops.h +60 -0
  95. data/ext/libuv/src/unix/core.c +985 -0
  96. data/ext/libuv/src/unix/darwin-proctitle.c +206 -0
  97. data/ext/libuv/src/unix/darwin.c +331 -0
  98. data/ext/libuv/src/unix/dl.c +83 -0
  99. data/ext/libuv/src/unix/freebsd.c +435 -0
  100. data/ext/libuv/src/unix/fs.c +1189 -0
  101. data/ext/libuv/src/unix/fsevents.c +899 -0
  102. data/ext/libuv/src/unix/getaddrinfo.c +202 -0
  103. data/ext/libuv/src/unix/getnameinfo.c +120 -0
  104. data/ext/libuv/src/unix/internal.h +314 -0
  105. data/ext/libuv/src/unix/kqueue.c +418 -0
  106. data/ext/libuv/src/unix/linux-core.c +876 -0
  107. data/ext/libuv/src/unix/linux-inotify.c +257 -0
  108. data/ext/libuv/src/unix/linux-syscalls.c +471 -0
  109. data/ext/libuv/src/unix/linux-syscalls.h +158 -0
  110. data/ext/libuv/src/unix/loop-watcher.c +63 -0
  111. data/ext/libuv/src/unix/loop.c +135 -0
  112. data/ext/libuv/src/unix/netbsd.c +368 -0
  113. data/ext/libuv/src/unix/openbsd.c +384 -0
  114. data/ext/libuv/src/unix/pipe.c +288 -0
  115. data/ext/libuv/src/unix/poll.c +113 -0
  116. data/ext/libuv/src/unix/process.c +551 -0
  117. data/ext/libuv/src/unix/proctitle.c +102 -0
  118. data/ext/libuv/src/unix/pthread-fixes.c +103 -0
  119. data/ext/libuv/src/unix/signal.c +465 -0
  120. data/ext/libuv/src/unix/spinlock.h +53 -0
  121. data/ext/libuv/src/unix/stream.c +1598 -0
  122. data/ext/libuv/src/unix/sunos.c +763 -0
  123. data/ext/libuv/src/unix/tcp.c +327 -0
  124. data/ext/libuv/src/unix/thread.c +519 -0
  125. data/ext/libuv/src/unix/timer.c +172 -0
  126. data/ext/libuv/src/unix/tty.c +265 -0
  127. data/ext/libuv/src/unix/udp.c +833 -0
  128. data/ext/libuv/src/uv-common.c +544 -0
  129. data/ext/libuv/src/uv-common.h +214 -0
  130. data/ext/libuv/src/version.c +49 -0
  131. data/ext/libuv/uv.gyp +487 -0
  132. data/ext/nginx/ContentHandler.c +21 -10
  133. data/ext/nginx/ngx_http_passenger_module.c +7 -0
  134. data/ext/oxt/implementation.cpp +9 -2
  135. data/ext/oxt/initialize.hpp +5 -1
  136. data/lib/phusion_passenger.rb +3 -3
  137. data/lib/phusion_passenger/admin_tools/instance.rb +10 -6
  138. data/lib/phusion_passenger/admin_tools/instance_registry.rb +6 -2
  139. data/lib/phusion_passenger/packaging.rb +3 -4
  140. data/lib/phusion_passenger/platform_info.rb +13 -1
  141. data/lib/phusion_passenger/platform_info/apache.rb +15 -4
  142. data/lib/phusion_passenger/platform_info/apache_detector.rb +5 -1
  143. data/lib/phusion_passenger/rack/thread_handler_extension.rb +184 -99
  144. data/lib/phusion_passenger/request_handler/thread_handler.rb +13 -6
  145. data/lib/phusion_passenger/standalone/start_command.rb +2 -2
  146. data/resources/templates/apache2/apache_install_broken.txt.erb +2 -1
  147. metadata +99 -22
  148. metadata.gz.asc +7 -7
  149. data/ext/libeio/Changes +0 -76
  150. data/ext/libeio/LICENSE +0 -36
  151. data/ext/libeio/Makefile.am +0 -15
  152. data/ext/libeio/Makefile.in +0 -694
  153. data/ext/libeio/aclocal.m4 +0 -9418
  154. data/ext/libeio/autogen.sh +0 -3
  155. data/ext/libeio/config.guess +0 -1540
  156. data/ext/libeio/config.h.in +0 -136
  157. data/ext/libeio/config.sub +0 -1779
  158. data/ext/libeio/configure +0 -14822
  159. data/ext/libeio/configure.ac +0 -22
  160. data/ext/libeio/demo.c +0 -194
  161. data/ext/libeio/ecb.h +0 -714
  162. data/ext/libeio/eio.c +0 -2818
  163. data/ext/libeio/eio.h +0 -414
  164. data/ext/libeio/install-sh +0 -520
  165. data/ext/libeio/libeio.m4 +0 -195
  166. data/ext/libeio/ltmain.sh +0 -9636
  167. data/ext/libeio/missing +0 -376
  168. data/ext/libeio/xthread.h +0 -166
@@ -0,0 +1,11 @@
1
+ prefix=@prefix@
2
+ exec_prefix=@prefix@
3
+ libdir=@libdir@
4
+ includedir=@includedir@
5
+
6
+ Name: @PACKAGE_NAME@
7
+ Version: @PACKAGE_VERSION@
8
+ Description: multi-platform support library with a focus on asynchronous I/O.
9
+
10
+ Libs: -L${libdir} -luv @LIBS@
11
+ Cflags: -I${includedir}
@@ -0,0 +1,4 @@
1
+ # Ignore libtoolize-generated files.
2
+ *.m4
3
+ !as_case.m4
4
+ !libuv-check-flags.m4
@@ -0,0 +1,21 @@
1
+ # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
2
+ # ----------------------------------------------------
3
+ # Expand into
4
+ # | case WORD in
5
+ # | PATTERN1) IF-MATCHED1 ;;
6
+ # | ...
7
+ # | *) DEFAULT ;;
8
+ # | esac
9
+ m4_define([_AS_CASE],
10
+ [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
11
+ [$#], 1, [ *) $1 ;;],
12
+ [$#], 2, [ $1) m4_default([$2], [:]) ;;],
13
+ [ $1) m4_default([$2], [:]) ;;
14
+ $0(m4_shiftn(2, $@))])dnl
15
+ ])
16
+ m4_defun([AS_CASE],
17
+ [m4_ifval([$2$3],
18
+ [case $1 in
19
+ _AS_CASE(m4_shift($@))
20
+ esac])])
21
+
@@ -0,0 +1,319 @@
1
+ dnl Macros to check the presence of generic (non-typed) symbols.
2
+ dnl Copyright (c) 2006-2008 Diego Pettenà <flameeyes gmail com>
3
+ dnl Copyright (c) 2006-2008 xine project
4
+ dnl
5
+ dnl This program is free software; you can redistribute it and/or modify
6
+ dnl it under the terms of the GNU General Public License as published by
7
+ dnl the Free Software Foundation; either version 3, or (at your option)
8
+ dnl any later version.
9
+ dnl
10
+ dnl This program is distributed in the hope that it will be useful,
11
+ dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ dnl GNU General Public License for more details.
14
+ dnl
15
+ dnl You should have received a copy of the GNU General Public License
16
+ dnl along with this program; if not, write to the Free Software
17
+ dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
+ dnl 02110-1301, USA.
19
+ dnl
20
+ dnl As a special exception, the copyright owners of the
21
+ dnl macro gives unlimited permission to copy, distribute and modify the
22
+ dnl configure scripts that are the output of Autoconf when processing the
23
+ dnl Macro. You need not follow the terms of the GNU General Public
24
+ dnl License when using or distributing such scripts, even though portions
25
+ dnl of the text of the Macro appear in them. The GNU General Public
26
+ dnl License (GPL) does govern all other use of the material that
27
+ dnl constitutes the Autoconf Macro.
28
+ dnl
29
+ dnl This special exception to the GPL applies to versions of the
30
+ dnl Autoconf Macro released by this project. When you make and
31
+ dnl distribute a modified version of the Autoconf Macro, you may extend
32
+ dnl this special exception to the GPL to apply to your modified version as
33
+ dnl well.
34
+
35
+ dnl Check if the flag is supported by compiler
36
+ dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
37
+
38
+ AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
39
+ AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
40
+ [ac_save_CFLAGS="$CFLAGS"
41
+ CFLAGS="$CFLAGS $1"
42
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
43
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
44
+ [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"])
45
+ CFLAGS="$ac_save_CFLAGS"
46
+ ])
47
+
48
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
49
+ [$2], [$3])
50
+ ])
51
+
52
+ dnl Check if the flag is supported by compiler (cacheable)
53
+ dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
54
+
55
+ AC_DEFUN([CC_CHECK_CFLAGS], [
56
+ AC_CACHE_CHECK([if $CC supports $1 flag],
57
+ AS_TR_SH([cc_cv_cflags_$1]),
58
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
59
+ )
60
+
61
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
62
+ [$2], [$3])
63
+ ])
64
+
65
+ dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
66
+ dnl Check for CFLAG and appends them to CFLAGS if supported
67
+ AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
68
+ AC_CACHE_CHECK([if $CC supports $1 flag],
69
+ AS_TR_SH([cc_cv_cflags_$1]),
70
+ CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
71
+ )
72
+
73
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
74
+ [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
75
+ ])
76
+
77
+ dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
78
+ AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
79
+ for flag in $1; do
80
+ CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
81
+ done
82
+ ])
83
+
84
+ dnl Check if the flag is supported by linker (cacheable)
85
+ dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
86
+
87
+ AC_DEFUN([CC_CHECK_LDFLAGS], [
88
+ AC_CACHE_CHECK([if $CC supports $1 flag],
89
+ AS_TR_SH([cc_cv_ldflags_$1]),
90
+ [ac_save_LDFLAGS="$LDFLAGS"
91
+ LDFLAGS="$LDFLAGS $1"
92
+ AC_LANG_PUSH([C])
93
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])],
94
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
95
+ [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
96
+ AC_LANG_POP([C])
97
+ LDFLAGS="$ac_save_LDFLAGS"
98
+ ])
99
+
100
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
101
+ [$2], [$3])
102
+ ])
103
+
104
+ dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
105
+ dnl the current linker to avoid undefined references in a shared object.
106
+ AC_DEFUN([CC_NOUNDEFINED], [
107
+ dnl We check $host for which systems to enable this for.
108
+ AC_REQUIRE([AC_CANONICAL_HOST])
109
+
110
+ case $host in
111
+ dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
112
+ dnl are requested, as different implementations are present; to avoid problems
113
+ dnl use -Wl,-z,defs only for those platform not behaving this way.
114
+ *-freebsd* | *-openbsd*) ;;
115
+ *)
116
+ dnl First of all check for the --no-undefined variant of GNU ld. This allows
117
+ dnl for a much more readable commandline, so that people can understand what
118
+ dnl it does without going to look for what the heck -z defs does.
119
+ for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
120
+ CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
121
+ break
122
+ done
123
+ ;;
124
+ esac
125
+
126
+ AC_SUBST([LDFLAGS_NOUNDEFINED])
127
+ ])
128
+
129
+ dnl Check for a -Werror flag or equivalent. -Werror is the GCC
130
+ dnl and ICC flag that tells the compiler to treat all the warnings
131
+ dnl as fatal. We usually need this option to make sure that some
132
+ dnl constructs (like attributes) are not simply ignored.
133
+ dnl
134
+ dnl Other compilers don't support -Werror per se, but they support
135
+ dnl an equivalent flag:
136
+ dnl - Sun Studio compiler supports -errwarn=%all
137
+ AC_DEFUN([CC_CHECK_WERROR], [
138
+ AC_CACHE_CHECK(
139
+ [for $CC way to treat warnings as errors],
140
+ [cc_cv_werror],
141
+ [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
142
+ [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
143
+ ])
144
+ ])
145
+
146
+ AC_DEFUN([CC_CHECK_ATTRIBUTE], [
147
+ AC_REQUIRE([CC_CHECK_WERROR])
148
+ AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
149
+ AS_TR_SH([cc_cv_attribute_$1]),
150
+ [ac_save_CFLAGS="$CFLAGS"
151
+ CFLAGS="$CFLAGS $cc_cv_werror"
152
+ AC_LANG_PUSH([C])
153
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
154
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
155
+ [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
156
+ AC_LANG_POP([C])
157
+ CFLAGS="$ac_save_CFLAGS"
158
+ ])
159
+
160
+ AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
161
+ [AC_DEFINE(
162
+ AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
163
+ [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
164
+ )
165
+ $4],
166
+ [$5])
167
+ ])
168
+
169
+ AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
170
+ CC_CHECK_ATTRIBUTE(
171
+ [constructor],,
172
+ [void __attribute__((constructor)) ctor() { int a; }],
173
+ [$1], [$2])
174
+ ])
175
+
176
+ AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
177
+ CC_CHECK_ATTRIBUTE(
178
+ [format], [format(printf, n, n)],
179
+ [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
180
+ [$1], [$2])
181
+ ])
182
+
183
+ AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
184
+ CC_CHECK_ATTRIBUTE(
185
+ [format_arg], [format_arg(printf)],
186
+ [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
187
+ [$1], [$2])
188
+ ])
189
+
190
+ AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
191
+ CC_CHECK_ATTRIBUTE(
192
+ [visibility_$1], [visibility("$1")],
193
+ [void __attribute__((visibility("$1"))) $1_function() { }],
194
+ [$2], [$3])
195
+ ])
196
+
197
+ AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
198
+ CC_CHECK_ATTRIBUTE(
199
+ [nonnull], [nonnull()],
200
+ [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
201
+ [$1], [$2])
202
+ ])
203
+
204
+ AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
205
+ CC_CHECK_ATTRIBUTE(
206
+ [unused], ,
207
+ [void some_function(void *foo, __attribute__((unused)) void *bar);],
208
+ [$1], [$2])
209
+ ])
210
+
211
+ AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
212
+ CC_CHECK_ATTRIBUTE(
213
+ [sentinel], ,
214
+ [void some_function(void *foo, ...) __attribute__((sentinel));],
215
+ [$1], [$2])
216
+ ])
217
+
218
+ AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
219
+ CC_CHECK_ATTRIBUTE(
220
+ [deprecated], ,
221
+ [void some_function(void *foo, ...) __attribute__((deprecated));],
222
+ [$1], [$2])
223
+ ])
224
+
225
+ AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
226
+ CC_CHECK_ATTRIBUTE(
227
+ [alias], [weak, alias],
228
+ [void other_function(void *foo) { }
229
+ void some_function(void *foo) __attribute__((weak, alias("other_function")));],
230
+ [$1], [$2])
231
+ ])
232
+
233
+ AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
234
+ CC_CHECK_ATTRIBUTE(
235
+ [malloc], ,
236
+ [void * __attribute__((malloc)) my_alloc(int n);],
237
+ [$1], [$2])
238
+ ])
239
+
240
+ AC_DEFUN([CC_ATTRIBUTE_PACKED], [
241
+ CC_CHECK_ATTRIBUTE(
242
+ [packed], ,
243
+ [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
244
+ [$1], [$2])
245
+ ])
246
+
247
+ AC_DEFUN([CC_ATTRIBUTE_CONST], [
248
+ CC_CHECK_ATTRIBUTE(
249
+ [const], ,
250
+ [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
251
+ [$1], [$2])
252
+ ])
253
+
254
+ AC_DEFUN([CC_FLAG_VISIBILITY], [
255
+ AC_REQUIRE([CC_CHECK_WERROR])
256
+ AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
257
+ [cc_cv_flag_visibility],
258
+ [cc_flag_visibility_save_CFLAGS="$CFLAGS"
259
+ CFLAGS="$CFLAGS $cc_cv_werror"
260
+ CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
261
+ cc_cv_flag_visibility='yes',
262
+ cc_cv_flag_visibility='no')
263
+ CFLAGS="$cc_flag_visibility_save_CFLAGS"])
264
+
265
+ AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
266
+ [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
267
+ [Define this if the compiler supports the -fvisibility flag])
268
+ $1],
269
+ [$2])
270
+ ])
271
+
272
+ AC_DEFUN([CC_FUNC_EXPECT], [
273
+ AC_REQUIRE([CC_CHECK_WERROR])
274
+ AC_CACHE_CHECK([if compiler has __builtin_expect function],
275
+ [cc_cv_func_expect],
276
+ [ac_save_CFLAGS="$CFLAGS"
277
+ CFLAGS="$CFLAGS $cc_cv_werror"
278
+ AC_LANG_PUSH([C])
279
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
280
+ [int some_function() {
281
+ int a = 3;
282
+ return (int)__builtin_expect(a, 3);
283
+ }])],
284
+ [cc_cv_func_expect=yes],
285
+ [cc_cv_func_expect=no])
286
+ AC_LANG_POP([C])
287
+ CFLAGS="$ac_save_CFLAGS"
288
+ ])
289
+
290
+ AS_IF([test "x$cc_cv_func_expect" = "xyes"],
291
+ [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
292
+ [Define this if the compiler supports __builtin_expect() function])
293
+ $1],
294
+ [$2])
295
+ ])
296
+
297
+ AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
298
+ AC_REQUIRE([CC_CHECK_WERROR])
299
+ AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
300
+ [cc_cv_attribute_aligned],
301
+ [ac_save_CFLAGS="$CFLAGS"
302
+ CFLAGS="$CFLAGS $cc_cv_werror"
303
+ AC_LANG_PUSH([C])
304
+ for cc_attribute_align_try in 64 32 16 8 4 2; do
305
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
306
+ int main() {
307
+ static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
308
+ return c;
309
+ }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
310
+ done
311
+ AC_LANG_POP([C])
312
+ CFLAGS="$ac_save_CFLAGS"
313
+ ])
314
+
315
+ if test "x$cc_cv_attribute_aligned" != "x"; then
316
+ AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
317
+ [Define the highest alignment supported])
318
+ fi
319
+ ])
@@ -0,0 +1,255 @@
1
+ /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ #include "uv.h"
23
+ #include "uv-common.h"
24
+
25
+ #include <assert.h>
26
+ #include <stdlib.h>
27
+ #include <string.h>
28
+
29
+ struct poll_ctx {
30
+ uv_fs_poll_t* parent_handle; /* NULL if parent has been stopped or closed */
31
+ int busy_polling;
32
+ unsigned int interval;
33
+ uint64_t start_time;
34
+ uv_loop_t* loop;
35
+ uv_fs_poll_cb poll_cb;
36
+ uv_timer_t timer_handle;
37
+ uv_fs_t fs_req; /* TODO(bnoordhuis) mark fs_req internal */
38
+ uv_stat_t statbuf;
39
+ char path[1]; /* variable length */
40
+ };
41
+
42
+ static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b);
43
+ static void poll_cb(uv_fs_t* req);
44
+ static void timer_cb(uv_timer_t* timer);
45
+ static void timer_close_cb(uv_handle_t* handle);
46
+
47
+ static uv_stat_t zero_statbuf;
48
+
49
+
50
+ int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) {
51
+ uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL);
52
+ return 0;
53
+ }
54
+
55
+
56
+ int uv_fs_poll_start(uv_fs_poll_t* handle,
57
+ uv_fs_poll_cb cb,
58
+ const char* path,
59
+ unsigned int interval) {
60
+ struct poll_ctx* ctx;
61
+ uv_loop_t* loop;
62
+ size_t len;
63
+ int err;
64
+
65
+ if (uv__is_active(handle))
66
+ return 0;
67
+
68
+ loop = handle->loop;
69
+ len = strlen(path);
70
+ ctx = calloc(1, sizeof(*ctx) + len);
71
+
72
+ if (ctx == NULL)
73
+ return UV_ENOMEM;
74
+
75
+ ctx->loop = loop;
76
+ ctx->poll_cb = cb;
77
+ ctx->interval = interval ? interval : 1;
78
+ ctx->start_time = uv_now(loop);
79
+ ctx->parent_handle = handle;
80
+ memcpy(ctx->path, path, len + 1);
81
+
82
+ err = uv_timer_init(loop, &ctx->timer_handle);
83
+ if (err < 0)
84
+ goto error;
85
+
86
+ ctx->timer_handle.flags |= UV__HANDLE_INTERNAL;
87
+ uv__handle_unref(&ctx->timer_handle);
88
+
89
+ err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
90
+ if (err < 0)
91
+ goto error;
92
+
93
+ handle->poll_ctx = ctx;
94
+ uv__handle_start(handle);
95
+
96
+ return 0;
97
+
98
+ error:
99
+ free(ctx);
100
+ return err;
101
+ }
102
+
103
+
104
+ int uv_fs_poll_stop(uv_fs_poll_t* handle) {
105
+ struct poll_ctx* ctx;
106
+
107
+ if (!uv__is_active(handle))
108
+ return 0;
109
+
110
+ ctx = handle->poll_ctx;
111
+ assert(ctx != NULL);
112
+ assert(ctx->parent_handle != NULL);
113
+ ctx->parent_handle = NULL;
114
+ handle->poll_ctx = NULL;
115
+
116
+ /* Close the timer if it's active. If it's inactive, there's a stat request
117
+ * in progress and poll_cb will take care of the cleanup.
118
+ */
119
+ if (uv__is_active(&ctx->timer_handle))
120
+ uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
121
+
122
+ uv__handle_stop(handle);
123
+
124
+ return 0;
125
+ }
126
+
127
+
128
+ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
129
+ struct poll_ctx* ctx;
130
+ size_t required_len;
131
+
132
+ if (!uv__is_active(handle)) {
133
+ *size = 0;
134
+ return UV_EINVAL;
135
+ }
136
+
137
+ ctx = handle->poll_ctx;
138
+ assert(ctx != NULL);
139
+
140
+ required_len = strlen(ctx->path);
141
+ if (required_len > *size) {
142
+ *size = required_len;
143
+ return UV_ENOBUFS;
144
+ }
145
+
146
+ memcpy(buffer, ctx->path, required_len);
147
+ *size = required_len;
148
+
149
+ return 0;
150
+ }
151
+
152
+
153
+ void uv__fs_poll_close(uv_fs_poll_t* handle) {
154
+ uv_fs_poll_stop(handle);
155
+ }
156
+
157
+
158
+ static void timer_cb(uv_timer_t* timer) {
159
+ struct poll_ctx* ctx;
160
+
161
+ ctx = container_of(timer, struct poll_ctx, timer_handle);
162
+ assert(ctx->parent_handle != NULL);
163
+ assert(ctx->parent_handle->poll_ctx == ctx);
164
+ ctx->start_time = uv_now(ctx->loop);
165
+
166
+ if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb))
167
+ abort();
168
+ }
169
+
170
+
171
+ static void poll_cb(uv_fs_t* req) {
172
+ uv_stat_t* statbuf;
173
+ struct poll_ctx* ctx;
174
+ uint64_t interval;
175
+
176
+ ctx = container_of(req, struct poll_ctx, fs_req);
177
+
178
+ if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */
179
+ uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
180
+ uv_fs_req_cleanup(req);
181
+ return;
182
+ }
183
+
184
+ if (req->result != 0) {
185
+ if (ctx->busy_polling != req->result) {
186
+ ctx->poll_cb(ctx->parent_handle,
187
+ req->result,
188
+ &ctx->statbuf,
189
+ &zero_statbuf);
190
+ ctx->busy_polling = req->result;
191
+ }
192
+ goto out;
193
+ }
194
+
195
+ statbuf = &req->statbuf;
196
+
197
+ if (ctx->busy_polling != 0)
198
+ if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf))
199
+ ctx->poll_cb(ctx->parent_handle, 0, &ctx->statbuf, statbuf);
200
+
201
+ ctx->statbuf = *statbuf;
202
+ ctx->busy_polling = 1;
203
+
204
+ out:
205
+ uv_fs_req_cleanup(req);
206
+
207
+ if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */
208
+ uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
209
+ return;
210
+ }
211
+
212
+ /* Reschedule timer, subtract the delay from doing the stat(). */
213
+ interval = ctx->interval;
214
+ interval -= (uv_now(ctx->loop) - ctx->start_time) % interval;
215
+
216
+ if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0))
217
+ abort();
218
+ }
219
+
220
+
221
+ static void timer_close_cb(uv_handle_t* handle) {
222
+ free(container_of(handle, struct poll_ctx, timer_handle));
223
+ }
224
+
225
+
226
+ static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) {
227
+ return a->st_ctim.tv_nsec == b->st_ctim.tv_nsec
228
+ && a->st_mtim.tv_nsec == b->st_mtim.tv_nsec
229
+ && a->st_birthtim.tv_nsec == b->st_birthtim.tv_nsec
230
+ && a->st_ctim.tv_sec == b->st_ctim.tv_sec
231
+ && a->st_mtim.tv_sec == b->st_mtim.tv_sec
232
+ && a->st_birthtim.tv_sec == b->st_birthtim.tv_sec
233
+ && a->st_size == b->st_size
234
+ && a->st_mode == b->st_mode
235
+ && a->st_uid == b->st_uid
236
+ && a->st_gid == b->st_gid
237
+ && a->st_ino == b->st_ino
238
+ && a->st_dev == b->st_dev
239
+ && a->st_flags == b->st_flags
240
+ && a->st_gen == b->st_gen;
241
+ }
242
+
243
+
244
+ #if defined(_WIN32)
245
+
246
+ #include "win/internal.h"
247
+ #include "win/handle-inl.h"
248
+
249
+ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) {
250
+ assert(handle->flags & UV__HANDLE_CLOSING);
251
+ assert(!(handle->flags & UV_HANDLE_CLOSED));
252
+ uv__handle_close(handle);
253
+ }
254
+
255
+ #endif /* _WIN32 */