Alien-uv

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

libuv/test/test-homedir.c
libuv/test/test-hrtime.c
libuv/test/test-idle.c
libuv/test/test-idna.c
libuv/test/test-ip4-addr.c
libuv/test/test-ip6-addr.c
libuv/test/test-ipc-heavy-traffic-deadlock-bug.c
libuv/test/test-ipc-send-recv.c
libuv/test/test-ipc.c
libuv/test/test-list.h
libuv/test/test-loop-alive.c
libuv/test/test-loop-close.c
libuv/test/test-loop-configure.c
libuv/test/test-loop-handles.c
libuv/test/test-loop-stop.c
libuv/test/test-loop-time.c
libuv/test/test-multiple-listen.c
libuv/test/test-mutexes.c
libuv/test/test-osx-select.c
libuv/test/test-pass-always.c
libuv/test/test-ping-pong.c

libuv/CMakeLists.txt  view on Meta::CPAN

    test/test-homedir.c
    test/test-hrtime.c
    test/test-idle.c
    test/test-idna.c
    test/test-ip4-addr.c
    test/test-ip6-addr.c
    test/test-ip6-addr.c
    test/test-ipc-heavy-traffic-deadlock-bug.c
    test/test-ipc-send-recv.c
    test/test-ipc.c
    test/test-loop-alive.c
    test/test-loop-close.c
    test/test-loop-configure.c
    test/test-loop-handles.c
    test/test-loop-stop.c
    test/test-loop-time.c
    test/test-multiple-listen.c
    test/test-mutexes.c
    test/test-osx-select.c
    test/test-pass-always.c
    test/test-ping-pong.c

libuv/ChangeLog  view on Meta::CPAN


* doc: fix IRC URL in CONTRIBUTING.md (Matt Harrison)


2017.11.25, Version 1.17.0 (Stable), 1344d2bb82e195d0eafc0b40ba103f18dfd04cc5

Changes since version 1.16.1:

* unix: avoid malloc() call in uv_spawn() (Ben Noordhuis)

* doc: clarify the description of uv_loop_alive() (Ed Schouten)

* win: map UV_FS_O_EXLOCK to a share mode of 0 (Joran Dirk Greef)

* win: fix build on case-sensitive file systems (Ben Noordhuis)

* win: fix test runner build with mingw64 (Ben Noordhuis)

* win: remove unused variable in test/test-fs.c (Ben Noordhuis)

* zos: add strnlen() implementation (jBarz)

libuv/ChangeLog  view on Meta::CPAN



2013.12.32, Version 0.11.17 (Unstable), 589c224d4c2e79fec65db01d361948f1e4976858

Changes since version 0.11.16:

* stream: allow multiple buffers for uv_try_write (Fedor Indutny)

* unix: fix a possible memory leak in uv_fs_readdir (Alex Crichton)

* unix, windows: add uv_loop_alive() function (Sam Roberts)

* windows: avoid assertion failure when pipe server is closed (Bert Belder)

* osx: Fix a possible segfault in uv__io_poll (Alex Crichton)

* stream: fix uv__stream_osx_select (Fedor Indutny)


2013.12.14, Version 0.11.16 (Unstable), ae0ed8c49d0d313c935c22077511148b6e8408a4

libuv/Makefile.am  view on Meta::CPAN

                         test/test-hrtime.c \
                         test/test-idle.c \
                         test/test-idna.c \
                         test/test-ip4-addr.c \
                         test/test-ip6-addr.c \
                         test/test-ipc-heavy-traffic-deadlock-bug.c \
                         test/test-ipc-send-recv.c \
                         test/test-ipc.c \
                         test/test-list.h \
                         test/test-loop-handles.c \
                         test/test-loop-alive.c \
                         test/test-loop-close.c \
                         test/test-loop-stop.c \
                         test/test-loop-time.c \
                         test/test-loop-configure.c \
                         test/test-multiple-listen.c \
                         test/test-mutexes.c \
                         test/test-osx-select.c \
                         test/test-pass-always.c \
                         test/test-ping-pong.c \
                         test/test-pipe-bind-error.c \

libuv/docs/src/design.rst  view on Meta::CPAN

stages of a loop iteration:

.. image:: static/loop_iteration.png
    :scale: 75%
    :align: center


#. The loop concept of 'now' is updated. The event loop caches the current time at the start of
   the event loop tick in order to reduce the number of time-related system calls.

