提交 12d47554 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update libuv to 1.34.1

上级 8308dbcf
......@@ -5,6 +5,11 @@ daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- v2
- enhancement
- good first issue
- feature-request
- doc
- bug
- not-stale
# Label to use when marking an issue as stale
staleLabel: stale
......
......@@ -412,3 +412,4 @@ ZYSzys <zyszys98@gmail.com>
Carl Lei <xecycle@gmail.com>
Stefan Bender <stefan.bender@ntnu.no>
nia <nia@NetBSD.org>
virtualyw <virtualyw@gmail.com>
2019.12.05, Version 1.34.0 (Stable)
2020.01.13, Version 1.34.1 (Stable)
Changes since version 1.34.0:
* unix: fix -Wstrict-aliasing compiler warning (Ben Noordhuis)
* unix: cache address of dlsym("mkostemp") (Ben Noordhuis)
* build: remove -pedantic from compiler flags (Ben Noordhuis)
* Revert "darwin: assume pthread_setname_np() is available" (Ben Noordhuis)
* Revert "darwin: speed up uv_set_process_title()" (Ben Noordhuis)
* darwin: assume pthread_setname_np() is available (Ben Noordhuis)
* ibmi: fix the false isatty() issue on IBMi (Xu Meng)
* test: fix test failure under NetBSD and OpenBSD (David Carlier)
* test: skip some test cases on IBMi (Xu Meng)
* test: skip uv_(get|set)_process_title on IBMi (Xu Meng)
* doc: remove binaries for Windows from README (Richard Lau)
* unix: fix -Wunused-but-set-variable warning (George Zhao)
* unix: pass sysctl size arg using ARRAY_SIZE macro (David Carlier)
* test: disallow running the test suite as root (cjihrig)
* unix: suppress -Waddress-of-packed-member warning (Ben Noordhuis)
* misc: make more tags "not-stale" (Jameson Nash)
* test: fix pthread memory leak (Trevor Norris)
* docs: delete socks5-proxy sample (Jameson Nash)
* ibmi: fix the CMSG length issue (Xu Meng)
* docs: fix formatting (Jameson Nash)
* unix: squelch fchmod() EPERM on CIFS share (Ben Noordhuis)
* docs: fix linkcheck (Jameson Nash)
* docs: switch from linux.die.net to man7.org (Jameson Nash)
* win: remove abort when non-IFS LSP detection fails (virtualyw)
* docs: clarify that uv_pipe_t is a pipe (Jameson Nash)
* win,tty: avoid regressions in utf-8 handling (Jameson Nash)
* win: remove bad assert in uv_loop_close (Jameson Nash)
* test: fix -fno-common build errors (Ben Noordhuis)
* build: turn on -fno-common to catch regressions (Ben Noordhuis)
* test: fix fs birth time test failure (Ben Noordhuis)
* tty,unix: avoid affecting controlling TTY (Jameson Nash)
2019.12.05, Version 1.34.0 (Stable), 15ae750151ac9341e5945eb38f8982d59fb99201
Changes since version 1.33.1:
......
......@@ -123,7 +123,6 @@ EXTRA_DIST = test/fixtures/empty_file \
include \
docs \
img \
samples \
android-configure-arm \
android-configure-arm64 \
android-configure-x86 \
......
......@@ -116,9 +116,6 @@ libuv can be downloaded either from the
[GitHub repository](https://github.com/libuv/libuv)
or from the [downloads site](http://dist.libuv.org/dist/).
Starting with libuv 1.7.0, binaries for Windows are also provided. This is to
be considered EXPERIMENTAL.
Before verifying the git tags or signature files, importing the relevant keys
is necessary. Key IDs are listed in the
[MAINTAINERS](https://github.com/libuv/libuv/blob/master/MAINTAINERS.md)
......
......@@ -35,7 +35,7 @@
},
'conditions': [
['OS != "zos"', {
'cflags': [ '-O0', '-fwrapv' ]
'cflags': [ '-O0', '-fno-common', '-fwrapv' ]
}],
['OS == "android"', {
'cflags': [ '-fPIE' ],
......@@ -80,9 +80,10 @@
'conditions': [
['OS != "zos"', {
'cflags': [
'-fomit-frame-pointer',
'-fdata-sections',
'-ffunction-sections',
'-fno-common',
'-fomit-frame-pointer',
],
}],
]
......
......@@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57)
AC_INIT([libuv], [1.34.0], [https://github.com/libuv/libuv/issues])
AC_INIT([libuv], [1.34.1], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4])
......@@ -24,9 +24,6 @@ AC_ENABLE_SHARED
AC_ENABLE_STATIC
AC_PROG_CC
AM_PROG_CC_C_O
AS_IF([AS_CASE([$host_os],[openedition*], [false], [true])], [
CC_CHECK_CFLAGS_APPEND([-pedantic])
])
CC_FLAG_VISIBILITY #[-fvisibility=hidden]
CC_CHECK_CFLAGS_APPEND([-g])
CC_CHECK_CFLAGS_APPEND([-std=gnu89])
......
......@@ -126,7 +126,7 @@ Unlike network I/O, there are no platform-specific file I/O primitives libuv cou
so the current approach is to run blocking file I/O operations in a thread pool.
For a thorough explanation of the cross-platform file I/O landscape, checkout
`this post <http://blog.libtorrent.org/2012/10/asynchronous-disk-io/>`_.
`this post <https://blog.libtorrent.org/2012/10/asynchronous-disk-io/>`_.
libuv currently uses a global thread pool on which all loops can queue work. 3 types of
operations are currently run on this pool:
......
......@@ -403,7 +403,7 @@ API
.. c:function:: int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb)
.. c:function:: int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb)
Equivalent to :man:`utime(2)` and :man:`futime(2)` respectively.
Equivalent to :man:`utime(2)` and :man:`futimes(3)` respectively.
.. note::
AIX: This function only works for AIX 7.1 and newer. It can still be called on older
......@@ -435,7 +435,7 @@ API
.. c:function:: int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle <https://msdn.microsoft.com/en-us/library/windows/desktop/aa364962(v=vs.85).aspx>`_.
Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>`_.
The resulting string is stored in `req->ptr`.
.. warning::
......@@ -512,7 +512,7 @@ Helper functions
.. c:function:: uv_os_fd_t uv_get_osfhandle(int fd)
For a file descriptor in the C runtime, get the OS-dependent handle.
On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle <https://msdn.microsoft.com/en-us/library/ks2530z6.aspx>`_.
On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=vs-2019>`_.
Note that the return value is still owned by the C runtime,
any attempts to close it or to use it after closing the fd may lead to malfunction.
......@@ -521,7 +521,7 @@ Helper functions
.. c:function:: int uv_open_osfhandle(uv_os_fd_t os_fd)
For a OS-dependent handle, get the file descriptor in the C runtime.
On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://msdn.microsoft.com/en-us/library/bdts1c9x.aspx>`_.
On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>`_.
Note that the return value is still owned by the CRT,
any attempts to close it or to use it after closing the handle may lead to malfunction.
......@@ -547,7 +547,7 @@ File open constants
.. note::
`UV_FS_O_DIRECT` is supported on Linux, and on Windows via
`FILE_FLAG_NO_BUFFERING <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_NO_BUFFERING <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
`UV_FS_O_DIRECT` is not supported on macOS.
.. c:macro:: UV_FS_O_DIRECTORY
......@@ -564,7 +564,7 @@ File open constants
.. note::
`UV_FS_O_DSYNC` is supported on Windows via
`FILE_FLAG_WRITE_THROUGH <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
.. c:macro:: UV_FS_O_EXCL
......@@ -631,7 +631,7 @@ File open constants
.. note::
`UV_FS_O_RANDOM` is only supported on Windows via
`FILE_FLAG_RANDOM_ACCESS <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_FLAG_RANDOM_ACCESS <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
.. c:macro:: UV_FS_O_RDONLY
......@@ -648,7 +648,7 @@ File open constants
.. note::
`UV_FS_O_SEQUENTIAL` is only supported on Windows via
`FILE_FLAG_SEQUENTIAL_SCAN <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_FLAG_SEQUENTIAL_SCAN <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
.. c:macro:: UV_FS_O_SHORT_LIVED
......@@ -656,7 +656,7 @@ File open constants
.. note::
`UV_FS_O_SHORT_LIVED` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
.. c:macro:: UV_FS_O_SYMLINK
......@@ -669,7 +669,7 @@ File open constants
.. note::
`UV_FS_O_SYNC` is supported on Windows via
`FILE_FLAG_WRITE_THROUGH <https://msdn.microsoft.com/en-us/library/windows/desktop/cc644950.aspx>`_.
`FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
.. c:macro:: UV_FS_O_TEMPORARY
......@@ -677,7 +677,7 @@ File open constants
.. note::
`UV_FS_O_TEMPORARY` is only supported on Windows via
`FILE_ATTRIBUTE_TEMPORARY <https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx>`_.
`FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
.. c:macro:: UV_FS_O_TRUNC
......
......@@ -23,7 +23,7 @@ the best backend for the job on each platform.
creation/deletion within a directory that is being monitored.
See the `IBM Knowledge centre`_ for more details.
.. _documentation: http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/
.. _documentation: https://developer.ibm.com/articles/au-aix_event_infrastructure/
.. _`IBM Knowledge centre`: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/ioc.htm
......
About
=====
`Nikhil Marathe <http://nikhilism.com>`_ started writing this book one
`Nikhil Marathe <https://nikhilism.com>`_ started writing this book one
afternoon (June 16, 2012) when he didn't feel like programming. He had recently
been stung by the lack of good documentation on libuv while working on
`node-taglib <https://github.com/nikhilm/node-taglib>`_. Although reference
......@@ -13,8 +13,8 @@ Nikhil is indebted to Marc Lehmann's comprehensive `man page
<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod>`_ about libev which
describes much of the semantics of the two libraries.
This book was made using `Sphinx <http://sphinx.pocoo.org/>`_ and `vim
<http://www.vim.org>`_.
This book was made using `Sphinx <https://www.sphinx-doc.org>`_ and `vim
<https://www.vim.org>`_.
.. note::
In 2017 the libuv project incorporated the Nikhil's work into the official
......
......@@ -66,10 +66,10 @@ There is no need to ``make install``. To build the examples run ``make`` in the
.. _Clone: https://github.com/nikhilm/uvbook
.. _Download: https://github.com/nikhilm/uvbook/downloads
.. _v1.3.0: https://github.com/libuv/libuv/tags
.. _V8: http://code.google.com/p/v8/
.. _V8: https://v8.dev
.. _libev: http://software.schmorp.de/pkg/libev.html
.. _libuv: https://github.com/libuv/libuv
.. _node.js: http://www.nodejs.org
.. _node.js: https://www.nodejs.org
.. _libev was removed: https://github.com/joyent/libuv/issues/485
.. _Rust: http://rust-lang.org
.. _Rust: https://www.rust-lang.org
.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
......@@ -175,7 +175,7 @@ where ``membership`` is ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``.
The concepts of multicasting are nicely explained in `this guide`_.
.. _this guide: http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html
.. _this guide: https://www.tldp.org/HOWTO/Multicast-HOWTO-2.html
Local loopback of multicast packets is enabled by default [#]_, use
``uv_udp_set_multicast_loop`` to switch it off.
......@@ -234,17 +234,17 @@ useful to allow your service to bind to IP addresses when it starts.
interface has multiple IPv4/IPv6 addresses, the name will be reported multiple
times, with each address being reported once.
.. _c-ares: http://c-ares.haxx.se
.. _getaddrinfo: http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo.3.html
.. _c-ares: https://c-ares.haxx.se
.. _getaddrinfo: https://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo.3.html
.. _User Datagram Protocol: http://en.wikipedia.org/wiki/User_Datagram_Protocol
.. _DHCP: http://tools.ietf.org/html/rfc2131
.. _User Datagram Protocol: https://en.wikipedia.org/wiki/User_Datagram_Protocol
.. _DHCP: https://tools.ietf.org/html/rfc2131
----
.. [#] http://beej.us/guide/bgnet/output/html/multipage/advanced.html#broadcast
.. [#] https://beej.us/guide/bgnet/html/#broadcast-packetshello-world
.. [#] on Windows only supported on Windows Vista and later.
.. [#] http://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1
.. [#] https://www.tldp.org/HOWTO/Multicast-HOWTO-6.html#ss6.1
.. [#] libuv use the system ``getaddrinfo`` in the libuv threadpool. libuv
v0.8.0 and earlier also included c-ares_ as an alternative, but this has been
removed in v0.9.0.
......@@ -42,12 +42,10 @@ exits. This is achieved using ``uv_spawn``.
The ``uv_process_t`` struct only acts as the handle, all options are set via
``uv_process_options_t``. To simply launch a process, you need to set only the
``file`` and ``args`` fields. ``file`` is the program to execute. Since
``uv_spawn`` uses execvp_ internally, there is no need to supply the full
``uv_spawn`` uses :man:`execvp(3)` internally, there is no need to supply the full
path. Finally as per underlying conventions, **the arguments array has to be
one larger than the number of arguments, with the last element being NULL**.
.. _execvp: http://www.kernel.org/doc/man-pages/online/pages/man3/exec.3.html
After the call to ``uv_spawn``, ``uv_process_t.pid`` will contain the process
ID of the child process.
......@@ -213,7 +211,7 @@ to ``UV_INHERIT_STREAM`` and setting ``data.stream`` to the stream in the
parent process, the child process can treat that stream as standard I/O. This
can be used to implement something like CGI_.
.. _CGI: http://en.wikipedia.org/wiki/Common_Gateway_Interface
.. _CGI: https://en.wikipedia.org/wiki/Common_Gateway_Interface
A sample CGI script/executable is:
......@@ -245,26 +243,35 @@ is great. Just be warned that creating processes is a costly task.
.. _pipes:
Pipes
-----
libuv's ``uv_pipe_t`` structure is slightly confusing to Unix programmers,
because it immediately conjures up ``|`` and `pipe(7)`_. But ``uv_pipe_t`` is
not related to anonymous pipes, rather it is an IPC mechanism. ``uv_pipe_t``
can be backed by a `Unix Domain Socket`_ or `Windows Named Pipe`_ to allow
multiple processes to communicate. This is discussed below.
.. _pipe(7): http://www.kernel.org/doc/man-pages/online/pages/man7/pipe.7.html
.. _Unix Domain Socket: http://www.kernel.org/doc/man-pages/online/pages/man7/unix.7.html
.. _Windows Named Pipe: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365590(v=vs.85).aspx
Parent-child IPC
++++++++++++++++
----------------
A parent and child can have one or two way communication over a pipe created by
settings ``uv_stdio_container_t.flags`` to a bit-wise combination of
``UV_CREATE_PIPE`` and ``UV_READABLE_PIPE`` or ``UV_WRITABLE_PIPE``. The
read/write flag is from the perspective of the child process.
read/write flag is from the perspective of the child process. In this case,
the ``uv_stream_t* stream`` field must be set to point to an initialized,
unopened ``uv_pipe_t`` instance.
New stdio Pipes
+++++++++++++++
The ``uv_pipe_t`` structure represents more than just `pipe(7)`_ (or ``|``),
but supports any streaming file-like objects. On Windows, the only object of
that description is the `Named Pipe`_. On Unix, this could be any of `Unix
Domain Socket`_, or derived from `mkfifo(1)`_, or it could actually be a
`pipe(7)`_. When ``uv_spawn`` initializes a ``uv_pipe_t`` due to the
`UV_CREATE_PIPE` flag, it opts for creating a `socketpair(2)`_.
This is intended for the purpose of allowing multiple libuv processes to
communicate with IPC. This is discussed below.
.. _pipe(7): http://man7.org/linux/man-pages/man7/pipe.7.html
.. _mkfifo(1): http://man7.org/linux/man-pages/man1/mkfifo.1.html
.. _socketpair(2): http://man7.org/linux/man-pages/man2/socketpair.2.html
.. _Unix Domain Socket: http://man7.org/linux/man-pages/man7/unix.7.html
.. _Named Pipe: https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipes
Arbitrary process IPC
+++++++++++++++++++++
......@@ -276,7 +283,7 @@ notification. Various applications can then react when a contact comes online
or new hardware is detected. The MySQL server also runs a domain socket on
which clients can interact with it.
.. _D-BUS: http://www.freedesktop.org/wiki/Software/dbus
.. _D-BUS: https://www.freedesktop.org/wiki/Software/dbus
When using domain sockets, a client-server pattern is usually followed with the
creator/owner of the socket acting as the server. After the initial setup,
......
......@@ -12,7 +12,7 @@ asynchronously that is actually blocking, by spawning a thread and collecting
the result when it is done.
Today there are two predominant thread libraries: the Windows threads
implementation and POSIX's `pthreads`_. libuv's thread API is analogous to
implementation and POSIX's :man:`pthreads(7)`. libuv's thread API is analogous to
the pthreads API and often has similar semantics.
A notable aspect of libuv's thread facilities is that it is a self contained
......@@ -68,7 +68,7 @@ Synchronization Primitives
This section is purposely spartan. This book is not about threads, so I only
catalogue any surprises in the libuv APIs here. For the rest you can look at
the pthreads `man pages <pthreads>`_.
the :man:`pthreads(7)` man pages.
Mutexes
~~~~~~~
......@@ -141,9 +141,9 @@ Others
libuv also supports semaphores_, `condition variables`_ and barriers_ with APIs
very similar to their pthread counterparts.
.. _semaphores: http://en.wikipedia.org/wiki/Semaphore_(programming)
.. _condition variables: http://en.wikipedia.org/wiki/Condition_variable#Waiting_and_signaling
.. _barriers: http://en.wikipedia.org/wiki/Barrier_(computer_science)
.. _semaphores: https://en.wikipedia.org/wiki/Semaphore_(programming)
.. _condition variables: https://en.wikipedia.org/wiki/Monitor_(synchronization)#Condition_variables_2
.. _barriers: https://en.wikipedia.org/wiki/Barrier_(computer_science)
In addition, libuv provides a convenience function ``uv_once()``. Multiple
threads can attempt to call ``uv_once()`` with a given guard and a function
......@@ -379,9 +379,7 @@ which binds a third party library. It may go something like this:
4. The async callback, invoked in the main loop thread, which is the v8 thread,
then interacts with v8 to invoke the JavaScript callback.
.. _pthreads: http://man7.org/linux/man-pages/man7/pthreads.7.html
----
.. _node.js is cancer: http://teddziuba.github.io/2011/10/node-js-is-cancer.html
.. _node.js is cancer: http://widgetsandshit.com/teddziuba/2011/10/node-js-is-cancer.html
.. _bnoordhuis: https://github.com/bnoordhuis
......@@ -196,7 +196,7 @@ to access the underlying file descriptors and provide functions that process
tasks in small increments as decided by your application. Some libraries though
will not allow such access, providing only a standard blocking function which
will perform the entire I/O transaction and only then return. It is unwise to
use these in the event loop thread, use the :ref:`libuv-work-queue` instead. Of
use these in the event loop thread, use the :ref:`threadpool` instead. Of
course, this will also mean losing granular control on the library.
The ``uv_poll`` section of libuv simply watches file descriptors using the
......@@ -210,8 +210,8 @@ download files. Rather than give all control to libcurl, we'll instead be
using the libuv event loop, and use the non-blocking, async multi_ interface to
progress with the download whenever libuv notifies of I/O readiness.
.. _libcurl: http://curl.haxx.se/libcurl/
.. _multi: http://curl.haxx.se/libcurl/c/libcurl-multi.html
.. _libcurl: https://curl.haxx.se/libcurl/
.. _multi: https://curl.haxx.se/libcurl/c/libcurl-multi.html
.. rubric:: uvwget/main.c - The setup
.. literalinclude:: ../../code/uvwget/main.c
......@@ -352,7 +352,7 @@ to get the error message.
argument. ``init_plugin_function`` is a function pointer to the sort of
function we are looking for in the application's plugins.
.. _shared libraries: http://en.wikipedia.org/wiki/Shared_library#Shared_libraries
.. _shared libraries: https://en.wikipedia.org/wiki/Shared_library#Shared_libraries
TTY
---
......@@ -365,7 +365,7 @@ implement the ANSI escape codes across all platforms. By this I mean that libuv
converts ANSI codes to the Windows equivalent, and provides functions to get
terminal information.
.. _pretty standardised: http://en.wikipedia.org/wiki/ANSI_escape_sequences
.. _pretty standardised: https://en.wikipedia.org/wiki/ANSI_escape_sequences
The first thing to do is to initialize a ``uv_tty_t`` with the file descriptor
it reads/writes from. This is achieved with::
......@@ -422,7 +422,7 @@ As you can see this is very useful to produce nicely formatted output, or even
console based arcade games if that tickles your fancy. For fancier control you
can try `ncurses`_.
.. _ncurses: http://www.gnu.org/software/ncurses/ncurses.html
.. _ncurses: https://www.gnu.org/software/ncurses/ncurses.html
.. versionchanged:: 1.23.1: the `readable` parameter is now unused and ignored.
The appropriate value will now be auto-detected from the kernel.
......@@ -431,7 +431,7 @@ can try `ncurses`_.
.. [#] I was first introduced to the term baton in this context, in Konstantin
Käfer's excellent slides on writing node.js bindings --
http://kkaefer.github.com/node-cpp-modules/#baton
https://kkaefer.com/node-cpp-modules/#baton
.. [#] mfp is My Fancy Plugin
.. _libev man page: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#COMMON_OR_USEFUL_IDIOMS_OR_BOTH
......@@ -13,9 +13,9 @@ was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_,
In case you find errors in this documentation you can help by sending
`pull requests <https://github.com/libuv/libuv>`_!
.. _Node.js: http://nodejs.org
.. _Luvit: http://luvit.io
.. _Julia: http://julialang.org
.. _Node.js: https://nodejs.org
.. _Luvit: https://luvit.io
.. _Julia: https://julialang.org
.. _pyuv: https://github.com/saghul/pyuv
.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
......@@ -52,7 +52,7 @@ Documentation
Downloads
---------
libuv can be downloaded from `here <http://dist.libuv.org/dist/>`_.
libuv can be downloaded from `here <https://dist.libuv.org/dist/>`_.
Installation
......
......@@ -192,10 +192,10 @@ Data types
::
typedef struct uv_env_item_s {
char* name;
char* value;
} uv_env_item_t;
typedef struct uv_env_item_s {
char* name;
char* value;
} uv_env_item_t;
.. c:type:: uv_random_t
......@@ -314,7 +314,7 @@ API
.. c:function:: void uv_loadavg(double avg[3])
Gets the load average. See: `<http://en.wikipedia.org/wiki/Load_(computing)>`_
Gets the load average. See: `<https://en.wikipedia.org/wiki/Load_(computing)>`_
.. note::
Returns [0,0,0] on Windows (i.e., it's not implemented).
......@@ -646,7 +646,7 @@ API
Retrieves system information in `buffer`. The populated data includes the
operating system name, release, version, and machine. On non-Windows
systems, `uv_os_uname()` is a thin wrapper around :man:`uname(3)`. Returns
systems, `uv_os_uname()` is a thin wrapper around :man:`uname(2)`. Returns
zero on success, and a non-zero error value otherwise.
.. versionadded:: 1.25.0
......@@ -687,7 +687,7 @@ API
- Other UNIX: `/dev/urandom` after reading from `/dev/random` once.
:returns: 0 on success, or an error code < 0 on failure. The contents of
`buf` is undefined after an error.
`buf` is undefined after an error.
.. note::
When using the synchronous version, both `loop` and `req` parameters
......
......@@ -4,8 +4,8 @@
:c:type:`uv_pipe_t` --- Pipe handle
===================================
Pipe handles provide an abstraction over local domain sockets on Unix and named
pipes on Windows.
Pipe handles provide an abstraction over streaming files on Unix (including
local domain sockets, pipes, and FIFOs) and named pipes on Windows.
:c:type:`uv_pipe_t` is a 'subclass' of :c:type:`uv_stream_t`.
......@@ -34,7 +34,8 @@ API
.. c:function:: int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc)
Initialize a pipe handle. The `ipc` argument is a boolean to indicate if
this pipe will be used for handle passing between processes.
this pipe will be used for handle passing between processes (which may
change the bytes on the wire).
.. c:function:: int uv_pipe_open(uv_pipe_t* handle, uv_file file)
......
......@@ -18,7 +18,7 @@ from string import Template
def make_link_node(rawtext, app, name, manpage_num, options):
ref = app.config.man_url_regex
if not ref:
ref = "http://linux.die.net/man/%s/%s" % (manpage_num, name)
ref = "http://man7.org/linux/man-pages/man%s/%s.%s.html" %(manpage_num, name, manpage_num)
else:
s = Template(ref)
ref = s.substitute(num=manpage_num, topic=name)
......
......@@ -10,7 +10,7 @@ a major release. In this section you'll find all macros and functions that
will allow you to write or compile code conditionally, in order to work with
multiple libuv versions.
.. _semantic versioning: http://semver.org
.. _semantic versioning: https://semver.org
Macros
......
......@@ -32,7 +32,7 @@
#define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 34
#define UV_VERSION_PATCH 0
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX ""
......
# Copyright StrongLoop, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
*.mk
*.Makefile
# Copyright StrongLoop, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
/build/
Files: *
========
Copyright StrongLoop, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
Files: getopt.c
===============
Copyright (c) 1987, 1993, 1994
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
# Copyright StrongLoop, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
{
'targets': [
{
'dependencies': ['../../uv.gyp:libuv'],
'target_name': 's5-proxy',
'type': 'executable',
'sources': [
'client.c',
'defs.h',
'main.c',
's5.c',
's5.h',
'server.c',
'util.c',
],
'conditions': [
['OS=="win"', {
'defines': ['HAVE_UNISTD_H=0'],
'sources': ['getopt.c']
}, {
'defines': ['HAVE_UNISTD_H=1']
}]
]
}
]
}
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef DEFS_H_
#define DEFS_H_
#include "s5.h"
#include "uv.h"
#include <assert.h>
#include <netinet/in.h> /* sockaddr_in, sockaddr_in6 */
#include <stddef.h> /* size_t, ssize_t */
#include <stdint.h>
#include <sys/socket.h> /* sockaddr */
struct client_ctx;
typedef struct {
const char *bind_host;
unsigned short bind_port;
unsigned int idle_timeout;
} server_config;
typedef struct {
unsigned int idle_timeout; /* Connection idle timeout in ms. */
uv_tcp_t tcp_handle;
uv_loop_t *loop;
} server_ctx;
typedef struct {
unsigned char rdstate;
unsigned char wrstate;
unsigned int idle_timeout;
struct client_ctx *client; /* Backlink to owning client context. */
ssize_t result;
union {
uv_handle_t handle;
uv_stream_t stream;
uv_tcp_t tcp;
uv_udp_t udp;
} handle;
uv_timer_t timer_handle; /* For detecting timeouts. */
uv_write_t write_req;
/* We only need one of these at a time so make them share memory. */
union {
uv_getaddrinfo_t addrinfo_req;
uv_connect_t connect_req;
uv_req_t req;
struct sockaddr_in6 addr6;
struct sockaddr_in addr4;
struct sockaddr addr;
char buf[2048]; /* Scratch space. Used to read data into. */
} t;
} conn;
typedef struct client_ctx {
unsigned int state;
server_ctx *sx; /* Backlink to owning server context. */
s5_ctx parser; /* The SOCKS protocol parser. */
conn incoming; /* Connection with the SOCKS client. */
conn outgoing; /* Connection with upstream. */
} client_ctx;
/* server.c */
int server_run(const server_config *cf, uv_loop_t *loop);
int can_auth_none(const server_ctx *sx, const client_ctx *cx);
int can_auth_passwd(const server_ctx *sx, const client_ctx *cx);
int can_access(const server_ctx *sx,
const client_ctx *cx,
const struct sockaddr *addr);
/* client.c */
void client_finish_init(server_ctx *sx, client_ctx *cx);
/* util.c */
#if defined(__GNUC__)
# define ATTRIBUTE_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
#else
# define ATTRIBUTE_FORMAT_PRINTF(a, b)
#endif
void pr_info(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void pr_warn(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void pr_err(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void *xmalloc(size_t size);
/* main.c */
const char *_getprogname(void);
/* getopt.c */
#if !HAVE_UNISTD_H
extern char *optarg;
int getopt(int argc, char **argv, const char *options);
#endif
/* ASSERT() is for debug checks, CHECK() for run-time sanity checks.
* DEBUG_CHECKS is for expensive debug checks that we only want to
* enable in debug builds but still want type-checked by the compiler
* in release builds.
*/
#if defined(NDEBUG)
# define ASSERT(exp)
# define CHECK(exp) do { if (!(exp)) abort(); } while (0)
# define DEBUG_CHECKS (0)
#else
# define ASSERT(exp) assert(exp)
# define CHECK(exp) assert(exp)
# define DEBUG_CHECKS (1)
#endif
#define UNREACHABLE() CHECK(!"Unreachable code reached.")
/* This macro looks complicated but it's not: it calculates the address
* of the embedding struct through the address of the embedded struct.
* In other words, if struct A embeds struct B, then we can obtain
* the address of A by taking the address of B and subtracting the
* field offset of B in A.
*/
#define CONTAINER_OF(ptr, type, field) \
((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field)))
#endif /* DEFS_H_ */
/* $NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
extern const char *_getprogname(void);
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int
getopt(nargc, nargv, ostr)
int nargc;
char * const nargv[];
const char *ostr;
{
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (optreset || *place == 0) { /* update scanning pointer */
optreset = 0;
place = nargv[optind];
if (optind >= nargc || *place++ != '-') {
/* Argument is absent or is not an option */
place = EMSG;
return (-1);
}
optopt = *place++;
if (optopt == '-' && *place == 0) {
/* "--" => end of options */
++optind;
place = EMSG;
return (-1);
}
if (optopt == 0) {
/* Solitary '-', treat as a '-' option
if the program (eg su) is looking for it. */
place = EMSG;
if (strchr(ostr, '-') == NULL)
return (-1);
optopt = '-';
}
} else
optopt = *place++;
/* See if option letter is one the caller wanted... */
if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
if (*place == 0)
++optind;
if (opterr && *ostr != ':')
(void)fprintf(stderr,
"%s: illegal option -- %c\n", _getprogname(),
optopt);
return (BADCH);
}
/* Does this option need an argument? */
if (oli[1] != ':') {
/* don't need argument */
optarg = NULL;
if (*place == 0)
++optind;
} else {
/* Option-argument is either the rest of this argument or the
entire next argument. */
if (*place)
optarg = place;
else if (nargc > ++optind)
optarg = nargv[optind];
else {
/* option-argument absent */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
_getprogname(), optopt);
return (BADCH);
}
place = EMSG;
++optind;
}
return (optopt); /* return option letter */
}
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h> /* getopt */
#endif
#define DEFAULT_BIND_HOST "127.0.0.1"
#define DEFAULT_BIND_PORT 1080
#define DEFAULT_IDLE_TIMEOUT (60 * 1000)
static void parse_opts(server_config *cf, int argc, char **argv);
static void usage(void);
static const char *progname = __FILE__; /* Reset in main(). */
int main(int argc, char **argv) {
server_config config;
int err;
progname = argv[0];
memset(&config, 0, sizeof(config));
config.bind_host = DEFAULT_BIND_HOST;
config.bind_port = DEFAULT_BIND_PORT;
config.idle_timeout = DEFAULT_IDLE_TIMEOUT;
parse_opts(&config, argc, argv);
err = server_run(&config, uv_default_loop());
if (err) {
exit(1);
}
return 0;
}
const char *_getprogname(void) {
return progname;
}
static void parse_opts(server_config *cf, int argc, char **argv) {
int opt;
while (-1 != (opt = getopt(argc, argv, "b:hp:"))) {
switch (opt) {
case 'b':
cf->bind_host = optarg;
break;
case 'p':
if (1 != sscanf(optarg, "%hu", &cf->bind_port)) {
pr_err("bad port number: %s", optarg);
usage();
}
break;
default:
usage();
}
}
}
static void usage(void) {
printf("Usage:\n"
"\n"
" %s [-b <address>] [-h] [-p <port>]\n"
"\n"
"Options:\n"
"\n"
" -b <hostname|address> Bind to this address or hostname.\n"
" Default: \"127.0.0.1\"\n"
" -h Show this help message.\n"
" -p <port> Bind to this port number. Default: 1080\n"
"",
progname);
exit(1);
}
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "s5.h"
#include <errno.h>
#include <stdint.h>
#include <stdlib.h> /* abort() */
#include <string.h> /* memset() */
enum {
s5_version,
s5_nmethods,
s5_methods,
s5_auth_pw_version,
s5_auth_pw_userlen,
s5_auth_pw_username,
s5_auth_pw_passlen,
s5_auth_pw_password,
s5_req_version,
s5_req_cmd,
s5_req_reserved,
s5_req_atyp,
s5_req_atyp_host,
s5_req_daddr,
s5_req_dport0,
s5_req_dport1,
s5_dead
};
void s5_init(s5_ctx *cx) {
memset(cx, 0, sizeof(*cx));
cx->state = s5_version;
}
s5_err s5_parse(s5_ctx *cx, uint8_t **data, size_t *size) {
s5_err err;
uint8_t *p;
uint8_t c;
size_t i;
size_t n;
p = *data;
n = *size;
i = 0;
while (i < n) {
c = p[i];
i += 1;
switch (cx->state) {
case s5_version:
if (c != 5) {
err = s5_bad_version;
goto out;
}
cx->state = s5_nmethods;
break;
case s5_nmethods:
cx->arg0 = 0;
cx->arg1 = c; /* Number of bytes to read. */
cx->state = s5_methods;
break;
case s5_methods:
if (cx->arg0 < cx->arg1) {
switch (c) {
case 0:
cx->methods |= S5_AUTH_NONE;
break;
case 1:
cx->methods |= S5_AUTH_GSSAPI;
break;
case 2:
cx->methods |= S5_AUTH_PASSWD;
break;
/* Ignore everything we don't understand. */
}
cx->arg0 += 1;
}
if (cx->arg0 == cx->arg1) {
err = s5_auth_select;
goto out;
}
break;
case s5_auth_pw_version:
if (c != 1) {
err = s5_bad_version;
goto out;
}
cx->state = s5_auth_pw_userlen;
break;
case s5_auth_pw_userlen:
cx->arg0 = 0;
cx->userlen = c;
cx->state = s5_auth_pw_username;
break;
case s5_auth_pw_username:
if (cx->arg0 < cx->userlen) {
cx->username[cx->arg0] = c;
cx->arg0 += 1;
}
if (cx->arg0 == cx->userlen) {
cx->username[cx->userlen] = '\0';
cx->state = s5_auth_pw_passlen;
}
break;
case s5_auth_pw_passlen:
cx->arg0 = 0;
cx->passlen = c;
cx->state = s5_auth_pw_password;
break;
case s5_auth_pw_password:
if (cx->arg0 < cx->passlen) {
cx->password[cx->arg0] = c;
cx->arg0 += 1;
}
if (cx->arg0 == cx->passlen) {
cx->password[cx->passlen] = '\0';
cx->state = s5_req_version;
err = s5_auth_verify;
goto out;
}
break;
case s5_req_version:
if (c != 5) {
err = s5_bad_version;
goto out;
}
cx->state = s5_req_cmd;
break;
case s5_req_cmd:
switch (c) {
case 1: /* TCP connect */
cx->cmd = s5_cmd_tcp_connect;
break;
case 3: /* UDP associate */
cx->cmd = s5_cmd_udp_assoc;
break;
default:
err = s5_bad_cmd;
goto out;
}
cx->state = s5_req_reserved;
break;
case s5_req_reserved:
cx->state = s5_req_atyp;
break;
case s5_req_atyp:
cx->arg0 = 0;
switch (c) {
case 1: /* IPv4, four octets. */
cx->state = s5_req_daddr;
cx->atyp = s5_atyp_ipv4;
cx->arg1 = 4;
break;
case 3: /* Hostname. First byte is length. */
cx->state = s5_req_atyp_host;
cx->atyp = s5_atyp_host;
cx->arg1 = 0;
break;
case 4: /* IPv6, sixteen octets. */
cx->state = s5_req_daddr;
cx->atyp = s5_atyp_ipv6;
cx->arg1 = 16;
break;
default:
err = s5_bad_atyp;
goto out;
}
break;
case s5_req_atyp_host:
cx->arg1 = c;
cx->state = s5_req_daddr;
break;
case s5_req_daddr:
if (cx->arg0 < cx->arg1) {
cx->daddr[cx->arg0] = c;
cx->arg0 += 1;
}
if (cx->arg0 == cx->arg1) {
cx->daddr[cx->arg1] = '\0';
cx->state = s5_req_dport0;
}
break;
case s5_req_dport0:
cx->dport = c << 8;
cx->state = s5_req_dport1;
break;
case s5_req_dport1:
cx->dport |= c;
cx->state = s5_dead;
err = s5_exec_cmd;
goto out;
case s5_dead:
break;
default:
abort();
}
}
err = s5_ok;
out:
*data = p + i;
*size = n - i;
return err;
}
unsigned int s5_auth_methods(const s5_ctx *cx) {
return cx->methods;
}
int s5_select_auth(s5_ctx *cx, s5_auth_method method) {
int err;
err = 0;
switch (method) {
case S5_AUTH_NONE:
cx->state = s5_req_version;
break;
case S5_AUTH_PASSWD:
cx->state = s5_auth_pw_version;
break;
default:
err = -EINVAL;
}
return err;
}
const char *s5_strerror(s5_err err) {
#define S5_ERR_GEN(_, name, errmsg) case s5_ ## name: return errmsg;
switch (err) {
S5_ERR_MAP(S5_ERR_GEN)
default: ; /* Silence s5_max_errors -Wswitch warning. */
}
#undef S5_ERR_GEN
return "Unknown error.";
}
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef S5_H_
#define S5_H_
#include <stddef.h>
#include <stdint.h>
#define S5_ERR_MAP(V) \
V(-1, bad_version, "Bad protocol version.") \
V(-2, bad_cmd, "Bad protocol command.") \
V(-3, bad_atyp, "Bad address type.") \
V(0, ok, "No error.") \
V(1, auth_select, "Select authentication method.") \
V(2, auth_verify, "Verify authentication.") \
V(3, exec_cmd, "Execute command.") \
typedef enum {
#define S5_ERR_GEN(code, name, _) s5_ ## name = code,
S5_ERR_MAP(S5_ERR_GEN)
#undef S5_ERR_GEN
s5_max_errors
} s5_err;
typedef enum {
S5_AUTH_NONE = 1 << 0,
S5_AUTH_GSSAPI = 1 << 1,
S5_AUTH_PASSWD = 1 << 2
} s5_auth_method;
typedef enum {
s5_auth_allow,
s5_auth_deny
} s5_auth_result;
typedef enum {
s5_atyp_ipv4,
s5_atyp_ipv6,
s5_atyp_host
} s5_atyp;
typedef enum {
s5_cmd_tcp_connect,
s5_cmd_tcp_bind,
s5_cmd_udp_assoc
} s5_cmd;
typedef struct {
uint32_t arg0; /* Scratch space for the state machine. */
uint32_t arg1; /* Scratch space for the state machine. */
uint8_t state;
uint8_t methods;
uint8_t cmd;
uint8_t atyp;
uint8_t userlen;
uint8_t passlen;
uint16_t dport;
uint8_t username[257];
uint8_t password[257];
uint8_t daddr[257]; /* TODO(bnoordhuis) Merge with username/password. */
} s5_ctx;
void s5_init(s5_ctx *ctx);
s5_err s5_parse(s5_ctx *cx, uint8_t **data, size_t *size);
/* Only call after s5_parse() has returned s5_want_auth_method. */
unsigned int s5_auth_methods(const s5_ctx *cx);
/* Call after s5_parse() has returned s5_want_auth_method. */
int s5_select_auth(s5_ctx *cx, s5_auth_method method);
const char *s5_strerror(s5_err err);
#endif /* S5_H_ */
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "defs.h"
#include <netinet/in.h> /* INET6_ADDRSTRLEN */
#include <stdlib.h>
#include <string.h>
#ifndef INET6_ADDRSTRLEN
# define INET6_ADDRSTRLEN 63
#endif
typedef struct {
uv_getaddrinfo_t getaddrinfo_req;
server_config config;
server_ctx *servers;
uv_loop_t *loop;
} server_state;
static void do_bind(uv_getaddrinfo_t *req, int status, struct addrinfo *ai);
static void on_connection(uv_stream_t *server, int status);
int server_run(const server_config *cf, uv_loop_t *loop) {
struct addrinfo hints;
server_state state;
int err;
memset(&state, 0, sizeof(state));
state.servers = NULL;
state.config = *cf;
state.loop = loop;
/* Resolve the address of the interface that we should bind to.
* The getaddrinfo callback starts the server and everything else.
*/
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
err = uv_getaddrinfo(loop,
&state.getaddrinfo_req,
do_bind,
cf->bind_host,
NULL,
&hints);
if (err != 0) {
pr_err("getaddrinfo: %s", uv_strerror(err));
return err;
}
/* Start the event loop. Control continues in do_bind(). */
if (uv_run(loop, UV_RUN_DEFAULT)) {
abort();
}
/* Please Valgrind. */
uv_loop_delete(loop);
free(state.servers);
return 0;
}
/* Bind a server to each address that getaddrinfo() reported. */
static void do_bind(uv_getaddrinfo_t *req, int status, struct addrinfo *addrs) {
char addrbuf[INET6_ADDRSTRLEN + 1];
unsigned int ipv4_naddrs;
unsigned int ipv6_naddrs;
server_state *state;
server_config *cf;
struct addrinfo *ai;
const void *addrv;
const char *what;
uv_loop_t *loop;
server_ctx *sx;
unsigned int n;
int err;
union {
struct sockaddr addr;
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
} s;
state = CONTAINER_OF(req, server_state, getaddrinfo_req);
loop = state->loop;
cf = &state->config;
if (status < 0) {
pr_err("getaddrinfo(\"%s\"): %s", cf->bind_host, uv_strerror(status));
uv_freeaddrinfo(addrs);
return;
}
ipv4_naddrs = 0;
ipv6_naddrs = 0;
for (ai = addrs; ai != NULL; ai = ai->ai_next) {
if (ai->ai_family == AF_INET) {
ipv4_naddrs += 1;
} else if (ai->ai_family == AF_INET6) {
ipv6_naddrs += 1;
}
}
if (ipv4_naddrs == 0 && ipv6_naddrs == 0) {
pr_err("%s has no IPv4/6 addresses", cf->bind_host);
uv_freeaddrinfo(addrs);
return;
}
state->servers =
xmalloc((ipv4_naddrs + ipv6_naddrs) * sizeof(state->servers[0]));
n = 0;
for (ai = addrs; ai != NULL; ai = ai->ai_next) {
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) {
continue;
}
if (ai->ai_family == AF_INET) {
s.addr4 = *(const struct sockaddr_in *) ai->ai_addr;
s.addr4.sin_port = htons(cf->bind_port);
addrv = &s.addr4.sin_addr;
} else if (ai->ai_family == AF_INET6) {
s.addr6 = *(const struct sockaddr_in6 *) ai->ai_addr;
s.addr6.sin6_port = htons(cf->bind_port);
addrv = &s.addr6.sin6_addr;
} else {
UNREACHABLE();
}
if (uv_inet_ntop(s.addr.sa_family, addrv, addrbuf, sizeof(addrbuf))) {
UNREACHABLE();
}
sx = state->servers + n;
sx->loop = loop;
sx->idle_timeout = state->config.idle_timeout;
CHECK(0 == uv_tcp_init(loop, &sx->tcp_handle));
what = "uv_tcp_bind";
err = uv_tcp_bind(&sx->tcp_handle, &s.addr, 0);
if (err == 0) {
what = "uv_listen";
err = uv_listen((uv_stream_t *) &sx->tcp_handle, 128, on_connection);
}
if (err != 0) {
pr_err("%s(\"%s:%hu\"): %s",
what,
addrbuf,
cf->bind_port,
uv_strerror(err));
while (n > 0) {
n -= 1;
uv_close((uv_handle_t *) (state->servers + n), NULL);
}
break;
}
pr_info("listening on %s:%hu", addrbuf, cf->bind_port);
n += 1;
}
uv_freeaddrinfo(addrs);
}
static void on_connection(uv_stream_t *server, int status) {
server_ctx *sx;
client_ctx *cx;
CHECK(status == 0);
sx = CONTAINER_OF(server, server_ctx, tcp_handle);
cx = xmalloc(sizeof(*cx));
CHECK(0 == uv_tcp_init(sx->loop, &cx->incoming.handle.tcp));
CHECK(0 == uv_accept(server, &cx->incoming.handle.stream));
client_finish_init(sx, cx);
}
int can_auth_none(const server_ctx *sx, const client_ctx *cx) {
return 1;
}
int can_auth_passwd(const server_ctx *sx, const client_ctx *cx) {
return 0;
}
int can_access(const server_ctx *sx,
const client_ctx *cx,
const struct sockaddr *addr) {
const struct sockaddr_in6 *addr6;
const struct sockaddr_in *addr4;
const uint32_t *p;
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
/* TODO(bnoordhuis) Implement proper access checks. For now, just reject
* traffic to localhost.
*/
if (addr->sa_family == AF_INET) {
addr4 = (const struct sockaddr_in *) addr;
d = ntohl(addr4->sin_addr.s_addr);
return (d >> 24) != 0x7F;
}
if (addr->sa_family == AF_INET6) {
addr6 = (const struct sockaddr_in6 *) addr;
p = (const uint32_t *) &addr6->sin6_addr.s6_addr;
a = ntohl(p[0]);
b = ntohl(p[1]);
c = ntohl(p[2]);
d = ntohl(p[3]);
if (a == 0 && b == 0 && c == 0 && d == 1) {
return 0; /* "::1" style address. */
}
if (a == 0 && b == 0 && c == 0xFFFF && (d >> 24) == 0x7F) {
return 0; /* "::ffff:127.x.x.x" style address. */
}
return 1;
}
return 0;
}
/* Copyright StrongLoop, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "defs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
static void pr_do(FILE *stream,
const char *label,
const char *fmt,
va_list ap);
void *xmalloc(size_t size) {
void *ptr;
ptr = malloc(size);
if (ptr == NULL) {
pr_err("out of memory, need %lu bytes", (unsigned long) size);
exit(1);
}
return ptr;
}
void pr_info(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
pr_do(stdout, "info", fmt, ap);
va_end(ap);
}
void pr_warn(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
pr_do(stderr, "warn", fmt, ap);
va_end(ap);
}
void pr_err(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
pr_do(stderr, "error", fmt, ap);
va_end(ap);
}
static void pr_do(FILE *stream,
const char *label,
const char *fmt,
va_list ap) {
char fmtbuf[1024];
vsnprintf(fmtbuf, sizeof(fmtbuf), fmt, ap);
fprintf(stream, "%s:%s: %s\n", _getprogname(), label, fmtbuf);
}
......@@ -34,52 +34,53 @@
# include <ApplicationServices/ApplicationServices.h>
#endif
#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
static int uv__pthread_setname_np(const char* name) {
char namebuf[64]; /* MAXTHREADNAMESIZE */
int err;
#if !TARGET_OS_IPHONE
static CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
const char*,
CFStringEncoding);
static CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
static void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
static void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
static CFTypeRef (*pLSGetCurrentApplicationASN)(void);
static OSStatus (*pLSSetApplicationInformationItem)(int,
CFTypeRef,
CFStringRef,
CFStringRef,
CFDictionaryRef*);
static void* application_services_handle;
static void* core_foundation_handle;
static CFBundleRef launch_services_bundle;
static CFStringRef* display_name_key;
static CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
static CFBundleRef (*pCFBundleGetMainBundle)(void);
static CFBundleRef hi_services_bundle;
static CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
static void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
void*);
UV_DESTRUCTOR(static void uv__set_process_title_platform_fini(void)) {
if (core_foundation_handle != NULL) {
dlclose(core_foundation_handle);
core_foundation_handle = NULL;
}
strncpy(namebuf, name, sizeof(namebuf) - 1);
namebuf[sizeof(namebuf) - 1] = '\0';
if (application_services_handle != NULL) {
dlclose(application_services_handle);
application_services_handle = NULL;
}
err = pthread_setname_np(namebuf);
if (err)
return UV__ERR(err);
return 0;
}
#endif /* !TARGET_OS_IPHONE */
void uv__set_process_title_platform_init(void) {
#if !TARGET_OS_IPHONE
int uv__set_process_title(const char* title) {
#if TARGET_OS_IPHONE
return uv__pthread_setname_np(title);
#else
CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
const char*,
CFStringEncoding);
CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
CFTypeRef (*pLSGetCurrentApplicationASN)(void);
OSStatus (*pLSSetApplicationInformationItem)(int,
CFTypeRef,
CFStringRef,
CFStringRef,
CFDictionaryRef*);
void* application_services_handle;
void* core_foundation_handle;
CFBundleRef launch_services_bundle;
CFStringRef* display_name_key;
CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
CFBundleRef (*pCFBundleGetMainBundle)(void);
CFBundleRef hi_services_bundle;
OSStatus (*pSetApplicationIsDaemon)(int);
CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
void*);
CFTypeRef asn;
int err;
err = UV_ENOENT;
application_services_handle = dlopen("/System/Library/Frameworks/"
"ApplicationServices.framework/"
"Versions/A/ApplicationServices",
......@@ -108,6 +109,8 @@ void uv__set_process_title_platform_init(void) {
goto out;
}
#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
launch_services_bundle =
pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices"));
......@@ -138,14 +141,13 @@ void uv__set_process_title_platform_init(void) {
"CFBundleGetInfoDictionary");
*(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle,
"CFBundleGetMainBundle");
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
goto out;
/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
hi_services_bundle =
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
err = UV_ENOENT;
if (hi_services_bundle == NULL)
goto out;
......@@ -159,38 +161,42 @@ void uv__set_process_title_platform_init(void) {
pCFBundleGetFunctionPointerForName(
launch_services_bundle,
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
if (pSetApplicationIsDaemon == NULL ||
pLSApplicationCheckIn == NULL ||
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
goto out;
}
/* Prevent crash when LaunchServices cannot be connected to. */
pSetApplicationIsDaemon(1);
return;
if (pSetApplicationIsDaemon(1) != noErr)
goto out;
out:
uv__set_process_title_platform_fini();
#endif /* !TARGET_OS_IPHONE */
}
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
/* Check into process manager?! */
pLSApplicationCheckIn(-2,
pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
void uv__set_process_title(const char* title) {
char namebuf[64 /* MAXTHREADNAMESIZE */];
asn = pLSGetCurrentApplicationASN();
#if !TARGET_OS_IPHONE
if (core_foundation_handle != NULL) {
CFTypeRef asn;
pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
pLSApplicationCheckIn(/* Magic value */ -2,
pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
asn = pLSGetCurrentApplicationASN();
pLSSetApplicationInformationItem(/* Magic value */ -2, asn,
*display_name_key, S(title), NULL);
err = UV_EINVAL;
if (pLSSetApplicationInformationItem(-2, /* Magic value. */
asn,
*display_name_key,
S(title),
NULL) != noErr) {
goto out;
}
#endif /* !TARGET_OS_IPHONE */
uv__strscpy(namebuf, title, sizeof(namebuf));
pthread_setname_np(namebuf);
uv__pthread_setname_np(title); /* Don't care if it fails. */
err = 0;
out:
if (core_foundation_handle != NULL)
dlclose(core_foundation_handle);
if (application_services_handle != NULL)
dlclose(application_services_handle);
return err;
#endif /* !TARGET_OS_IPHONE */
}
......@@ -110,7 +110,7 @@ uint64_t uv_get_total_memory(void) {
int which[] = {CTL_HW, HW_MEMSIZE};
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info;
......@@ -127,7 +127,7 @@ void uv_loadavg(double avg[3]) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0) < 0) return;
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
......@@ -162,7 +162,7 @@ int uv_uptime(double* uptime) {
size_t size = sizeof(info);
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
now = time(NULL);
......
......@@ -95,7 +95,7 @@ int uv_exepath(char* buffer, size_t* size) {
mib[3] = -1;
abspath_size = sizeof abspath;
if (sysctl(mib, 4, abspath, &abspath_size, NULL, 0))
if (sysctl(mib, ARRAY_SIZE(mib), abspath, &abspath_size, NULL, 0))
return UV__ERR(errno);
assert(abspath_size > 0);
......@@ -130,7 +130,7 @@ uint64_t uv_get_total_memory(void) {
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info;
......@@ -147,7 +147,7 @@ void uv_loadavg(double avg[3]) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0) < 0) return;
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
......@@ -168,7 +168,7 @@ int uv_resident_set_memory(size_t* rss) {
kinfo_size = sizeof(kinfo);
if (sysctl(mib, 4, &kinfo, &kinfo_size, NULL, 0))
if (sysctl(mib, ARRAY_SIZE(mib), &kinfo, &kinfo_size, NULL, 0))
return UV__ERR(errno);
page_size = getpagesize();
......
......@@ -259,10 +259,29 @@ static ssize_t uv__fs_mkdtemp(uv_fs_t* req) {
}
static int (*uv__mkostemp)(char*, int);
static void uv__mkostemp_initonce(void) {
/* z/os doesn't have RTLD_DEFAULT but that's okay
* because it doesn't have mkostemp(O_CLOEXEC) either.
*/
#ifdef RTLD_DEFAULT
uv__mkostemp = (int (*)(char*, int)) dlsym(RTLD_DEFAULT, "mkostemp");
/* We don't care about errors, but we do want to clean them up.
* If there has been no error, then dlerror() will just return
* NULL.
*/
dlerror();
#endif /* RTLD_DEFAULT */
}
static int uv__fs_mkstemp(uv_fs_t* req) {
static uv_once_t once = UV_ONCE_INIT;
int r;
#ifdef O_CLOEXEC
int (*mkostemp_function)(char*, int);
static int no_cloexec_support;
#endif
static const char pattern[] = "XXXXXX";
......@@ -284,30 +303,23 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
return -1;
}
#ifdef O_CLOEXEC
if (no_cloexec_support == 0) {
*(int**)(&mkostemp_function) = dlsym(RTLD_DEFAULT, "mkostemp");
/* We don't care about errors, but we do want to clean them up.
If there has been no error, then dlerror() will just return
NULL. */
dlerror();
uv_once(&once, uv__mkostemp_initonce);
if (mkostemp_function != NULL) {
r = mkostemp_function(path, O_CLOEXEC);
#ifdef O_CLOEXEC
if (no_cloexec_support == 0 && uv__mkostemp != NULL) {
r = uv__mkostemp(path, O_CLOEXEC);
if (r >= 0)
return r;
if (r >= 0)
return r;
/* If mkostemp() returns EINVAL, it means the kernel doesn't
support O_CLOEXEC, so we just fallback to mkstemp() below. */
if (errno != EINVAL)
return r;
/* If mkostemp() returns EINVAL, it means the kernel doesn't
support O_CLOEXEC, so we just fallback to mkstemp() below. */
if (errno != EINVAL)
return r;
/* We set the static variable so that next calls don't even
try to use mkostemp. */
no_cloexec_support = 1;
}
/* We set the static variable so that next calls don't even
try to use mkostemp. */
no_cloexec_support = 1;
}
#endif /* O_CLOEXEC */
......@@ -1125,7 +1137,28 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
if (fchmod(dstfd, src_statsbuf.st_mode) == -1) {
err = UV__ERR(errno);
#ifdef __linux__
if (err != UV_EPERM)
goto out;
{
struct statfs s;
/* fchmod() on CIFS shares always fails with EPERM unless the share is
* mounted with "noperm". As fchmod() is a meaningless operation on such
* shares anyway, detect that condition and squelch the error.
*/
if (fstatfs(dstfd, &s) == -1)
goto out;
if (s.f_type != /* CIFS */ 0xFF534D42u)
goto out;
}
err = 0;
#else /* !__linux__ */
goto out;
#endif /* !__linux__ */
}
#ifdef FICLONE
......
......@@ -359,9 +359,19 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
have_signals = 0;
nevents = 0;
assert(loop->watchers != NULL);
loop->watchers[loop->nwatchers] = (void*) events;
loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;
{
/* Squelch a -Waddress-of-packed-member warning with gcc >= 9. */
union {
struct epoll_event* events;
uv__io_t* watchers;
} x;
x.events = events;
assert(loop->watchers != NULL);
loop->watchers[loop->nwatchers] = x.watchers;
loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;
}
for (i = 0; i < nfds; i++) {
pe = events + i;
fd = pe->data.fd;
......
......@@ -55,7 +55,7 @@ void uv_loadavg(double avg[3]) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) == -1) return;
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0) == -1) return;
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
......@@ -102,7 +102,7 @@ uint64_t uv_get_free_memory(void) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_UVMEXP};
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
......@@ -119,7 +119,7 @@ uint64_t uv_get_total_memory(void) {
#endif
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info;
......@@ -167,7 +167,7 @@ int uv_uptime(double* uptime) {
size_t size = sizeof(info);
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
now = time(NULL);
......
......@@ -50,7 +50,7 @@ void uv_loadavg(double avg[3]) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_LOADAVG};
if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return;
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0) < 0) return;
avg[0] = (double) info.ldavg[0] / info.fscale;
avg[1] = (double) info.ldavg[1] / info.fscale;
......@@ -81,7 +81,7 @@ int uv_exepath(char* buffer, size_t* size) {
mib[1] = KERN_PROC_ARGS;
mib[2] = mypid;
mib[3] = KERN_PROC_ARGV;
if (sysctl(mib, 4, argsbuf, &argsbuf_size, NULL, 0) == 0) {
if (sysctl(mib, ARRAY_SIZE(mib), argsbuf, &argsbuf_size, NULL, 0) == 0) {
break;
}
if (errno != ENOMEM) {
......@@ -117,7 +117,7 @@ uint64_t uv_get_free_memory(void) {
size_t size = sizeof(info);
int which[] = {CTL_VM, VM_UVMEXP};
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
......@@ -129,7 +129,7 @@ uint64_t uv_get_total_memory(void) {
int which[] = {CTL_HW, HW_PHYSMEM64};
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
return (uint64_t) info;
......@@ -154,7 +154,7 @@ int uv_resident_set_memory(size_t* rss) {
mib[4] = sizeof(struct kinfo_proc);
mib[5] = 1;
if (sysctl(mib, 6, &kinfo, &size, NULL, 0) < 0)
if (sysctl(mib, ARRAY_SIZE(mib), &kinfo, &size, NULL, 0) < 0)
return UV__ERR(errno);
*rss = kinfo.p_vm_rssize * page_size;
......@@ -168,7 +168,7 @@ int uv_uptime(double* uptime) {
size_t size = sizeof(info);
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
return UV__ERR(errno);
now = time(NULL);
......@@ -184,18 +184,19 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
uint64_t info[CPUSTATES];
char model[512];
int numcpus = 1;
int which[] = {CTL_HW,HW_MODEL,0};
int which[] = {CTL_HW,HW_MODEL};
int percpu[] = {CTL_HW,HW_CPUSPEED,0};
size_t size;
int i, j;
uv_cpu_info_t* cpu_info;
size = sizeof(model);
if (sysctl(which, 2, &model, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &model, &size, NULL, 0))
return UV__ERR(errno);
which[1] = HW_NCPUONLINE;
size = sizeof(numcpus);
if (sysctl(which, 2, &numcpus, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(which), &numcpus, &size, NULL, 0))
return UV__ERR(errno);
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
......@@ -205,18 +206,17 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
i = 0;
*count = numcpus;
which[1] = HW_CPUSPEED;
size = sizeof(cpuspeed);
if (sysctl(which, 2, &cpuspeed, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(percpu), &cpuspeed, &size, NULL, 0))
goto error;
size = sizeof(info);
which[0] = CTL_KERN;
which[1] = KERN_CPTIME2;
percpu[0] = CTL_KERN;
percpu[1] = KERN_CPTIME2;
for (i = 0; i < numcpus; i++) {
which[2] = i;
percpu[2] = i;
size = sizeof(info);
if (sysctl(which, 3, &info, &size, NULL, 0))
if (sysctl(which, ARRAY_SIZE(percpu), &info, &size, NULL, 0))
goto error;
cpu_info = &(*cpu_infos)[i];
......
......@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
extern void uv__set_process_title_platform_init(void);
extern void uv__set_process_title(const char* title);
static uv_mutex_t process_title_mutex;
......@@ -39,9 +38,6 @@ static struct {
static void init_process_title_mutex_once(void) {
uv_mutex_init(&process_title_mutex);
#ifdef __APPLE__
uv__set_process_title_platform_init();
#endif
}
......
......@@ -565,6 +565,7 @@ static void uv__signal_stop(uv_signal_t* handle) {
if (first_oneshot && !rem_oneshot) {
ret = uv__signal_register_handler(handle->signum, 1);
assert(ret == 0);
(void)ret;
}
}
......
......@@ -1048,7 +1048,12 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
}
#define UV__CMSG_FD_COUNT 64
#if defined(__PASE__)
/* on IBMi PASE the control message length can not exceed 256. */
# define UV__CMSG_FD_COUNT 60
#else
# define UV__CMSG_FD_COUNT 64
#endif
#define UV__CMSG_FD_SIZE (UV__CMSG_FD_COUNT * sizeof(int))
......
......@@ -139,7 +139,7 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int unused) {
* slave device.
*/
if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
r = uv__open_cloexec(path, mode);
r = uv__open_cloexec(path, mode | O_NOCTTY);
else
r = -1;
......@@ -293,7 +293,14 @@ uv_handle_type uv_guess_handle(uv_file file) {
if (file < 0)
return UV_UNKNOWN_HANDLE;
#if defined(__PASE__)
/* On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
* Use ioctl() instead to identify whether it's actually a TTY.
*/
if (!ioctl(file, TXISATTY + 0x81, NULL) || errno != ENOTTY)
#else
if (isatty(file))
#endif
return UV_TTY;
if (fstat(file, &s))
......
......@@ -321,8 +321,13 @@ void uv__loop_close(uv_loop_t* loop) {
uv__loops_remove(loop);
/* close the async handle without needing an extra loop iteration */
assert(!loop->wq_async.async_sent);
/* Close the async handle without needing an extra loop iteration.
* We might have a pending message, but we're just going to destroy the IOCP
* soon, so we can just discard it now without the usual risk of a getting
* another notification from GetQueuedCompletionStatusEx after calling the
* close_cb (which we also skip defining). We'll assert later that queue was
* actually empty and all reqs handled. */
loop->wq_async.async_sent = 0;
loop->wq_async.close_cb = NULL;
uv__handle_closing(&loop->wq_async);
uv__handle_close(&loop->wq_async);
......
......@@ -1625,28 +1625,16 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
/* We can only write 8k characters at a time. Windows can't handle much more
* characters in a single console write anyway. */
WCHAR utf16_buf[MAX_CONSOLE_CHAR];
WCHAR* utf16_buffer;
DWORD utf16_buf_used = 0;
unsigned int i, len, max_len, pos;
int allocate = 0;
#define FLUSH_TEXT() \
do { \
pos = 0; \
do { \
len = utf16_buf_used - pos; \
if (len > MAX_CONSOLE_CHAR) \
len = MAX_CONSOLE_CHAR; \
uv_tty_emit_text(handle, &utf16_buffer[pos], len, error); \
pos += len; \
} while (pos < utf16_buf_used); \
if (allocate) { \
uv__free(utf16_buffer); \
allocate = 0; \
utf16_buffer = utf16_buf; \
} \
utf16_buf_used = 0; \
} while (0)
unsigned int i;
#define FLUSH_TEXT() \
do { \
if (utf16_buf_used > 0) { \
uv_tty_emit_text(handle, utf16_buf, utf16_buf_used, error); \
utf16_buf_used = 0; \
} \
} while (0)
#define ENSURE_BUFFER_SPACE(wchars_needed) \
if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \
......@@ -1663,48 +1651,12 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
* keep parsing the buffer so we leave the parser in a consistent state. */
*error = ERROR_SUCCESS;
utf16_buffer = utf16_buf;
uv_sem_wait(&uv_tty_output_lock);
for (i = 0; i < nbufs; i++) {
uv_buf_t buf = bufs[i];
unsigned int j;
if (uv__vterm_state == UV_TTY_SUPPORTED && buf.len > 0) {
utf16_buf_used = MultiByteToWideChar(CP_UTF8,
0,
buf.base,
buf.len,
NULL,
0);
if (utf16_buf_used == 0) {
*error = GetLastError();
break;
}
max_len = (utf16_buf_used + 1) * sizeof(WCHAR);
allocate = max_len > MAX_CONSOLE_CHAR;
if (allocate)
utf16_buffer = uv__malloc(max_len);
if (!MultiByteToWideChar(CP_UTF8,
0,
buf.base,
buf.len,
utf16_buffer,
utf16_buf_used)) {
if (allocate)
uv__free(utf16_buffer);
*error = GetLastError();
break;
}
FLUSH_TEXT();
continue;
}
for (j = 0; j < buf.len; j++) {
unsigned char c = buf.base[j];
......@@ -1761,7 +1713,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
}
/* Parse vt100/ansi escape codes */
if (ansi_parser_state == ANSI_NORMAL) {
if (uv__vterm_state == UV_TTY_SUPPORTED) {
/* Pass through escape codes if conhost supports them. */
} else if (ansi_parser_state == ANSI_NORMAL) {
switch (utf8_codepoint) {
case '\033':
ansi_parser_state = ANSI_ESCAPE_SEEN;
......
......@@ -74,11 +74,6 @@ BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target) {
}
static int error_means_no_support(DWORD error) {
return error == WSAEPROTONOSUPPORT || error == WSAESOCKTNOSUPPORT ||
error == WSAEPFNOSUPPORT || error == WSAEAFNOSUPPORT;
}
void uv_winsock_init(void) {
WSADATA wsa_data;
......@@ -105,50 +100,36 @@ void uv_winsock_init(void) {
uv_fatal_error(errorno, "WSAStartup");
}
/* Detect non-IFS LSPs */
/* Try to detect non-IFS LSPs */
uv_tcp_non_ifs_lsp_ipv4 = 1;
dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (dummy != INVALID_SOCKET) {
opt_len = (int) sizeof protocol_info;
if (getsockopt(dummy,
SOL_SOCKET,
SO_PROTOCOL_INFOW,
(char*) &protocol_info,
&opt_len) == SOCKET_ERROR)
uv_fatal_error(WSAGetLastError(), "getsockopt");
if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES))
uv_tcp_non_ifs_lsp_ipv4 = 1;
if (closesocket(dummy) == SOCKET_ERROR)
uv_fatal_error(WSAGetLastError(), "closesocket");
} else if (!error_means_no_support(WSAGetLastError())) {
/* Any error other than "socket type not supported" is fatal. */
uv_fatal_error(WSAGetLastError(), "socket");
&opt_len) == 0) {
if (protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)
uv_tcp_non_ifs_lsp_ipv4 = 0;
}
closesocket(dummy);
}
/* Detect IPV6 support and non-IFS LSPs */
/* Try to detect IPV6 support and non-IFS LSPs */
uv_tcp_non_ifs_lsp_ipv6 = 1;
dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP);
if (dummy != INVALID_SOCKET) {
opt_len = (int) sizeof protocol_info;
if (getsockopt(dummy,
SOL_SOCKET,
SO_PROTOCOL_INFOW,
(char*) &protocol_info,
&opt_len) == SOCKET_ERROR)
uv_fatal_error(WSAGetLastError(), "getsockopt");
if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES))
uv_tcp_non_ifs_lsp_ipv6 = 1;
if (closesocket(dummy) == SOCKET_ERROR)
uv_fatal_error(WSAGetLastError(), "closesocket");
} else if (!error_means_no_support(WSAGetLastError())) {
/* Any error other than "socket type not supported" is fatal. */
uv_fatal_error(WSAGetLastError(), "socket");
&opt_len) == 0) {
if (protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)
uv_tcp_non_ifs_lsp_ipv6 = 0;
}
closesocket(dummy);
}
}
......
......@@ -51,6 +51,13 @@ static int maybe_run_test(int argc, char **argv);
int main(int argc, char **argv) {
#ifndef _WIN32
if (0 == geteuid() && NULL == getenv("UV_RUN_AS_ROOT")) {
fprintf(stderr, "The libuv test suite cannot be run as root.\n");
return EXIT_FAILURE;
}
#endif
if (platform_init(argc, argv))
return EXIT_FAILURE;
......
......@@ -215,7 +215,7 @@ UNUSED static int can_ipv6(void) {
return supported;
}
#if defined(__CYGWIN__) || defined(__MSYS__)
#if defined(__CYGWIN__) || defined(__MSYS__) || defined(__PASE__)
# define NO_FS_EVENTS "Filesystem watching not supported on this platform."
#endif
......
......@@ -42,13 +42,17 @@ TEST_IMPL(dlerror) {
msg = uv_dlerror(&lib);
ASSERT(msg != NULL);
#ifndef __OpenBSD__
ASSERT(strstr(msg, path) != NULL);
#endif
ASSERT(strstr(msg, dlerror_no_error) == NULL);
/* Should return the same error twice in a row. */
msg = uv_dlerror(&lib);
ASSERT(msg != NULL);
#ifndef __OpenBSD__
ASSERT(strstr(msg, path) != NULL);
#endif
ASSERT(strstr(msg, dlerror_no_error) == NULL);
uv_dlclose(&lib);
......
......@@ -343,7 +343,8 @@ static void statfs_cb(uv_fs_t* req) {
ASSERT(req->ptr != NULL);
stats = req->ptr;
#if defined(_WIN32) || defined(__sun) || defined(_AIX) || defined(__MVS__)
#if defined(_WIN32) || defined(__sun) || defined(_AIX) || defined(__MVS__) || \
defined(__OpenBSD__) || defined(__NetBSD__)
ASSERT(stats->f_type == 0);
#else
ASSERT(stats->f_type > 0);
......@@ -1322,6 +1323,25 @@ TEST_IMPL(fs_fstat) {
file = req.result;
uv_fs_req_cleanup(&req);
#ifndef _WIN32
ASSERT(0 == fstat(file, &t));
ASSERT(0 == uv_fs_fstat(NULL, &req, file, NULL));
ASSERT(req.result == 0);
s = req.ptr;
# if defined(__APPLE__)
ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec);
# elif defined(__linux__)
/* If statx() is supported, the birth time should be equal to the change time
* because we just created the file. On older kernels, it's set to zero.
*/
ASSERT(s->st_birthtim.tv_sec == 0 ||
s->st_birthtim.tv_sec == t.st_ctim.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == 0 ||
s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec);
# endif
#endif
iov = uv_buf_init(test_buf, sizeof(test_buf));
r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL);
ASSERT(r == sizeof(test_buf));
......@@ -1356,10 +1376,6 @@ TEST_IMPL(fs_fstat) {
ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec);
ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec);
ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec);
ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec);
ASSERT(s->st_flags == t.st_flags);
ASSERT(s->st_gen == t.st_gen);
#elif defined(_AIX)
ASSERT(s->st_atim.tv_sec == t.st_atime);
ASSERT(s->st_atim.tv_nsec == 0);
......@@ -1394,8 +1410,6 @@ TEST_IMPL(fs_fstat) {
defined(__NetBSD__)
ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec);
ASSERT(s->st_flags == t.st_flags);
ASSERT(s->st_gen == t.st_gen);
# endif
#else
ASSERT(s->st_atim.tv_sec == t.st_atime);
......@@ -1407,14 +1421,10 @@ TEST_IMPL(fs_fstat) {
#endif
#endif
#if defined(__linux__)
/* If statx() is supported, the birth time should be equal to the change time
* because we just created the file. On older kernels, it's set to zero.
*/
ASSERT(s->st_birthtim.tv_sec == 0 ||
s->st_birthtim.tv_sec == t.st_ctim.tv_sec);
ASSERT(s->st_birthtim.tv_nsec == 0 ||
s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec);
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
ASSERT(s->st_flags == t.st_flags);
ASSERT(s->st_gen == t.st_gen);
#else
ASSERT(s->st_flags == 0);
ASSERT(s->st_gen == 0);
#endif
......
......@@ -58,9 +58,13 @@ TEST_IMPL(platform_output) {
#endif
err = uv_uptime(&uptime);
#if defined(__PASE__)
ASSERT(err == UV_ENOSYS);
#else
ASSERT(err == 0);
ASSERT(uptime > 0);
printf("uv_uptime: %f\n", uptime);
#endif
err = uv_getrusage(&rusage);
ASSERT(err == 0);
......
......@@ -31,11 +31,9 @@
# define NO_INLINE __attribute__ ((noinline))
#endif
uv_os_sock_t sock;
uv_poll_t handle;
#ifdef _WIN32
static uv_os_sock_t sock;
static uv_poll_t handle;
static int close_cb_called = 0;
......
......@@ -25,10 +25,9 @@
#include "uv.h"
#include "task.h"
uv_os_sock_t sock;
uv_poll_t handle;
#ifdef _WIN32
static uv_os_sock_t sock;
static uv_poll_t handle;
static int close_cb_called = 0;
......
......@@ -25,7 +25,11 @@
#include <string.h>
#define NUM_ITERATIONS 50
#ifdef __APPLE__
# define NUM_ITERATIONS 5
#else
# define NUM_ITERATIONS 50
#endif
static const char* titles[] = {
"8L2NY0Kdj0XyNFZnmUZigIOfcWjyNr0SkMmUhKw99VLUsZFrvCQQC3XIRfNR8pjyMjXObllled",
......@@ -68,7 +72,7 @@ TEST_IMPL(process_title_threadsafe) {
int i;
#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \
defined(__MVS__)
defined(__MVS__) || defined(__PASE__)
RETURN_SKIP("uv_(get|set)_process_title is not implemented.");
#endif
......
......@@ -60,7 +60,8 @@ static void uv_get_process_title_edge_cases(void) {
TEST_IMPL(process_title) {
#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__)
#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \
defined(__PASE__)
RETURN_SKIP("uv_(get|set)_process_title is not implemented.");
#endif
......
......@@ -232,6 +232,7 @@ static void thread_check_stack(void* arg) {
if (expected == 0)
expected = (size_t)lim.rlim_cur;
ASSERT(stack_size >= expected);
ASSERT(0 == pthread_attr_destroy(&attr));
#endif
}
......
......@@ -126,8 +126,10 @@ static void cl_recv_cb(uv_udp_t* handle,
r = uv_udp_set_membership(&server, MULTICAST_ADDR, NULL, UV_LEAVE_GROUP);
ASSERT(r == 0);
#if !defined(__OpenBSD__) && !defined(__NetBSD__)
r = uv_udp_set_source_membership(&server, MULTICAST_ADDR, NULL, source_addr, UV_JOIN_GROUP);
ASSERT(r == 0);
#endif
r = do_send(&req_ss);
ASSERT(r == 0);
......
......@@ -93,7 +93,7 @@
'-Wno-unused-parameter',
'-Wstrict-prototypes',
],
'OTHER_CFLAGS': [ '-g', '--std=gnu89', '-pedantic' ],
'OTHER_CFLAGS': [ '-g', '--std=gnu89' ],
},
'conditions': [
[ 'OS=="win"', {
......@@ -217,7 +217,6 @@
'-fvisibility=hidden',
'-g',
'--std=gnu89',
'-pedantic',
'-Wall',
'-Wextra',
'-Wno-unused-parameter',
......
......@@ -80,7 +80,7 @@ function get_netstring()
function get_libuv()
{
GIT_REPO="https://github.com/libuv/libuv.git"
GIT_TAG="v1.34.0"
GIT_TAG="v1.34.1"
DEST="deps/libuv"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论