#. If the loop is *alive*  an iteration is started, otherwise the loop will exit immediately. So,
   when is a loop considered to be *alive*? If a loop has active and ref'd handles, active
   requests or closing handles it's considered to be *alive*.

#. Due timers are run. All active timers scheduled for a time before the loop's concept of *now*
   get their callbacks called.

#. Pending callbacks are called. All I/O callbacks are called right after polling for I/O, for the
   most part. There are cases, however, in which calling such a callback is deferred for the next
   loop iteration. If the previous iteration deferred any I/O callback it will be run at this point.

#. Idle handle callbacks are called. Despite the unfortunate name, idle handles are run on every
   loop iteration, if they are active.

libuv/docs/src/design.rst  view on Meta::CPAN


#. Close callbacks are called. If a handle was closed by calling :c:func:`uv_close` it will
   get the close callback called.

#. Special case in case the loop was run with ``UV_RUN_ONCE``, as it implies forward progress.
   It's possible that no I/O callbacks were fired after blocking for I/O, but some time has passed
   so there might be timers which are due, those timers get their callbacks called.

#. Iteration ends. If the loop was run with ``UV_RUN_NOWAIT`` or ``UV_RUN_ONCE`` modes the
   iteration ends and :c:func:`uv_run` will return. If the loop was run with ``UV_RUN_DEFAULT``
   it will continue from the start if it's still *alive*, otherwise it will also end.


.. important::
    libuv uses a thread pool to make asynchronous file I/O operations possible, but
    network I/O is **always** performed in a single thread, each loop's thread.

.. note::
    While the polling mechanism is different, libuv makes the execution model consistent
    across Unix systems and Windows.

libuv/docs/src/guide/utilities.rst  view on Meta::CPAN


The event loop only runs as long as there are active handles. This system
works by having every handle increase the reference count of the event loop
when it is started and decreasing the reference count when stopped. It is also
possible to manually change the reference count of handles using::

    void uv_ref(uv_handle_t*);
    void uv_unref(uv_handle_t*);

These functions can be used to allow a loop to exit even when a watcher is
active or to use custom objects to keep the loop alive.

The latter can be used with interval timers. You might have a garbage collector
which runs every X seconds, or your network service might send a heartbeat to
others periodically, but you don't want to have to stop them along all clean
exit paths or error scenarios. Or you want the program to exit when all your
other watchers are done. In that case just unref the timer immediately after
creation so that if it is the only watcher running then ``uv_run`` will still
exit.

This is also used in node.js where some libuv methods are being bubbled up to

libuv/docs/src/loop.rst  view on Meta::CPAN

      there are no pending callbacks. Returns zero when done (no active handles
      or requests left), or non-zero if more callbacks are expected (meaning
      you should run the event loop again sometime in the future).
    - UV_RUN_NOWAIT: Poll for i/o once but don't block if there are no
      pending callbacks. Returns zero if done (no active handles
      or requests left), or non-zero if more callbacks are expected (meaning
      you should run the event loop again sometime in the future).

    :c:func:`uv_run` is not reentrant. It must not be called from a callback.

.. c:function:: int uv_loop_alive(const uv_loop_t* loop)

    Returns non-zero if there are referenced active handles, active
    requests or closing handles in the loop.

.. c:function:: void uv_stop(uv_loop_t* loop)

    Stop the event loop, causing :c:func:`uv_run` to end as soon as
    possible. This will happen not sooner than the next loop iteration.
    If this function was called before blocking for i/o, the loop won't block
    for i/o on this iteration.

libuv/docs/src/process.rst  view on Meta::CPAN

            /*
            * Do not wrap any arguments in quotes, or perform any other escaping, when
            * converting the argument list into a command line string. This option is
            * only meaningful on Windows systems. On Unix it is silently ignored.
            */
            UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
            /*
            * Spawn the child process in a detached state - this will make it a process
            * group leader, and will effectively enable the child to keep running after
            * the parent exits. Note that the child process will still keep the
            * parent's event loop alive unless the parent process calls uv_unref() on
            * the child's process handle.
            */
            UV_PROCESS_DETACHED = (1 << 3),
            /*
            * Hide the subprocess window that would normally be created. This option is
            * only meaningful on Windows systems. On Unix it is silently ignored.
            */
            UV_PROCESS_WINDOWS_HIDE = (1 << 4),
            /*
            * Hide the subprocess console window that would normally be created. This 

libuv/docs/src/tcp.rst  view on Meta::CPAN

    .. versionchanged:: 1.2.1 the file descriptor is set to non-blocking mode.

    .. note::
        The passed file descriptor or SOCKET is not checked for its type, but
        it's required that it represents a valid stream socket.

.. c:function:: int uv_tcp_nodelay(uv_tcp_t* handle, int enable)

    Enable `TCP_NODELAY`, which disables Nagle's algorithm.

.. c:function:: int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay)

    Enable / disable TCP keep-alive. `delay` is the initial delay in seconds,
    ignored when `enable` is zero.

.. c:function:: int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable)

    Enable / disable simultaneous asynchronous accept requests that are
    queued by the operating system when listening for new TCP connections.

    This setting is used to tune a TCP server for the desired performance.
    Having simultaneous accepts can significantly improve the rate of accepting
    connections (which is why it is enabled by default) but may lead to uneven

libuv/include/uv.h  view on Meta::CPAN

 *  allocate the loop manually and use uv_loop_init instead.
 */
UV_EXTERN uv_loop_t* uv_loop_new(void);
/*
 * NOTE:
 *  This function is DEPRECATED (to be removed after 0.12). Users should use
 *  uv_loop_close and free the memory manually instead.
 */
UV_EXTERN void uv_loop_delete(uv_loop_t*);
UV_EXTERN size_t uv_loop_size(void);
UV_EXTERN int uv_loop_alive(const uv_loop_t* loop);
UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...);
UV_EXTERN int uv_loop_fork(uv_loop_t* loop);

UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
UV_EXTERN void uv_stop(uv_loop_t*);

UV_EXTERN void uv_ref(uv_handle_t*);
UV_EXTERN void uv_unref(uv_handle_t*);
UV_EXTERN int uv_has_ref(const uv_handle_t*);

libuv/include/uv.h  view on Meta::CPAN

struct uv_tcp_s {
  UV_HANDLE_FIELDS
  UV_STREAM_FIELDS
  UV_TCP_PRIVATE_FIELDS
};

UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags);
UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
                               int enable,
                               unsigned int delay);
UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);

enum uv_tcp_flags {
  /* Used with uv_tcp_bind, when an IPv6 address is used. */
  UV_TCP_IPV6ONLY = 1
};

UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle,

libuv/include/uv.h  view on Meta::CPAN

  /*
   * Do not wrap any arguments in quotes, or perform any other escaping, when
   * converting the argument list into a command line string. This option is
   * only meaningful on Windows systems. On Unix it is silently ignored.
   */
  UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
  /*
   * Spawn the child process in a detached state - this will make it a process
   * group leader, and will effectively enable the child to keep running after
   * the parent exits.  Note that the child process will still keep the
   * parent's event loop alive unless the parent process calls uv_unref() on
   * the child's process handle.
   */
  UV_PROCESS_DETACHED = (1 << 3),
  /*
   * Hide the subprocess window that would normally be created. This option is
   * only meaningful on Windows systems. On Unix it is silently ignored.
   */
  UV_PROCESS_WINDOWS_HIDE = (1 << 4),
  /*
   * Hide the subprocess console window that would normally be created. This

libuv/src/unix/core.c  view on Meta::CPAN

  if (!QUEUE_EMPTY(&loop->pending_queue))
    return 0;

  if (loop->closing_handles)
    return 0;

  return uv__next_timeout(loop);
}


static int uv__loop_alive(const uv_loop_t* loop) {
  return uv__has_active_handles(loop) ||
         uv__has_active_reqs(loop) ||
         loop->closing_handles != NULL;
}


int uv_loop_alive(const uv_loop_t* loop) {
    return uv__loop_alive(loop);
}


int uv_run(uv_loop_t* loop, uv_run_mode mode) {
  int timeout;
  int r;
  int ran_pending;

  r = uv__loop_alive(loop);
  if (!r)
    uv__update_time(loop);

  while (r != 0 && loop->stop_flag == 0) {
    uv__update_time(loop);
    uv__run_timers(loop);
    ran_pending = uv__run_pending(loop);
    uv__run_idle(loop);
    uv__run_prepare(loop);

libuv/src/unix/core.c  view on Meta::CPAN

       * I/O (meaning: no callbacks) when its timeout expires - which means we
       * have pending timers that satisfy the forward progress constraint.
       *
       * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
       * the check.
       */
      uv__update_time(loop);
      uv__run_timers(loop);
    }

    r = uv__loop_alive(loop);
    if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
      break;
  }

  /* The if statement lets gcc compile it to a conditional store. Avoids
   * dirtying a cache line.
   */
  if (loop->stop_flag != 0)
    loop->stop_flag = 0;

libuv/src/unix/internal.h  view on Meta::CPAN

int uv__stream_try_select(uv_stream_t* stream, int* fd);
#endif /* defined(__APPLE__) */
void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events);
int uv__accept(int sockfd);
int uv__dup2_cloexec(int oldfd, int newfd);
int uv__open_cloexec(const char* path, int flags);

/* tcp */
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
int uv__tcp_nodelay(int fd, int on);
int uv__tcp_keepalive(int fd, int on, unsigned int delay);

/* pipe */
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);

/* signal */
void uv__signal_close(uv_signal_t* handle);
void uv__signal_global_once_init(void);
void uv__signal_loop_cleanup(uv_loop_t* loop);
int uv__signal_loop_fork(uv_loop_t* loop);

libuv/src/unix/os390.c  view on Meta::CPAN

    Long-term average CPU service used by this logical partition,
    in millions of service units per hour. If this value is above
    the partition's defined capacity, the partition will be capped.
    It is calculated using the physical CPU adjustment factor
    (RCTPCPUA) so it may not match other measures of service which
    are based on the logical CPU adjustment factor. It is available
    if the hardware supports LPAR cluster.
*/
#define RCTLACS_OFFSET    0xC4

/* 32-bit count of alive CPUs. This includes both CPs and IFAs */
#define CSD_NUMBER_ONLINE_CPUS        0xD4

/* Address of system resources manager (SRM) control table */
#define CVTOPCTP_OFFSET   0x25C

/* Address of the RCT table */
#define RMCTRCT_OFFSET    0xE4

/* Address of the rsm control and enumeration area. */
#define CVTRCEP_OFFSET    0x490

libuv/src/unix/stream.c  view on Meta::CPAN


  assert(fd >= 0);
  stream->flags |= flags;

  if (stream->type == UV_TCP) {
    if ((stream->flags & UV_HANDLE_TCP_NODELAY) && uv__tcp_nodelay(fd, 1))
      return UV__ERR(errno);

    /* TODO Use delay the user passed in. */
    if ((stream->flags & UV_HANDLE_TCP_KEEPALIVE) &&
        uv__tcp_keepalive(fd, 1, 60)) {
      return UV__ERR(errno);
    }
  }

#if defined(__APPLE__)
  enable = 1;
  if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &enable, sizeof(enable)) &&
      errno != ENOTSOCK &&
      errno != EINVAL) {
    return UV__ERR(errno);

libuv/src/unix/tcp.c  view on Meta::CPAN

}


int uv__tcp_nodelay(int fd, int on) {
  if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)))
    return UV__ERR(errno);
  return 0;
}


int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
  if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
    return UV__ERR(errno);

#ifdef TCP_KEEPIDLE
  if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
    return UV__ERR(errno);
#endif

  /* Solaris/SmartOS, if you don't support keep-alive,
   * then don't advertise it in your system headers...
   */
  /* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */
#if defined(TCP_KEEPALIVE) && !defined(__sun)
  if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay)))
    return UV__ERR(errno);
#endif

  return 0;
}

libuv/src/unix/tcp.c  view on Meta::CPAN


  if (on)
    handle->flags |= UV_HANDLE_TCP_NODELAY;
  else
    handle->flags &= ~UV_HANDLE_TCP_NODELAY;

  return 0;
}


int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) {
  int err;

  if (uv__stream_fd(handle) != -1) {
    err =uv__tcp_keepalive(uv__stream_fd(handle), on, delay);
    if (err)
      return err;
  }

  if (on)
    handle->flags |= UV_HANDLE_TCP_KEEPALIVE;
  else
    handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE;

  /* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge

libuv/src/win/core.c  view on Meta::CPAN

         */
        timeout += repeat ? (1 << (repeat - 1)) : 0;
        continue;
      }
    }
    break;
  }
}


static int uv__loop_alive(const uv_loop_t* loop) {
  return uv__has_active_handles(loop) ||
         uv__has_active_reqs(loop) ||
         loop->endgame_handles != NULL;
}


int uv_loop_alive(const uv_loop_t* loop) {
    return uv__loop_alive(loop);
}


int uv_run(uv_loop_t *loop, uv_run_mode mode) {
  DWORD timeout;
  int r;
  int ran_pending;

  r = uv__loop_alive(loop);
  if (!r)
    uv_update_time(loop);

  while (r != 0 && loop->stop_flag == 0) {
    uv_update_time(loop);
    uv__run_timers(loop);

    ran_pending = uv_process_reqs(loop);
    uv_idle_invoke(loop);
    uv_prepare_invoke(loop);

libuv/src/win/core.c  view on Meta::CPAN

       * been invoked when it returns. uv__io_poll() can return without doing
       * I/O (meaning: no callbacks) when its timeout expires - which means we
       * have pending timers that satisfy the forward progress constraint.
       *
       * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
       * the check.
       */
      uv__run_timers(loop);
    }

    r = uv__loop_alive(loop);
    if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
      break;
  }

  /* The if statement lets the compiler compile it to a conditional store.
   * Avoids dirtying a cache line.
   */
  if (loop->stop_flag != 0)
    loop->stop_flag = 0;

libuv/src/win/process.c  view on Meta::CPAN

      if (err == ERROR_ACCESS_DENIED &&
          GetExitCodeProcess(process_handle, &status) &&
          status != STILL_ACTIVE) {
        return UV_ESRCH;
      }

      return uv_translate_sys_error(err);
    }

    case 0: {
      /* Health check: is the process still alive? */
      DWORD status;

      if (!GetExitCodeProcess(process_handle, &status))
        return uv_translate_sys_error(GetLastError());

      if (status != STILL_ACTIVE)
        return UV_ESRCH;

      return 0;
    }

libuv/src/win/tcp.c  view on Meta::CPAN

                 IPPROTO_TCP,
                 TCP_NODELAY,
                 (const char*)&enable,
                 sizeof enable) == -1) {
    return WSAGetLastError();
  }
  return 0;
}


static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay) {
  if (setsockopt(socket,
                 SOL_SOCKET,
                 SO_KEEPALIVE,
                 (const char*)&enable,
                 sizeof enable) == -1) {
    return WSAGetLastError();
  }

  if (enable && setsockopt(socket,
                           IPPROTO_TCP,

libuv/src/win/tcp.c  view on Meta::CPAN

  }

  if (handle->flags & UV_HANDLE_TCP_NODELAY) {
    err = uv__tcp_nodelay(handle, socket, 1);
    if (err)
      return err;
  }

  /* TODO: Use stored delay. */
  if (handle->flags & UV_HANDLE_TCP_KEEPALIVE) {
    err = uv__tcp_keepalive(handle, socket, 1, 60);
    if (err)
      return err;
  }

  handle->socket = socket;

  if (family == AF_INET6) {
    handle->flags |= UV_HANDLE_IPV6;
  } else {
    assert(!(handle->flags & UV_HANDLE_IPV6));

libuv/src/win/tcp.c  view on Meta::CPAN

  if (enable) {
    handle->flags |= UV_HANDLE_TCP_NODELAY;
  } else {
    handle->flags &= ~UV_HANDLE_TCP_NODELAY;
  }

  return 0;
}


int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) {
  int err;

  if (handle->socket != INVALID_SOCKET) {
    err = uv__tcp_keepalive(handle, handle->socket, enable, delay);
    if (err)
      return err;
  }

  if (enable) {
    handle->flags |= UV_HANDLE_TCP_KEEPALIVE;
  } else {
    handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE;
  }

libuv/test/benchmark-udp-pummel.c  view on Meta::CPAN

  ASSERT(n_receivers <= ARRAY_SIZE(receivers));

  loop = uv_default_loop();

  n_senders_ = n_senders;
  n_receivers_ = n_receivers;

  if (timeout) {
    ASSERT(0 == uv_timer_init(loop, &timer_handle));
    ASSERT(0 == uv_timer_start(&timer_handle, timeout_cb, timeout, 0));
    /* Timer should not keep loop alive. */
    uv_unref((uv_handle_t*)&timer_handle);
    timed = 1;
  }

  for (i = 0; i < n_receivers; i++) {
    struct receiver_state* s = receivers + i;
    struct sockaddr_in addr;
    ASSERT(0 == uv_ip4_addr("0.0.0.0", BASE_PORT + i, &addr));
    ASSERT(0 == uv_udp_init(loop, &s->udp_handle));
    ASSERT(0 == uv_udp_bind(&s->udp_handle, (const struct sockaddr*) &addr, 0));

libuv/test/test-fork.c  view on Meta::CPAN

    uv_unref((uv_handle_t*)&signal_handle);
    ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_NOWAIT));
    ASSERT(0 == fork_signal_cb_called);
    printf("Waiting for child in parent\n");
    assert_wait_child(child_pid);
  } else {
    /* child */
    ASSERT(0 == uv_loop_fork(uv_default_loop()));
    ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */
    /* Get the signal. */
    ASSERT(0 != uv_loop_alive(uv_default_loop()));
    printf("Running loop in child\n");
    ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE));
    ASSERT(SIGUSR1 == fork_signal_cb_called);
  }

  MAKE_VALGRIND_HAPPY();
  return 0;
}


libuv/test/test-fork.c  view on Meta::CPAN

    ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE));
    printf("Signal in parent %d\n", fork_signal_cb_called);
    ASSERT(0 == fork_signal_cb_called);
    ASSERT(1 == write(sync_pipe2[1], "1", 1)); /* alert child */
    printf("Waiting for child in parent\n");
    assert_wait_child(child_pid);
  } else {
    /* Child. Our signal handler should still be installed. */
    ASSERT(0 == uv_loop_fork(uv_default_loop()));
    printf("Checking loop in child\n");
    ASSERT(0 != uv_loop_alive(uv_default_loop()));
    printf("Alerting parent in child\n");
    ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */
    /* Don't run the loop. Wait for the parent to call us */
    printf("Waiting on parent in child\n");
    /* Wait for parent. read may fail if the parent tripped an ASSERT
       and exited, so this ASSERT is generous.
    */
    r = read(sync_pipe2[0], sync_buf, 1);
    ASSERT(-1 <= r && r <= 1);
    ASSERT(0 == fork_signal_cb_called);

libuv/test/test-list.h  view on Meta::CPAN

 * IN THE SOFTWARE.
 */

#include "uv.h"

TEST_DECLARE   (platform_output)
TEST_DECLARE   (callback_order)
TEST_DECLARE   (close_order)
TEST_DECLARE   (run_once)
TEST_DECLARE   (run_nowait)
TEST_DECLARE   (loop_alive)
TEST_DECLARE   (loop_close)
TEST_DECLARE   (loop_instant_close)
TEST_DECLARE   (loop_stop)
TEST_DECLARE   (loop_update_time)
TEST_DECLARE   (loop_backend_timeout)
TEST_DECLARE   (loop_configure)
TEST_DECLARE   (default_loop_close)
TEST_DECLARE   (barrier_1)
TEST_DECLARE   (barrier_2)
TEST_DECLARE   (barrier_3)

libuv/test/test-list.h  view on Meta::CPAN


TASK_LIST_START
  TEST_ENTRY_CUSTOM (platform_output, 0, 1, 5000)

#if 0
  TEST_ENTRY  (callback_order)
#endif
  TEST_ENTRY  (close_order)
  TEST_ENTRY  (run_once)
  TEST_ENTRY  (run_nowait)
  TEST_ENTRY  (loop_alive)
  TEST_ENTRY  (loop_close)
  TEST_ENTRY  (loop_instant_close)
  TEST_ENTRY  (loop_stop)
  TEST_ENTRY  (loop_update_time)
  TEST_ENTRY  (loop_backend_timeout)
  TEST_ENTRY  (loop_configure)
  TEST_ENTRY  (default_loop_close)
  TEST_ENTRY  (barrier_1)
  TEST_ENTRY  (barrier_2)
  TEST_ENTRY  (barrier_3)

libuv/test/test-loop-alive.c  view on Meta::CPAN

static void work_cb(uv_work_t* req) {
  ASSERT(req);
}

static void after_work_cb(uv_work_t* req, int status) {
  ASSERT(req);
  ASSERT(status == 0);
}


TEST_IMPL(loop_alive) {
  int r;
  ASSERT(!uv_loop_alive(uv_default_loop()));

  /* loops with handles are alive */
  uv_timer_init(uv_default_loop(), &timer_handle);
  uv_timer_start(&timer_handle, timer_cb, 100, 0);
  ASSERT(uv_loop_alive(uv_default_loop()));

  r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
  ASSERT(r == 0);
  ASSERT(!uv_loop_alive(uv_default_loop()));

  /* loops with requests are alive */
  r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb);
  ASSERT(r == 0);
  ASSERT(uv_loop_alive(uv_default_loop()));

  r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
  ASSERT(r == 0);
  ASSERT(!uv_loop_alive(uv_default_loop()));

  return 0;
}

libuv/test/test-loop-handles.c  view on Meta::CPAN

 *   be called exactly once.
 * - A watcher can safely start and stop other watchers of the same type.
 * - Prepare and check watchers are called once per event loop iterations.
 * - All active idle watchers are queued when the event loop has no more work
 *   to do. This is done repeatedly until all idle watchers are inactive.
 * - If a watcher starts another watcher of the same type its callback is not
 *   immediately queued. For check and prepare watchers, that means that if
 *   a watcher makes another of the same type active, it'll not be called until
 *   the next event loop iteration. For idle. watchers this means that the
 *   newly activated idle watcher might not be queued immediately.
 * - Prepare, check, idle watchers keep the event loop alive even when they're
 *   not active.
 *
 * This is what the test globally does:
 *
 * - prepare_1 is always active and counts event loop iterations. It also
 *   creates and starts prepare_2 every other iteration. Finally it verifies
 *   that no idle watchers are active before polling.
 * - prepare_2 is started by prepare_1 every other iteration. It immediately
 *   stops itself. It verifies that a watcher is not queued immediately
 *   if created by another watcher of the same type.
 * - There's a check watcher that stops the event loop after a certain number
 *   of iterations. It starts a varying number of idle_1 watchers.
 * - Idle_1 watchers stop themselves after being called a few times. All idle_1
 *   watchers try to start the idle_2 watcher if it is not already started or
 *   awaiting its close callback.
 * - The idle_2 watcher always exists but immediately closes itself after
 *   being started by a check_1 watcher. It verifies that a watcher is
 *   implicitly stopped when closed, and that a watcher can close itself
 *   safely.
 * - There is a repeating timer. It does not keep the event loop alive
 *   (ev_unref) but makes sure that the loop keeps polling the system for
 *   events.
 */


#include "uv.h"
#include "task.h"

#include <math.h>

libuv/test/test-loop-handles.c  view on Meta::CPAN


  for (i = 0; i < IDLE_COUNT; i++) {
    /* initialize only, idle_1 handles are started by check_cb */
    r = uv_idle_init(uv_default_loop(), &idle_1_handles[i]);
    ASSERT(r == 0);
  }

  /* don't init or start idle_2, both is done by idle_1_cb */

  /* The timer callback is there to keep the event loop polling unref it as it
   * is not supposed to keep the loop alive */
  r = uv_timer_init(uv_default_loop(), &timer_handle);
  ASSERT(r == 0);
  r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
  ASSERT(r == 0);
  uv_unref((uv_handle_t*)&timer_handle);

  r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
  ASSERT(r == 0);

  ASSERT(loop_iteration == ITERATIONS);

libuv/test/test-loop-time.c  view on Meta::CPAN

}

TEST_IMPL(loop_backend_timeout) {
  uv_loop_t *loop = uv_default_loop();
  uv_timer_t timer;
  int r;

  r = uv_timer_init(loop, &timer);
  ASSERT(r == 0);

  ASSERT(!uv_loop_alive(loop));
  ASSERT(uv_backend_timeout(loop) == 0);

  r = uv_timer_start(&timer, cb, 1000, 0); /* 1 sec */
  ASSERT(r == 0);
  ASSERT(uv_backend_timeout(loop) > 100); /* 0.1 sec */
  ASSERT(uv_backend_timeout(loop) <= 1000); /* 1 sec */

  r = uv_run(loop, UV_RUN_DEFAULT);
  ASSERT(r == 0);
  ASSERT(uv_backend_timeout(loop) == 0);

libuv/test/test-spawn.c  view on Meta::CPAN

   * See: https://github.com/libuv/libuv/issues/1226
   */
  ASSERT(no_term_signal || term_signal == SIGTERM || term_signal == SIGKILL);
#else
  ASSERT(no_term_signal || term_signal == SIGTERM);
#endif
  uv_close((uv_handle_t*)process, close_cb);

  /*
   * Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   * This process should be dead.
   */
  err = uv_kill(process->pid, 0);
  ASSERT(err == UV_ESRCH);
}

static void detach_failure_cb(uv_process_t* process,
                              int64_t exit_status,
                              int term_signal) {
  printf("detach_cb\n");

libuv/test/test-spawn.c  view on Meta::CPAN

  options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
  options.stdio[0].data.stream = (uv_stream_t*)&in;
  options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
  options.stdio[1].data.stream = (uv_stream_t*)&out;
  options.stdio_count = 2;

  r = uv_spawn(uv_default_loop(), &process, &options);
  ASSERT(r == 0);

  /* Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   */
  r = uv_process_kill(&process, 0);
  ASSERT(r == 0);

  r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
  ASSERT(r == 0);

  r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
  ASSERT(r == 0);

libuv/test/test-spawn.c  view on Meta::CPAN

  options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
  options.stdio[0].data.stream = (uv_stream_t*)&in;
  options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
  options.stdio[1].data.stream = (uv_stream_t*)&out;
  options.stdio_count = 2;

  r = uv_spawn(uv_default_loop(), &process, &options);
  ASSERT(r == 0);

  /* Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   */
  r = uv_process_kill(&process, 0);
  ASSERT(r == 0);

  r = uv_write(&write_req, (uv_stream_t*)&in, &buf, 1, write_cb);
  ASSERT(r == 0);

  r = uv_read_start((uv_stream_t*)&out, on_alloc, on_read);
  ASSERT(r == 0);

libuv/test/test-spawn.c  view on Meta::CPAN

  {
    sigset_t set;
    sigemptyset(&set);
    sigaddset(&set, SIGTERM);
    ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL));
  }
  ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL));
#endif

  /* Sending signum == 0 should check if the
   * child process is still alive, not kill it.
   */
  r = uv_kill(process.pid, 0);
  ASSERT(r == 0);

  /* Kill the process. */
  r = uv_kill(process.pid, /* SIGTERM */ 15);
  ASSERT(r == 0);

  r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
  ASSERT(r == 0);

libuv/test/test-tcp-flags.c  view on Meta::CPAN

  int r;

  loop = uv_default_loop();

  r = uv_tcp_init(loop, &handle);
  ASSERT(r == 0);

  r = uv_tcp_nodelay(&handle, 1);
  ASSERT(r == 0);

  r = uv_tcp_keepalive(&handle, 1, 60);
  ASSERT(r == 0);

  uv_close((uv_handle_t*)&handle, NULL);

  r = uv_run(loop, UV_RUN_DEFAULT);
  ASSERT(r == 0);

  MAKE_VALGRIND_HAPPY();
  return 0;
}

libuv/test/test-udp-options.c  view on Meta::CPAN

  static int invalid_ttls[] = { -1, 0, 256 };
  uv_loop_t* loop;
  uv_udp_t h;
  int i, r;

  loop = uv_default_loop();

  r = uv_udp_init(loop, &h);
  ASSERT(r == 0);

  uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */

  r = uv_udp_bind(&h, addr, 0);
  ASSERT(r == 0);

  r = uv_udp_set_broadcast(&h, 1);
  r |= uv_udp_set_broadcast(&h, 1);
  r |= uv_udp_set_broadcast(&h, 0);
  r |= uv_udp_set_broadcast(&h, 0);
  ASSERT(r == 0);

libuv/test/test.gyp  view on Meta::CPAN

        'test-homedir.c',
        'test-hrtime.c',
        'test-idle.c',
        'test-idna.c',
        'test-ip6-addr.c',
        'test-ipc-heavy-traffic-deadlock-bug.c',
        'test-ipc-send-recv.c',
        'test-ipc.c',
        'test-list.h',
        'test-loop-handles.c',
        'test-loop-alive.c',
        'test-loop-close.c',
        'test-loop-stop.c',
        'test-loop-time.c',
        'test-loop-configure.c',
        'test-walk-handles.c',
        'test-watcher-cross-stop.c',
        'test-multiple-listen.c',
        'test-osx-select.c',
        'test-pass-always.c',
        'test-ping-pong.c',



( run in 1.982 second using v1.01-cache-2.11-cpan-df04353d9ac )