Rizin
unix-like reverse engineering framework and cli tools
uv-common.h File Reference
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include "uv.h"
#include "uv/tree.h"
#include "queue.h"
#include "strscpy.h"

Go to the source code of this file.

Classes

struct  uv__loop_metrics_s
 
struct  uv__loop_internal_fields_s
 

Macros

#define UV__ERR(x)   (x)
 
#define ARRAY_SIZE(a)   (sizeof(a) / sizeof((a)[0]))
 
#define container_of(ptr, type, member)    ((type *) ((char *) (ptr) - offsetof(type, member)))
 
#define STATIC_ASSERT(expr)    void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])
 
#define uv__load_relaxed(p)   (*p)
 
#define uv__store_relaxed(p, v)   do *p = v; while (0)
 
#define uv__has_active_reqs(loop)    ((loop)->active_reqs.count > 0)
 
#define uv__req_register(loop, req)
 
#define uv__req_unregister(loop, req)
 
#define uv__has_active_handles(loop)    ((loop)->active_handles > 0)
 
#define uv__active_handle_add(h)
 
#define uv__active_handle_rm(h)
 
#define uv__is_active(h)    (((h)->flags & UV_HANDLE_ACTIVE) != 0)
 
#define uv__is_closing(h)    (((h)->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)) != 0)
 
#define uv__handle_start(h)
 
#define uv__handle_stop(h)
 
#define uv__handle_ref(h)
 
#define uv__handle_unref(h)
 
#define uv__has_ref(h)    (((h)->flags & UV_HANDLE_REF) != 0)
 
#define uv__handle_platform_init(h)   ((h)->next_closing = NULL)
 
#define uv__handle_init(loop_, h, type_)
 
#define UV_REQ_INIT(req, typ)
 
#define uv__req_init(loop, req, typ)
 
#define uv__get_internal_fields(loop)    ((uv__loop_internal_fields_t*) loop->internal_fields)
 
#define uv__get_loop_metrics(loop)    (&uv__get_internal_fields(loop)->loop_metrics)
 

Typedefs

typedef struct uv__loop_metrics_s uv__loop_metrics_t
 
typedef struct uv__loop_internal_fields_s uv__loop_internal_fields_t
 

Enumerations

enum  {
  UV_HANDLE_CLOSING = 0x00000001 , UV_HANDLE_CLOSED = 0x00000002 , UV_HANDLE_ACTIVE = 0x00000004 , UV_HANDLE_REF = 0x00000008 ,
  UV_HANDLE_INTERNAL = 0x00000010 , UV_HANDLE_ENDGAME_QUEUED = 0x00000020 , UV_HANDLE_LISTENING = 0x00000040 , UV_HANDLE_CONNECTION = 0x00000080 ,
  UV_HANDLE_SHUTTING = 0x00000100 , UV_HANDLE_SHUT = 0x00000200 , UV_HANDLE_READ_PARTIAL = 0x00000400 , UV_HANDLE_READ_EOF = 0x00000800 ,
  UV_HANDLE_READING = 0x00001000 , UV_HANDLE_BOUND = 0x00002000 , UV_HANDLE_READABLE = 0x00004000 , UV_HANDLE_WRITABLE = 0x00008000 ,
  UV_HANDLE_READ_PENDING = 0x00010000 , UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000 , UV_HANDLE_ZERO_READ = 0x00040000 , UV_HANDLE_EMULATE_IOCP = 0x00080000 ,
  UV_HANDLE_BLOCKING_WRITES = 0x00100000 , UV_HANDLE_CANCELLATION_PENDING = 0x00200000 , UV_HANDLE_IPV6 = 0x00400000 , UV_HANDLE_TCP_NODELAY = 0x01000000 ,
  UV_HANDLE_TCP_KEEPALIVE = 0x02000000 , UV_HANDLE_TCP_SINGLE_ACCEPT = 0x04000000 , UV_HANDLE_TCP_ACCEPT_STATE_CHANGING = 0x08000000 , UV_HANDLE_TCP_SOCKET_CLOSED = 0x10000000 ,
  UV_HANDLE_SHARED_TCP_SOCKET = 0x20000000 , UV_HANDLE_UDP_PROCESSING = 0x01000000 , UV_HANDLE_UDP_CONNECTED = 0x02000000 , UV_HANDLE_UDP_RECVMMSG = 0x04000000 ,
  UV_HANDLE_NON_OVERLAPPED_PIPE = 0x01000000 , UV_HANDLE_PIPESERVER = 0x02000000 , UV_HANDLE_TTY_READABLE = 0x01000000 , UV_HANDLE_TTY_RAW = 0x02000000 ,
  UV_HANDLE_TTY_SAVED_POSITION = 0x04000000 , UV_HANDLE_TTY_SAVED_ATTRIBUTES = 0x08000000 , UV_SIGNAL_ONE_SHOT_DISPATCHED = 0x01000000 , UV_SIGNAL_ONE_SHOT = 0x02000000 ,
  UV_HANDLE_POLL_SLOW = 0x01000000
}
 
enum  uv__work_kind { UV__WORK_CPU , UV__WORK_FAST_IO , UV__WORK_SLOW_IO }
 

Functions

int uv__loop_configure (uv_loop_t *loop, uv_loop_option option, va_list ap)
 
void uv__loop_close (uv_loop_t *loop)
 
int uv__tcp_bind (uv_tcp_t *tcp, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
 
int uv__tcp_connect (uv_connect_t *req, uv_tcp_t *handle, const struct sockaddr *addr, unsigned int addrlen, uv_connect_cb cb)
 
int uv__udp_init_ex (uv_loop_t *loop, uv_udp_t *handle, unsigned flags, int domain)
 
int uv__udp_bind (uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
 
int uv__udp_connect (uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen)
 
int uv__udp_disconnect (uv_udp_t *handle)
 
int uv__udp_is_connected (uv_udp_t *handle)
 
int uv__udp_send (uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen, uv_udp_send_cb send_cb)
 
int uv__udp_try_send (uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen)
 
int uv__udp_recv_start (uv_udp_t *handle, uv_alloc_cb alloccb, uv_udp_recv_cb recv_cb)
 
int uv__udp_recv_stop (uv_udp_t *handle)
 
void uv__fs_poll_close (uv_fs_poll_t *handle)
 
int uv__getaddrinfo_translate_error (int sys_err)
 
void uv__work_submit (uv_loop_t *loop, struct uv__work *w, enum uv__work_kind kind, void(*work)(struct uv__work *w), void(*done)(struct uv__work *w, int status))
 
void uv__work_done (uv_async_t *handle)
 
size_t uv__count_bufs (const uv_buf_t bufs[], unsigned int nbufs)
 
int uv__socket_sockopt (uv_handle_t *handle, int optname, int *value)
 
void uv__fs_scandir_cleanup (uv_fs_t *req)
 
void uv__fs_readdir_cleanup (uv_fs_t *req)
 
uv_dirent_type_t uv__fs_get_dirent_type (uv__dirent_t *dent)
 
int uv__next_timeout (const uv_loop_t *loop)
 
void uv__run_timers (uv_loop_t *loop)
 
void uv__timer_close (uv_timer_t *handle)
 
void uv__process_title_cleanup (void)
 
void uv__signal_cleanup (void)
 
void uv__threadpool_cleanup (void)
 
void * uv__calloc (size_t count, size_t size)
 
char * uv__strdup (const char *s)
 
char * uv__strndup (const char *s, size_t n)
 
void * uv__malloc (size_t size)
 
void uv__free (void *ptr)
 
void * uv__realloc (void *ptr, size_t size)
 
void * uv__reallocf (void *ptr, size_t size)
 
void uv__metrics_update_idle_time (uv_loop_t *loop)
 
void uv__metrics_set_provider_entry_time (uv_loop_t *loop)
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a) / sizeof((a)[0]))

Definition at line 55 of file uv-common.h.

◆ container_of

#define container_of (   ptr,
  type,
  member 
)     ((type *) ((char *) (ptr) - offsetof(type, member)))

Definition at line 57 of file uv-common.h.

◆ STATIC_ASSERT

#define STATIC_ASSERT (   expr)     void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])

Definition at line 60 of file uv-common.h.

◆ uv__active_handle_add

#define uv__active_handle_add (   h)
Value:
do { \
} \
while (0)
#define h(i)
Definition: sha256.c:48
unsigned int active_handles
Definition: uv.h:1784
uv_loop_t * loop
Definition: main.c:7

Definition at line 240 of file uv-common.h.

◆ uv__active_handle_rm

#define uv__active_handle_rm (   h)
Value:
do { \
} \
while (0)

Definition at line 246 of file uv-common.h.

◆ UV__ERR

#define UV__ERR (   x)    (x)

Definition at line 48 of file uv-common.h.

◆ uv__get_internal_fields

#define uv__get_internal_fields (   loop)     ((uv__loop_internal_fields_t*) loop->internal_fields)

Definition at line 336 of file uv-common.h.

◆ uv__get_loop_metrics

#define uv__get_loop_metrics (   loop)     (&uv__get_internal_fields(loop)->loop_metrics)

Definition at line 339 of file uv-common.h.

◆ uv__handle_init

#define uv__handle_init (   loop_,
  h,
  type_ 
)
Value:
do { \
(h)->loop = (loop_); \
(h)->type = (type_); \
(h)->flags = UV_HANDLE_REF; /* Ref the loop when active. */ \
QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \
uv__handle_platform_init(h); \
} \
while (0)
int type
Definition: mipsasm.c:17
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
@ UV_HANDLE_REF
Definition: uv-common.h:77

Definition at line 301 of file uv-common.h.

◆ uv__handle_platform_init

#define uv__handle_platform_init (   h)    ((h)->next_closing = NULL)

Definition at line 298 of file uv-common.h.

◆ uv__handle_ref

#define uv__handle_ref (   h)
Value:
do { \
if (((h)->flags & UV_HANDLE_REF) != 0) break; \
if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \
} \
while (0)
while(len< limit &&buf1[len]==buf2[len])++len
@ UV_HANDLE_CLOSING
Definition: uv-common.h:74
@ UV_HANDLE_ACTIVE
Definition: uv-common.h:76
#define uv__active_handle_add(h)
Definition: uv-common.h:240
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

Definition at line 274 of file uv-common.h.

◆ uv__handle_start

#define uv__handle_start (   h)
Value:
do { \
if (((h)->flags & UV_HANDLE_ACTIVE) != 0) break; \
} \
while (0)

Definition at line 258 of file uv-common.h.

◆ uv__handle_stop

#define uv__handle_stop (   h)
Value:
do { \
if (((h)->flags & UV_HANDLE_ACTIVE) == 0) break; \
} \
while (0)
#define uv__active_handle_rm(h)
Definition: uv-common.h:246

Definition at line 266 of file uv-common.h.

◆ uv__handle_unref

#define uv__handle_unref (   h)
Value:
do { \
if (((h)->flags & UV_HANDLE_REF) == 0) break; \
(h)->flags &= ~UV_HANDLE_REF; \
if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \
} \
while (0)

Definition at line 283 of file uv-common.h.

◆ uv__has_active_handles

#define uv__has_active_handles (   loop)     ((loop)->active_handles > 0)

Definition at line 237 of file uv-common.h.

◆ uv__has_active_reqs

#define uv__has_active_reqs (   loop)     ((loop)->active_reqs.count > 0)

Definition at line 221 of file uv-common.h.

◆ uv__has_ref

#define uv__has_ref (   h)     (((h)->flags & UV_HANDLE_REF) != 0)

Definition at line 292 of file uv-common.h.

◆ uv__is_active

#define uv__is_active (   h)     (((h)->flags & UV_HANDLE_ACTIVE) != 0)

Definition at line 252 of file uv-common.h.

◆ uv__is_closing

#define uv__is_closing (   h)     (((h)->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)) != 0)

Definition at line 255 of file uv-common.h.

◆ uv__load_relaxed

#define uv__load_relaxed (   p)    (*p)

Definition at line 67 of file uv-common.h.

◆ uv__req_init

#define uv__req_init (   loop,
  req,
  typ 
)
Value:
do { \
UV_REQ_INIT(req, typ); \
uv__req_register(loop, req); \
} \
while (0)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition: sflib.h:128

Definition at line 329 of file uv-common.h.

◆ uv__req_register

#define uv__req_register (   loop,
  req 
)
Value:
do { \
(loop)->active_reqs.count++; \
} \
while (0)

Definition at line 224 of file uv-common.h.

◆ uv__req_unregister

#define uv__req_unregister (   loop,
  req 
)
Value:
do { \
(loop)->active_reqs.count--; \
} \
while (0)
#define uv__has_active_reqs(loop)
Definition: uv-common.h:221

Definition at line 230 of file uv-common.h.

◆ uv__store_relaxed

#define uv__store_relaxed (   p,
  v 
)    do *p = v; while (0)

Definition at line 68 of file uv-common.h.

◆ UV_REQ_INIT

#define UV_REQ_INIT (   req,
  typ 
)
Value:
do { \
(req)->type = (typ); \
} \
while (0)

Definition at line 322 of file uv-common.h.

Typedef Documentation

◆ uv__loop_internal_fields_t

Definition at line 349 of file uv-common.h.

◆ uv__loop_metrics_t

Definition at line 349 of file uv-common.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UV_HANDLE_CLOSING 
UV_HANDLE_CLOSED 
UV_HANDLE_ACTIVE 
UV_HANDLE_REF 
UV_HANDLE_INTERNAL 
UV_HANDLE_ENDGAME_QUEUED 
UV_HANDLE_LISTENING 
UV_HANDLE_CONNECTION 
UV_HANDLE_SHUTTING 
UV_HANDLE_SHUT 
UV_HANDLE_READ_PARTIAL 
UV_HANDLE_READ_EOF 
UV_HANDLE_READING 
UV_HANDLE_BOUND 
UV_HANDLE_READABLE 
UV_HANDLE_WRITABLE 
UV_HANDLE_READ_PENDING 
UV_HANDLE_SYNC_BYPASS_IOCP 
UV_HANDLE_ZERO_READ 
UV_HANDLE_EMULATE_IOCP 
UV_HANDLE_BLOCKING_WRITES 
UV_HANDLE_CANCELLATION_PENDING 
UV_HANDLE_IPV6 
UV_HANDLE_TCP_NODELAY 
UV_HANDLE_TCP_KEEPALIVE 
UV_HANDLE_TCP_SINGLE_ACCEPT 
UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 
UV_HANDLE_TCP_SOCKET_CLOSED 
UV_HANDLE_SHARED_TCP_SOCKET 
UV_HANDLE_UDP_PROCESSING 
UV_HANDLE_UDP_CONNECTED 
UV_HANDLE_UDP_RECVMMSG 
UV_HANDLE_NON_OVERLAPPED_PIPE 
UV_HANDLE_PIPESERVER 
UV_HANDLE_TTY_READABLE 
UV_HANDLE_TTY_RAW 
UV_HANDLE_TTY_SAVED_POSITION 
UV_HANDLE_TTY_SAVED_ATTRIBUTES 
UV_SIGNAL_ONE_SHOT_DISPATCHED 
UV_SIGNAL_ONE_SHOT 
UV_HANDLE_POLL_SLOW 

Definition at line 72 of file uv-common.h.

72  {
73  /* Used by all handles. */
74  UV_HANDLE_CLOSING = 0x00000001,
75  UV_HANDLE_CLOSED = 0x00000002,
76  UV_HANDLE_ACTIVE = 0x00000004,
77  UV_HANDLE_REF = 0x00000008,
78  UV_HANDLE_INTERNAL = 0x00000010,
79  UV_HANDLE_ENDGAME_QUEUED = 0x00000020,
80 
81  /* Used by streams. */
82  UV_HANDLE_LISTENING = 0x00000040,
83  UV_HANDLE_CONNECTION = 0x00000080,
84  UV_HANDLE_SHUTTING = 0x00000100,
85  UV_HANDLE_SHUT = 0x00000200,
86  UV_HANDLE_READ_PARTIAL = 0x00000400,
87  UV_HANDLE_READ_EOF = 0x00000800,
88 
89  /* Used by streams and UDP handles. */
90  UV_HANDLE_READING = 0x00001000,
91  UV_HANDLE_BOUND = 0x00002000,
92  UV_HANDLE_READABLE = 0x00004000,
93  UV_HANDLE_WRITABLE = 0x00008000,
94  UV_HANDLE_READ_PENDING = 0x00010000,
95  UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000,
96  UV_HANDLE_ZERO_READ = 0x00040000,
97  UV_HANDLE_EMULATE_IOCP = 0x00080000,
98  UV_HANDLE_BLOCKING_WRITES = 0x00100000,
99  UV_HANDLE_CANCELLATION_PENDING = 0x00200000,
100 
101  /* Used by uv_tcp_t and uv_udp_t handles */
102  UV_HANDLE_IPV6 = 0x00400000,
103 
104  /* Only used by uv_tcp_t handles. */
105  UV_HANDLE_TCP_NODELAY = 0x01000000,
106  UV_HANDLE_TCP_KEEPALIVE = 0x02000000,
107  UV_HANDLE_TCP_SINGLE_ACCEPT = 0x04000000,
109  UV_HANDLE_TCP_SOCKET_CLOSED = 0x10000000,
110  UV_HANDLE_SHARED_TCP_SOCKET = 0x20000000,
111 
112  /* Only used by uv_udp_t handles. */
113  UV_HANDLE_UDP_PROCESSING = 0x01000000,
114  UV_HANDLE_UDP_CONNECTED = 0x02000000,
115  UV_HANDLE_UDP_RECVMMSG = 0x04000000,
116 
117  /* Only used by uv_pipe_t handles. */
118  UV_HANDLE_NON_OVERLAPPED_PIPE = 0x01000000,
119  UV_HANDLE_PIPESERVER = 0x02000000,
120 
121  /* Only used by uv_tty_t handles. */
122  UV_HANDLE_TTY_READABLE = 0x01000000,
123  UV_HANDLE_TTY_RAW = 0x02000000,
124  UV_HANDLE_TTY_SAVED_POSITION = 0x04000000,
125  UV_HANDLE_TTY_SAVED_ATTRIBUTES = 0x08000000,
126 
127  /* Only used by uv_signal_t handles. */
128  UV_SIGNAL_ONE_SHOT_DISPATCHED = 0x01000000,
129  UV_SIGNAL_ONE_SHOT = 0x02000000,
130 
131  /* Only used by uv_poll_t handles. */
132  UV_HANDLE_POLL_SLOW = 0x01000000
133 };
@ UV_HANDLE_TCP_KEEPALIVE
Definition: uv-common.h:106
@ UV_HANDLE_TTY_SAVED_POSITION
Definition: uv-common.h:124
@ UV_HANDLE_UDP_PROCESSING
Definition: uv-common.h:113
@ UV_HANDLE_ZERO_READ
Definition: uv-common.h:96
@ UV_HANDLE_PIPESERVER
Definition: uv-common.h:119
@ UV_HANDLE_READ_PARTIAL
Definition: uv-common.h:86
@ UV_HANDLE_TTY_SAVED_ATTRIBUTES
Definition: uv-common.h:125
@ UV_HANDLE_IPV6
Definition: uv-common.h:102
@ UV_HANDLE_TCP_NODELAY
Definition: uv-common.h:105
@ UV_HANDLE_BLOCKING_WRITES
Definition: uv-common.h:98
@ UV_HANDLE_CANCELLATION_PENDING
Definition: uv-common.h:99
@ UV_HANDLE_TCP_SOCKET_CLOSED
Definition: uv-common.h:109
@ UV_HANDLE_POLL_SLOW
Definition: uv-common.h:132
@ UV_SIGNAL_ONE_SHOT
Definition: uv-common.h:129
@ UV_HANDLE_TCP_SINGLE_ACCEPT
Definition: uv-common.h:107
@ UV_HANDLE_READING
Definition: uv-common.h:90
@ UV_HANDLE_READ_EOF
Definition: uv-common.h:87
@ UV_HANDLE_LISTENING
Definition: uv-common.h:82
@ UV_HANDLE_SHUT
Definition: uv-common.h:85
@ UV_HANDLE_UDP_RECVMMSG
Definition: uv-common.h:115
@ UV_HANDLE_UDP_CONNECTED
Definition: uv-common.h:114
@ UV_HANDLE_EMULATE_IOCP
Definition: uv-common.h:97
@ UV_HANDLE_ENDGAME_QUEUED
Definition: uv-common.h:79
@ UV_HANDLE_CONNECTION
Definition: uv-common.h:83
@ UV_HANDLE_SHARED_TCP_SOCKET
Definition: uv-common.h:110
@ UV_HANDLE_SHUTTING
Definition: uv-common.h:84
@ UV_HANDLE_TCP_ACCEPT_STATE_CHANGING
Definition: uv-common.h:108
@ UV_HANDLE_WRITABLE
Definition: uv-common.h:93
@ UV_HANDLE_CLOSED
Definition: uv-common.h:75
@ UV_HANDLE_SYNC_BYPASS_IOCP
Definition: uv-common.h:95
@ UV_HANDLE_TTY_RAW
Definition: uv-common.h:123
@ UV_HANDLE_INTERNAL
Definition: uv-common.h:78
@ UV_HANDLE_READ_PENDING
Definition: uv-common.h:94
@ UV_SIGNAL_ONE_SHOT_DISPATCHED
Definition: uv-common.h:128
@ UV_HANDLE_NON_OVERLAPPED_PIPE
Definition: uv-common.h:118
@ UV_HANDLE_BOUND
Definition: uv-common.h:91
@ UV_HANDLE_READABLE
Definition: uv-common.h:92
@ UV_HANDLE_TTY_READABLE
Definition: uv-common.h:122

◆ uv__work_kind

Enumerator
UV__WORK_CPU 
UV__WORK_FAST_IO 
UV__WORK_SLOW_IO 

Definition at line 191 of file uv-common.h.

191  {
192  UV__WORK_CPU,
195 };
@ UV__WORK_SLOW_IO
Definition: uv-common.h:194
@ UV__WORK_FAST_IO
Definition: uv-common.h:193
@ UV__WORK_CPU
Definition: uv-common.h:192

Function Documentation

◆ uv__calloc()

void* uv__calloc ( size_t  count,
size_t  size 
)

Definition at line 92 of file uv-common.c.

92  {
94 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
voidpf void uLong size
Definition: ioapi.h:138
uv_calloc_func local_calloc
Definition: uv-common.c:44
static uv__allocator_t uv__allocator
Definition: uv-common.c:48

References count, uv__allocator_t::local_calloc, and uv__allocator.

Referenced by uv__interface_addresses_v6(), uv__pipe_write_ipc(), uv_cpu_info(), uv_fs_poll_start(), uv_interface_addresses(), uv_loop_init(), and uv_os_environ().

◆ uv__count_bufs()

size_t uv__count_bufs ( const uv_buf_t  bufs[],
unsigned int  nbufs 
)

Definition at line 573 of file uv-common.c.

573  {
574  unsigned int i;
575  size_t bytes;
576 
577  bytes = 0;
578  for (i = 0; i < nbufs; i++)
579  bytes += (size_t) bufs[i].len;
580 
581  return bytes;
582 }
lzma_index ** i
Definition: index.h:629
static ut8 bytes[32]
Definition: asm_arc.c:23
static char bufs[4][128]
Buffers for uint64_to_str() and uint64_to_nicestr()
Definition: util.c:18

References bufs, bytes, and i.

Referenced by uv__send(), uv__tty_try_write(), uv__udp_run_completed(), uv__udp_send(), uv__write_req_size(), uv_tcp_write(), uv_try_write(), and uv_write2().

◆ uv__free()

void uv__free ( void *  ptr)

Definition at line 81 of file uv-common.c.

81  {
82  int saved_errno;
83 
84  /* Libuv expects that free() does not clobber errno. The system allocator
85  * honors that assumption but custom allocators may not be so careful.
86  */
87  saved_errno = errno;
89  errno = saved_errno;
90 }
uv_free_func local_free
Definition: uv-common.c:45

References uv__allocator_t::local_free, and uv__allocator.

Referenced by child_fork(), eof_timer_close_cb(), epoll_queue_close(), freeifaddrs(), freeResultList(), fs__closedir(), fs__create_junction(), fs__opendir(), fs__readdir(), fs__realpath_handle(), fs__scandir(), fs__sendfile(), fs__statfs(), getNetlinkResponse(), make_program_args(), make_program_env(), maybe_free_watcher_list(), os390_readlink(), scandir(), search_path_join_test(), timer_close_cb(), uv__convert_utf16_to_utf8(), uv__convert_utf8_to_utf16(), uv__custom_sem_destroy(), uv__custom_sem_init(), uv__dlerror(), uv__fd_hash_remove(), uv__fs_closedir(), uv__fs_opendir(), uv__fs_read(), uv__fs_readdir(), uv__fs_readdir_cleanup(), uv__fs_readlink(), uv__fs_realpath(), uv__fs_write_all(), uv__getaddrinfo_done(), uv__getpwuid_r(), uv__inotify_fork(), uv__io_fork(), uv__loop_close(), uv__loops_remove(), uv__pipe_close(), uv__pipe_getname(), uv__pipe_write_ipc(), uv__platform_loop_delete(), uv__process_title_cleanup(), uv__realloc(), uv__reallocf(), uv__search_path(), uv__stdio_destroy(), uv__stream_close(), uv__thread_start(), uv__threadpool_cleanup(), uv__udp_run_completed(), uv__write_callbacks(), uv__write_req_finish(), uv_accept(), uv_barrier_destroy(), uv_barrier_init(), uv_chdir(), uv_cpu_info(), uv_cwd(), uv_dlclose(), uv_exepath(), uv_free_cpu_info(), uv_free_interface_addresses(), uv_freeaddrinfo(), uv_fs_event_endgame(), uv_fs_event_start(), uv_fs_event_stop(), uv_fs_poll_start(), uv_fs_req_cleanup(), uv_getaddrinfo(), uv_interface_addresses(), uv_loop_delete(), uv_loop_init(), uv_loop_new(), uv_os_environ(), uv_os_free_environ(), uv_os_free_passwd(), uv_os_getenv(), uv_os_setenv(), uv_os_tmpdir(), uv_os_unsetenv(), uv_pipe_accept(), uv_pipe_bind(), uv_pipe_chmod(), uv_pipe_cleanup(), uv_pipe_connect(), uv_pipe_endgame(), uv_process_fs_event_req(), uv_process_pipe_write_req(), uv_set_process_title(), uv_spawn(), uv_split_path(), uv_tcp_endgame(), uv_thread_create_ex(), uv_try_write(), and uv_uptime().

◆ uv__fs_get_dirent_type()

uv_dirent_type_t uv__fs_get_dirent_type ( uv__dirent_t dent)

Definition at line 688 of file uv-common.c.

688  {
690 
691 #ifdef HAVE_DIRENT_TYPES
692  switch (dent->d_type) {
693  case UV__DT_DIR:
695  break;
696  case UV__DT_FILE:
698  break;
699  case UV__DT_LINK:
701  break;
702  case UV__DT_FIFO:
704  break;
705  case UV__DT_SOCKET:
707  break;
708  case UV__DT_CHAR:
710  break;
711  case UV__DT_BLOCK:
713  break;
714  default:
716  }
717 #else
719 #endif
720 
721  return type;
722 }
uv_dirent_type_t
Definition: uv.h:1139
@ UV_DIRENT_FIFO
Definition: uv.h:1144
@ UV_DIRENT_CHAR
Definition: uv.h:1146
@ UV_DIRENT_DIR
Definition: uv.h:1142
@ UV_DIRENT_UNKNOWN
Definition: uv.h:1140
@ UV_DIRENT_BLOCK
Definition: uv.h:1147
@ UV_DIRENT_LINK
Definition: uv.h:1143
@ UV_DIRENT_FILE
Definition: uv.h:1141
@ UV_DIRENT_SOCKET
Definition: uv.h:1145
#define UV__DT_SOCKET
Definition: win.h:314
#define UV__DT_FILE
Definition: win.h:311
#define UV__DT_FIFO
Definition: win.h:313
#define UV__DT_CHAR
Definition: win.h:315
#define UV__DT_DIR
Definition: win.h:310
#define UV__DT_BLOCK
Definition: win.h:316
#define UV__DT_LINK
Definition: win.h:312

References type, UV__DT_BLOCK, UV__DT_CHAR, UV__DT_DIR, UV__DT_FIFO, UV__DT_FILE, UV__DT_LINK, UV__DT_SOCKET, UV_DIRENT_BLOCK, UV_DIRENT_CHAR, UV_DIRENT_DIR, UV_DIRENT_FIFO, UV_DIRENT_FILE, UV_DIRENT_LINK, UV_DIRENT_SOCKET, and UV_DIRENT_UNKNOWN.

Referenced by fs__readdir(), uv__fs_readdir(), and uv_fs_scandir_next().

◆ uv__fs_poll_close()

void uv__fs_poll_close ( uv_fs_poll_t handle)

Definition at line 164 of file fs-poll.c.

164  {
166 
167  if (handle->poll_ctx == NULL)
169 }
static mcore_handle handle
Definition: asm_mcore.c:8
#define NULL
Definition: cris-opc.c:27
int uv_fs_poll_stop(uv_fs_poll_t *handle)
Definition: fs-poll.c:116
void uv__make_close_pending(uv_handle_t *handle)
Definition: core.c:208

References handle, NULL, uv__make_close_pending(), and uv_fs_poll_stop().

Referenced by uv_close().

◆ uv__fs_readdir_cleanup()

void uv__fs_readdir_cleanup ( uv_fs_t req)

Definition at line 724 of file uv-common.c.

724  {
725  uv_dir_t* dir;
726  uv_dirent_t* dirents;
727  int i;
728 
729  if (req->ptr == NULL)
730  return;
731 
732  dir = req->ptr;
733  dirents = dir->dirents;
734  req->ptr = NULL;
735 
736  if (dirents == NULL)
737  return;
738 
739  for (i = 0; i < req->result; ++i) {
740  uv__free((char*) dirents[i].name);
741  dirents[i].name = NULL;
742  }
743 }
Definition: z80asm.h:102
Definition: uv.h:1298
uv_dirent_t * dirents
Definition: uv.h:1299
const char * name
Definition: uv.h:1151
void uv__free(void *ptr)
Definition: uv-common.c:81

References uv_dir_s::dirents, i, uv_dirent_s::name, NULL, req, and uv__free().

Referenced by uv_fs_req_cleanup().

◆ uv__fs_scandir_cleanup()

void uv__fs_scandir_cleanup ( uv_fs_t req)

Definition at line 635 of file uv-common.c.

635  {
636  uv__dirent_t** dents;
637 
638  unsigned int* nbufs = uv__get_nbufs(req);
639 
640  dents = req->ptr;
641  if (*nbufs > 0 && *nbufs != (unsigned int) req->result)
642  (*nbufs)--;
643  for (; *nbufs < (unsigned int) req->result; (*nbufs)++)
644  uv__fs_scandir_free(dents[*nbufs]);
645 
646  uv__fs_scandir_free(req->ptr);
647  req->ptr = NULL;
648 }
static int
Definition: sfsocketcall.h:114
Definition: sftypes.h:48
#define uv__fs_scandir_free
Definition: uv-common.c:632
static unsigned int * uv__get_nbufs(uv_fs_t *req)
Definition: uv-common.c:617

References int, NULL, req, uv__fs_scandir_free, and uv__get_nbufs().

Referenced by uv_fs_req_cleanup().

◆ uv__getaddrinfo_translate_error()

int uv__getaddrinfo_translate_error ( int  sys_err)

Definition at line 42 of file getaddrinfo.c.

42  {
43  switch (sys_err) {
44  case 0: return 0;
45 #if defined(EAI_ADDRFAMILY)
46  case EAI_ADDRFAMILY: return UV_EAI_ADDRFAMILY;
47 #endif
48 #if defined(EAI_AGAIN)
49  case EAI_AGAIN: return UV_EAI_AGAIN;
50 #endif
51 #if defined(EAI_BADFLAGS)
52  case EAI_BADFLAGS: return UV_EAI_BADFLAGS;
53 #endif
54 #if defined(EAI_BADHINTS)
55  case EAI_BADHINTS: return UV_EAI_BADHINTS;
56 #endif
57 #if defined(EAI_CANCELED)
58  case EAI_CANCELED: return UV_EAI_CANCELED;
59 #endif
60 #if defined(EAI_FAIL)
61  case EAI_FAIL: return UV_EAI_FAIL;
62 #endif
63 #if defined(EAI_FAMILY)
64  case EAI_FAMILY: return UV_EAI_FAMILY;
65 #endif
66 #if defined(EAI_MEMORY)
67  case EAI_MEMORY: return UV_EAI_MEMORY;
68 #endif
69 #if defined(EAI_NODATA)
70  case EAI_NODATA: return UV_EAI_NODATA;
71 #endif
72 #if defined(EAI_NONAME)
73 # if !defined(EAI_NODATA) || EAI_NODATA != EAI_NONAME
74  case EAI_NONAME: return UV_EAI_NONAME;
75 # endif
76 #endif
77 #if defined(EAI_OVERFLOW)
78  case EAI_OVERFLOW: return UV_EAI_OVERFLOW;
79 #endif
80 #if defined(EAI_PROTOCOL)
81  case EAI_PROTOCOL: return UV_EAI_PROTOCOL;
82 #endif
83 #if defined(EAI_SERVICE)
84  case EAI_SERVICE: return UV_EAI_SERVICE;
85 #endif
86 #if defined(EAI_SOCKTYPE)
87  case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE;
88 #endif
89 #if defined(EAI_SYSTEM)
90  case EAI_SYSTEM: return UV__ERR(errno);
91 #endif
92  }
93  assert(!"unknown EAI_* error code");
94  abort();
95 #ifndef __SUNPRO_C
96  return 0; /* Pacify compiler. */
97 #endif
98 }
#define UV__ERR(x)
Definition: errno.h:29
assert(limit<=UINT32_MAX/2)

References assert(), UV__ERR, and uv_translate_sys_error().

Referenced by uv__getaddrinfo_work(), and uv__getnameinfo_work().

◆ uv__loop_close()

void uv__loop_close ( uv_loop_t loop)

Definition at line 165 of file loop.c.

165  {
167 
171 
172  if (loop->emfile_fd != -1) {
173  uv__close(loop->emfile_fd);
174  loop->emfile_fd = -1;
175  }
176 
177  if (loop->backend_fd != -1) {
178  uv__close(loop->backend_fd);
179  loop->backend_fd = -1;
180  }
181 
182  uv_mutex_lock(&loop->wq_mutex);
183  assert(QUEUE_EMPTY(&loop->wq) && "thread pool work queue not empty!");
185  uv_mutex_unlock(&loop->wq_mutex);
186  uv_mutex_destroy(&loop->wq_mutex);
187 
188  /*
189  * Note that all thread pool stuff is finished at this point and
190  * it is safe to just destroy rw lock
191  */
192  uv_rwlock_destroy(&loop->cloexec_lock);
193 
194 #if 0
195  assert(QUEUE_EMPTY(&loop->pending_queue));
196  assert(QUEUE_EMPTY(&loop->watcher_queue));
197  assert(loop->nfds == 0);
198 #endif
199 
200  uv__free(loop->watchers);
201  loop->watchers = NULL;
202  loop->nwatchers = 0;
203 
204  lfields = uv__get_internal_fields(loop);
206  uv__free(lfields);
208 }
void uv__platform_loop_delete(uv_loop_t *loop)
Definition: aix.c:95
#define QUEUE_EMPTY(q)
Definition: queue.h:39
uv__loop_metrics_t loop_metrics
Definition: uv-common.h:365
uv_mutex_t lock
Definition: uv-common.h:357
void * internal_fields
Definition: uv.h:1791
int uv__close(int fd)
Definition: core.c:569
void uv__signal_loop_cleanup(uv_loop_t *loop)
Definition: signal.c:291
void uv__async_stop(uv_loop_t *loop)
Definition: async.c:240
#define uv__get_internal_fields(loop)
Definition: uv-common.h:336
UV_EXTERN void uv_mutex_lock(uv_mutex_t *handle)
Definition: thread.c:330
UV_EXTERN void uv_mutex_destroy(uv_mutex_t *handle)
Definition: thread.c:324
UV_EXTERN void uv_mutex_unlock(uv_mutex_t *handle)
Definition: thread.c:350
UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t *rwlock)
Definition: thread.c:361

References ARRAY_SIZE, assert(), i, uv_loop_s::internal_fields, uv__loop_metrics_s::lock, loop, uv__loop_internal_fields_s::loop_metrics, NULL, QUEUE_EMPTY, uv__async_stop(), uv__close(), uv__free(), uv__get_internal_fields, uv__handle_close, uv__handle_closing, uv__has_active_reqs, uv__loops_remove(), uv__platform_loop_delete(), uv__signal_loop_cleanup(), uv_mutex_destroy(), uv_mutex_lock(), uv_mutex_unlock(), and uv_rwlock_destroy().

Referenced by uv_loop_close().

◆ uv__loop_configure()

int uv__loop_configure ( uv_loop_t loop,
uv_loop_option  option,
va_list  ap 
)

Definition at line 211 of file loop.c.

211  {
213 
214  lfields = uv__get_internal_fields(loop);
215  if (option == UV_METRICS_IDLE_TIME) {
216  lfields->flags |= UV_METRICS_IDLE_TIME;
217  return 0;
218  }
219 
221  return UV_ENOSYS;
222 
223  if (va_arg(ap, int) != SIGPROF)
224  return UV_EINVAL;
225 
226  loop->flags |= UV_LOOP_BLOCK_SIGPROF;
227  return 0;
228 }
Definition: getopt.h:84
@ UV_LOOP_BLOCK_SIGPROF
Definition: internal.h:137
@ UV_LOOP_BLOCK_SIGNAL
Definition: uv.h:250
@ UV_METRICS_IDLE_TIME
Definition: uv.h:251

References uv__loop_internal_fields_s::flags, loop, uv__get_internal_fields, UV_LOOP_BLOCK_SIGNAL, UV_LOOP_BLOCK_SIGPROF, and UV_METRICS_IDLE_TIME.

Referenced by uv_loop_configure().

◆ uv__malloc()

void* uv__malloc ( size_t  size)

Definition at line 75 of file uv-common.c.

75  {
76  if (size > 0)
78  return NULL;
79 }
uv_malloc_func local_malloc
Definition: uv-common.c:42

References uv__allocator_t::local_malloc, NULL, and uv__allocator.

Referenced by eof_timer_init(), epoll_create1(), fs__capture_path(), fs__create_junction(), fs__opendir(), fs__realpath_handle(), fs__scandir(), fs__sendfile(), fs__statfs(), fs__wide_to_utf8(), getNetlinkResponse(), init_threads(), interpretAddr(), interpretLink(), make_program_args(), make_program_env(), newListItem(), os390_readlink(), scandir(), search_path_join_test(), uv__build_coalesced_write_req(), uv__convert_utf16_to_utf8(), uv__convert_utf8_to_utf16(), uv__custom_sem_init(), uv__fd_hash_add(), uv__fs_opendir(), uv__fs_readlink(), uv__fs_realpath(), uv__fs_statfs(), uv__getaddrinfo_done(), uv__getpwuid_r(), uv__interface_addresses_v6(), uv__pipe_getname(), uv__pipe_queue_ipc_xfer_info(), uv__stdio_create(), uv__strdup(), uv__stream_queue_fd(), uv__strndup(), uv__udp_send(), uv_barrier_init(), uv_chdir(), uv_cpu_info(), uv_cwd(), uv_exepath(), uv_fs_event_start(), uv_fs_read(), uv_fs_write(), uv_getaddrinfo(), uv_interface_addresses(), uv_loop_init(), uv_loop_new(), uv_os_getenv(), uv_os_tmpdir(), uv_pipe_bind(), uv_pipe_chmod(), uv_pipe_connect(), uv_process_fs_event_req(), uv_relative_path(), uv_set_process_title(), uv_setup_args(), uv_spawn(), uv_split_path(), uv_tcp_listen(), uv_thread_create_ex(), uv_uptime(), uv_utf8_to_utf16_alloc(), and uv_write2().

◆ uv__metrics_set_provider_entry_time()

void uv__metrics_set_provider_entry_time ( uv_loop_t loop)

Definition at line 899 of file uv-common.c.

899  {
900  uv__loop_metrics_t* loop_metrics;
901  uint64_t now;
902 
904  return;
905 
906  now = uv_hrtime();
907  loop_metrics = uv__get_loop_metrics(loop);
908  uv_mutex_lock(&loop_metrics->lock);
909  loop_metrics->provider_entry_time = now;
910  uv_mutex_unlock(&loop_metrics->lock);
911 }
unsigned long uint64_t
Definition: sftypes.h:28
uint64_t provider_entry_time
Definition: uv-common.h:355
#define uv__get_loop_metrics(loop)
Definition: uv-common.h:339
UV_EXTERN uint64_t uv_hrtime(void)
Definition: core.c:103

References flags, uv__loop_metrics_s::lock, loop, uv__loop_metrics_s::provider_entry_time, uv__get_internal_fields, uv__get_loop_metrics, uv_hrtime(), UV_METRICS_IDLE_TIME, uv_mutex_lock(), and uv_mutex_unlock().

Referenced by uv__io_poll(), uv__poll(), and uv__poll_wine().

◆ uv__metrics_update_idle_time()

void uv__metrics_update_idle_time ( uv_loop_t loop)

Definition at line 872 of file uv-common.c.

872  {
873  uv__loop_metrics_t* loop_metrics;
874  uint64_t entry_time;
875  uint64_t exit_time;
876 
878  return;
879 
880  loop_metrics = uv__get_loop_metrics(loop);
881 
882  /* The thread running uv__metrics_update_idle_time() is always the same
883  * thread that sets provider_entry_time. So it's unnecessary to lock before
884  * retrieving this value.
885  */
886  if (loop_metrics->provider_entry_time == 0)
887  return;
888 
889  exit_time = uv_hrtime();
890 
891  uv_mutex_lock(&loop_metrics->lock);
892  entry_time = loop_metrics->provider_entry_time;
893  loop_metrics->provider_entry_time = 0;
894  loop_metrics->provider_idle_time += exit_time - entry_time;
895  uv_mutex_unlock(&loop_metrics->lock);
896 }
uint64_t provider_idle_time
Definition: uv-common.h:356

References flags, uv__loop_metrics_s::lock, loop, uv__loop_metrics_s::provider_entry_time, uv__loop_metrics_s::provider_idle_time, uv__get_internal_fields, uv__get_loop_metrics, uv_hrtime(), UV_METRICS_IDLE_TIME, uv_mutex_lock(), and uv_mutex_unlock().

Referenced by uv__io_poll(), uv__poll(), uv__poll_wine(), and uv_run().

◆ uv__next_timeout()

int uv__next_timeout ( const uv_loop_t loop)

Definition at line 141 of file timer.c.

141  {
142  const struct heap_node* heap_node;
143  const uv_timer_t* handle;
144  uint64_t diff;
145 
146  heap_node = heap_min(timer_heap(loop));
147  if (heap_node == NULL)
148  return -1; /* block indefinitely */
149 
151  if (handle->timeout <= loop->time)
152  return 0;
153 
154  diff = handle->timeout - loop->time;
155  if (diff > INT_MAX)
156  diff = INT_MAX;
157 
158  return (int) diff;
159 }
#define INT_MAX
Definition: cp-demangle.c:131
#define container_of(ptr, type, member)
Definition: rz_types.h:650
Definition: uv.h:860
static struct heap * timer_heap(const uv_loop_t *loop)
Definition: timer.c:29

References container_of, handle, INT_MAX, loop, NULL, and timer_heap().

Referenced by uv_backend_timeout().

◆ uv__process_title_cleanup()

void uv__process_title_cleanup ( void  )

Definition at line 987 of file aix.c.

987  {
988  uv__free(args_mem); /* Keep valgrind happy. */
989  args_mem = NULL;
990 }
static void * args_mem
Definition: aix.c:71

References args_mem, NULL, and uv__free().

Referenced by uv_library_shutdown().

◆ uv__realloc()

void* uv__realloc ( void *  ptr,
size_t  size 
)

Definition at line 96 of file uv-common.c.

96  {
97  if (size > 0)
98  return uv__allocator.local_realloc(ptr, size);
99  uv__free(ptr);
100  return NULL;
101 }
uv_realloc_func local_realloc
Definition: uv-common.c:43

References uv__allocator_t::local_realloc, NULL, uv__allocator, and uv__free().

Referenced by fs__scandir(), scandir(), uv__loops_add(), uv__loops_remove(), uv__reallocf(), and uv__stream_queue_fd().

◆ uv__reallocf()

void* uv__reallocf ( void *  ptr,
size_t  size 
)

Definition at line 103 of file uv-common.c.

103  {
104  void* newptr;
105 
106  newptr = uv__realloc(ptr, size);
107  if (newptr == NULL)
108  if (size > 0)
109  uv__free(ptr);
110 
111  return newptr;
112 }
void * uv__realloc(void *ptr, size_t size)
Definition: uv-common.c:96

References NULL, uv__free(), and uv__realloc().

Referenced by fs__statfs(), maybe_resize(), uv__fs_readlink(), uv__pollfds_maybe_resize(), and uv_exepath().

◆ uv__run_timers()

void uv__run_timers ( uv_loop_t loop)

Definition at line 162 of file timer.c.

162  {
163  struct heap_node* heap_node;
165 
166  for (;;) {
167  heap_node = heap_min(timer_heap(loop));
168  if (heap_node == NULL)
169  break;
170 
172  if (handle->timeout > loop->time)
173  break;
174 
177  handle->timer_cb(handle);
178  }
179 }
int uv_timer_stop(uv_timer_t *handle)
Definition: timer.c:97
int uv_timer_again(uv_timer_t *handle)
Definition: timer.c:110

References container_of, handle, loop, NULL, timer_heap(), uv_timer_again(), and uv_timer_stop().

Referenced by uv_run().

◆ uv__signal_cleanup()

void uv__signal_cleanup ( void  )

Definition at line 80 of file signal.c.

80  {
81  /* We can only use signal-safe functions here.
82  * That includes read/write and close, fortunately.
83  * We do all of this directly here instead of resetting
84  * uv__signal_global_init_guard because
85  * uv__signal_global_once_init is only called from uv_loop_init
86  * and this needs to function in existing loops.
87  */
88  if (uv__signal_lock_pipefd[0] != -1) {
90  uv__signal_lock_pipefd[0] = -1;
91  }
92 
93  if (uv__signal_lock_pipefd[1] != -1) {
95  uv__signal_lock_pipefd[1] = -1;
96  }
97 }
static int uv__signal_lock_pipefd[2]
Definition: signal.c:57

References uv__close(), and uv__signal_lock_pipefd.

Referenced by uv__signal_global_reinit(), and uv_library_shutdown().

◆ uv__socket_sockopt()

int uv__socket_sockopt ( uv_handle_t handle,
int  optname,
int value 
)

Definition at line 180 of file core.c.

180  {
181  int r;
182  int fd;
183  socklen_t len;
184 
185  if (handle == NULL || value == NULL)
186  return UV_EINVAL;
187 
188  if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE)
190  else if (handle->type == UV_UDP)
191  fd = ((uv_udp_t *) handle)->io_watcher.fd;
192  else
193  return UV_ENOTSUP;
194 
195  len = sizeof(*value);
196 
197  if (*value == 0)
198  r = getsockopt(fd, SOL_SOCKET, optname, value, &len);
199  else
200  r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len);
201 
202  if (r < 0)
203  return UV__ERR(errno);
204 
205  return 0;
206 }
size_t len
Definition: 6502dis.c:15
static int value
Definition: cmd_api.c:93
#define r
Definition: crypto_rc6.c:12
unsigned int socklen_t
Definition: sftypes.h:219
#define SOL_SOCKET
Definition: sftypes.h:427
Definition: uv.h:638
#define uv__stream_fd(handle)
Definition: internal.h:282
static const z80_opcode fd[]
Definition: z80_tab.h:997

References fd, handle, len, NULL, r, socket, SOL_SOCKET, UV__ERR, uv__stream_fd, uv_translate_sys_error(), and value.

Referenced by uv_recv_buffer_size(), and uv_send_buffer_size().

◆ uv__strdup()

char* uv__strdup ( const char *  s)

Definition at line 55 of file uv-common.c.

55  {
56  size_t len = strlen(s) + 1;
57  char* m = uv__malloc(len);
58  if (m == NULL)
59  return NULL;
60  return memcpy(m, s, len);
61 }
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static RzSocket * s
Definition: rtr.c:28
void * uv__malloc(size_t size)
Definition: uv-common.c:75

References len, regress::m, memcpy(), NULL, s, and uv__malloc().

Referenced by uv__dlerror(), uv__fs_readdir(), uv__inotify_fork(), uv__interface_addresses_v6(), uv__search_path(), uv__unknown_err_code(), uv_cpu_info(), uv_fs_event_start(), uv_fs_mkdtemp(), uv_fs_mkstemp(), uv_interface_addresses(), uv_os_environ(), uv_pipe_bind(), uv_set_process_title(), and uv_setup_args().

◆ uv__strndup()

char* uv__strndup ( const char *  s,
size_t  n 
)

Definition at line 63 of file uv-common.c.

63  {
64  char* m;
65  size_t len = strlen(s);
66  if (n < len)
67  len = n;
68  m = uv__malloc(len + 1);
69  if (m == NULL)
70  return NULL;
71  m[len] = '\0';
72  return memcpy(m, s, len);
73 }
int n
Definition: mipsasm.c:19

References len, regress::m, memcpy(), n, NULL, s, and uv__malloc().

Referenced by read_models().

◆ uv__tcp_bind()

int uv__tcp_bind ( uv_tcp_t tcp,
const struct sockaddr addr,
unsigned int  addrlen,
unsigned int  flags 
)

Definition at line 148 of file tcp.c.

151  {
152  int err;
153  int on;
154 
155  /* Cannot set IPv6-only mode on non-IPv6 socket. */
156  if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6)
157  return UV_EINVAL;
158 
159  err = maybe_new_socket(tcp, addr->sa_family, 0);
160  if (err)
161  return err;
162 
163  on = 1;
164  if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
165  return UV__ERR(errno);
166 
167 #ifndef __OpenBSD__
168 #ifdef IPV6_V6ONLY
169  if (addr->sa_family == AF_INET6) {
170  on = (flags & UV_TCP_IPV6ONLY) != 0;
171  if (setsockopt(tcp->io_watcher.fd,
172  IPPROTO_IPV6,
173  IPV6_V6ONLY,
174  &on,
175  sizeof on) == -1) {
176 #if defined(__MVS__)
177  if (errno == EOPNOTSUPP)
178  return UV_EINVAL;
179 #endif
180  return UV__ERR(errno);
181  }
182  }
183 #endif
184 #endif
185 
186  errno = 0;
187  if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE) {
188  if (errno == EAFNOSUPPORT)
189  /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
190  * socket created with AF_INET to an AF_INET6 address or vice versa. */
191  return UV_EINVAL;
192  return UV__ERR(errno);
193  }
194  tcp->delayed_error = UV__ERR(errno);
195 
196  tcp->flags |= UV_HANDLE_BOUND;
197  if (addr->sa_family == AF_INET6)
198  tcp->flags |= UV_HANDLE_IPV6;
199 
200  return 0;
201 }
static bool err
Definition: armass.c:435
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol struct sockaddr addrlen
Definition: sflib.h:75
static bind
Definition: sfsocketcall.h:114
#define EOPNOTSUPP
Definition: sftypes.h:155
#define EAFNOSUPPORT
Definition: sftypes.h:157
#define SO_REUSEADDR
Definition: sftypes.h:430
#define EADDRINUSE
Definition: sftypes.h:158
#define AF_INET6
Definition: sftypes.h:295
static int maybe_new_socket(uv_tcp_t *handle, int domain, unsigned long flags)
Definition: tcp.c:67
@ UV_TCP_IPV6ONLY
Definition: uv.h:564
#define IPV6_V6ONLY
Definition: winsock.h:46
static int addr
Definition: z80asm.c:58

References addr, addrlen, AF_INET6, bind, EADDRINUSE, EAFNOSUPPORT, EOPNOTSUPP, err, flags, handle, IPV6_V6ONLY, maybe_new_socket(), SO_REUSEADDR, SOL_SOCKET, UV__ERR, UV_HANDLE_BOUND, UV_HANDLE_IPV6, UV_TCP_IPV6ONLY, uv_tcp_try_bind(), and uv_translate_sys_error().

Referenced by uv_tcp_bind().

◆ uv__tcp_connect()

int uv__tcp_connect ( uv_connect_t req,
uv_tcp_t handle,
const struct sockaddr addr,
unsigned int  addrlen,
uv_connect_cb  cb 
)

Definition at line 204 of file tcp.c.

208  {
209  int err;
210  int r;
211 
212  assert(handle->type == UV_TCP);
213 
214  if (handle->connect_req != NULL)
215  return UV_EALREADY; /* FIXME(bnoordhuis) UV_EINVAL or maybe UV_EBUSY. */
216 
218  addr->sa_family,
220  if (err)
221  return err;
222 
223  handle->delayed_error = 0;
224 
225  do {
226  errno = 0;
227  r = connect(uv__stream_fd(handle), addr, addrlen);
228  } while (r == -1 && errno == EINTR);
229 
230  /* We not only check the return value, but also check the errno != 0.
231  * Because in rare cases connect() will return -1 but the errno
232  * is 0 (for example, on Android 4.3, OnePlus phone A0001_12_150227)
233  * and actually the tcp three-way handshake is completed.
234  */
235  if (r == -1 && errno != 0) {
236  if (errno == EINPROGRESS)
237  ; /* not an error */
238  else if (errno == ECONNREFUSED
239 #if defined(__OpenBSD__)
240  || errno == EINVAL
241 #endif
242  )
243  /* If we get ECONNREFUSED (Solaris) or EINVAL (OpenBSD) wait until the
244  * next tick to report the error. Solaris and OpenBSD wants to report
245  * immediately -- other unixes want to wait.
246  */
247  handle->delayed_error = UV__ERR(ECONNREFUSED);
248  else
249  return UV__ERR(errno);
250  }
251 
252  uv__req_init(handle->loop, req, UV_CONNECT);
253  req->cb = cb;
254  req->handle = (uv_stream_t*) handle;
255  QUEUE_INIT(&req->queue);
256  handle->connect_req = req;
257 
258  uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
259 
260  if (handle->delayed_error)
261  uv__io_feed(handle->loop, &handle->io_watcher);
262 
263  return 0;
264 }
#define QUEUE_INIT(q)
Definition: queue.h:45
#define EINVAL
Definition: sftypes.h:132
#define EINTR
Definition: sftypes.h:114
#define EINPROGRESS
Definition: sftypes.h:175
#define ECONNREFUSED
Definition: sftypes.h:171
void uv__io_start(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: core.c:882
void uv__io_feed(uv_loop_t *loop, uv__io_t *w)
Definition: core.c:952
#define uv__req_init(loop, req, typ)
Definition: uv-common.h:329
static const char * cb[]
Definition: z80_tab.h:176

References addr, addrlen, assert(), cb, ECONNREFUSED, EINPROGRESS, EINTR, EINVAL, err, handle, maybe_new_socket(), NULL, QUEUE_INIT, r, req, UV__ERR, uv__io_feed(), uv__io_start(), uv__req_init, uv__stream_fd, UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_tcp_try_connect(), and uv_translate_sys_error().

Referenced by uv_tcp_connect().

◆ uv__threadpool_cleanup()

void uv__threadpool_cleanup ( void  )

Definition at line 163 of file threadpool.c.

163  {
164 #ifndef _WIN32
165  unsigned int i;
166 
167  if (nthreads == 0)
168  return;
169 
171 
172  for (i = 0; i < nthreads; i++)
173  if (uv_thread_join(threads + i))
174  abort();
175 
176  if (threads != default_threads)
177  uv__free(threads);
178 
181 
182  threads = NULL;
183  nthreads = 0;
184 #endif
185 }
static QUEUE exit_message
Definition: threadpool.c:40
static uv_mutex_t mutex
Definition: threadpool.c:34
static unsigned int nthreads
Definition: threadpool.c:37
static uv_thread_t * threads
Definition: threadpool.c:38
static void post(QUEUE *q, enum uv__work_kind kind)
Definition: threadpool.c:142
static uv_cond_t cond
Definition: threadpool.c:33
static uv_thread_t default_threads[4]
Definition: threadpool.c:39
UV_EXTERN int uv_thread_join(uv_thread_t *tid)
Definition: thread.c:272
UV_EXTERN void uv_cond_destroy(uv_cond_t *cond)
Definition: thread.c:735

References cond, default_threads, exit_message, i, mutex, nthreads, NULL, post(), threads, uv__free(), UV__WORK_CPU, uv_cond_destroy(), uv_mutex_destroy(), and uv_thread_join().

Referenced by uv_library_shutdown().

◆ uv__timer_close()

void uv__timer_close ( uv_timer_t handle)

Definition at line 182 of file timer.c.

182  {
184 }

References handle, and uv_timer_stop().

Referenced by uv_close(), and uv_process_endgames().

◆ uv__udp_bind()

int uv__udp_bind ( uv_udp_t handle,
const struct sockaddr addr,
unsigned int  addrlen,
unsigned int  flags 
)

Definition at line 508 of file udp.c.

511  {
512  int err;
513  int yes;
514  int fd;
515 
516  /* Check for bad flags. */
518  return UV_EINVAL;
519 
520  /* Cannot set IPv6-only mode on non-IPv6 socket. */
521  if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6)
522  return UV_EINVAL;
523 
524  fd = handle->io_watcher.fd;
525  if (fd == -1) {
526  err = uv__socket(addr->sa_family, SOCK_DGRAM, 0);
527  if (err < 0)
528  return err;
529  fd = err;
530  handle->io_watcher.fd = fd;
531  }
532 
533  if (flags & UV_UDP_REUSEADDR) {
534  err = uv__set_reuse(fd);
535  if (err)
536  return err;
537  }
538 
539  if (flags & UV_UDP_IPV6ONLY) {
540 #ifdef IPV6_V6ONLY
541  yes = 1;
542  if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof yes) == -1) {
543  err = UV__ERR(errno);
544  return err;
545  }
546 #else
547  err = UV_ENOTSUP;
548  return err;
549 #endif
550  }
551 
552  if (bind(fd, addr, addrlen)) {
553  err = UV__ERR(errno);
554  if (errno == EAFNOSUPPORT)
555  /* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
556  * socket created with AF_INET to an AF_INET6 address or vice versa. */
557  err = UV_EINVAL;
558  return err;
559  }
560 
561  if (addr->sa_family == AF_INET6)
562  handle->flags |= UV_HANDLE_IPV6;
563 
564  handle->flags |= UV_HANDLE_BOUND;
565  return 0;
566 }
@ SOCK_DGRAM
Definition: sftypes.h:227
int uv__socket(int domain, int type, int protocol)
Definition: core.c:436
static int uv__set_reuse(int fd)
Definition: udp.c:480
@ UV_UDP_IPV6ONLY
Definition: uv.h:597
@ UV_UDP_REUSEADDR
Definition: uv.h:611

References addr, addrlen, AF_INET6, bind, EAFNOSUPPORT, err, fd, flags, handle, IPV6_V6ONLY, SOCK_DGRAM, UV__ERR, uv__set_reuse(), uv__socket(), UV_HANDLE_BOUND, UV_HANDLE_IPV6, UV_UDP_IPV6ONLY, and UV_UDP_REUSEADDR.

Referenced by uv__udp_maybe_deferred_bind(), and uv_udp_bind().

◆ uv__udp_connect()

int uv__udp_connect ( uv_udp_t handle,
const struct sockaddr addr,
unsigned int  addrlen 
)

Definition at line 606 of file udp.c.

608  {
609  int err;
610 
611  err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
612  if (err)
613  return err;
614 
615  do {
616  errno = 0;
617  err = connect(handle->io_watcher.fd, addr, addrlen);
618  } while (err == -1 && errno == EINTR);
619 
620  if (err)
621  return UV__ERR(errno);
622 
624 
625  return 0;
626 }
static int uv__udp_maybe_deferred_bind(uv_udp_t *handle, int domain, unsigned int flags)
Definition: udp.c:569

References addr, addrlen, EINTR, err, handle, UV__ERR, uv__udp_maybe_deferred_bind(), uv_addr_ip4_any_, uv_addr_ip6_any_, UV_HANDLE_BOUND, UV_HANDLE_UDP_CONNECTED, uv_translate_sys_error(), and uv_udp_maybe_bind().

Referenced by uv_udp_connect().

◆ uv__udp_disconnect()

int uv__udp_disconnect ( uv_udp_t handle)

Definition at line 629 of file udp.c.

629  {
630  int r;
631  struct sockaddr addr;
632 
633  memset(&addr, 0, sizeof(addr));
634 
635  addr.sa_family = AF_UNSPEC;
636 
637  do {
638  errno = 0;
639  r = connect(handle->io_watcher.fd, &addr, sizeof(addr));
640  } while (r == -1 && errno == EINTR);
641 
642  if (r == -1 && errno != EAFNOSUPPORT)
643  return UV__ERR(errno);
644 
645  handle->flags &= ~UV_HANDLE_UDP_CONNECTED;
646  return 0;
647 }
return memset(p, 0, total)
#define AF_UNSPEC
Definition: sftypes.h:283

References addr, AF_UNSPEC, EAFNOSUPPORT, EINTR, err, handle, memset(), r, UV__ERR, UV_HANDLE_UDP_CONNECTED, and uv_translate_sys_error().

Referenced by uv_udp_connect().

◆ uv__udp_init_ex()

int uv__udp_init_ex ( uv_loop_t loop,
uv_udp_t handle,
unsigned  flags,
int  domain 
)

Definition at line 954 of file udp.c.

957  {
958  int fd;
959 
960  fd = -1;
961  if (domain != AF_UNSPEC) {
963  if (fd < 0)
964  return fd;
965  }
966 
968  handle->alloc_cb = NULL;
969  handle->recv_cb = NULL;
970  handle->send_queue_size = 0;
971  handle->send_queue_count = 0;
972  uv__io_init(&handle->io_watcher, uv__udp_io, fd);
973  QUEUE_INIT(&handle->write_queue);
974  QUEUE_INIT(&handle->write_completed_queue);
975 
976  return 0;
977 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd domain
Definition: sflib.h:79
void uv__io_init(uv__io_t *w, uv__io_cb cb, int fd)
Definition: core.c:865
static void uv__udp_io(uv_loop_t *loop, uv__io_t *w, unsigned int revents)
Definition: udp.c:173
#define uv__handle_init(loop_, h, type_)
Definition: uv-common.h:301

References AF_UNSPEC, domain, DWORD, err, fd, handle, loop, NULL, QUEUE_INIT, QUEUE_REMOVE, SOCK_DGRAM, socket, uv__handle_init, uv__io_init(), uv__socket(), uv__udp_io(), UV_REQ_INIT, uv_translate_sys_error(), and uv_udp_set_socket().

Referenced by uv_udp_init_ex().

◆ uv__udp_is_connected()

int uv__udp_is_connected ( uv_udp_t handle)

Definition at line 393 of file uv-common.c.

393  {
394  struct sockaddr_storage addr;
395  int addrlen;
396  if (handle->type != UV_UDP)
397  return 0;
398 
399  addrlen = sizeof(addr);
400  if (uv_udp_getpeername(handle, (struct sockaddr*) &addr, &addrlen) != 0)
401  return 0;
402 
403  return addrlen > 0;
404 }
UV_EXTERN int uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, int *namelen)
Definition: udp.c:1276

References addr, addrlen, handle, and uv_udp_getpeername().

Referenced by uv_udp_open().

◆ uv__udp_recv_start()

int uv__udp_recv_start ( uv_udp_t handle,
uv_alloc_cb  alloccb,
uv_udp_recv_cb  recv_cb 
)

Definition at line 1297 of file udp.c.

1299  {
1300  int err;
1301 
1302  if (alloc_cb == NULL || recv_cb == NULL)
1303  return UV_EINVAL;
1304 
1305  if (uv__io_active(&handle->io_watcher, POLLIN))
1306  return UV_EALREADY; /* FIXME(bnoordhuis) Should be UV_EBUSY. */
1307 
1309  if (err)
1310  return err;
1311 
1312  handle->alloc_cb = alloc_cb;
1313  handle->recv_cb = recv_cb;
1314 
1315  uv__io_start(handle->loop, &handle->io_watcher, POLLIN);
1317 
1318  return 0;
1319 }
#define AF_INET
Definition: sftypes.h:287
int uv__io_active(const uv__io_t *w, unsigned int events)
Definition: core.c:958
#define uv__handle_start(h)
Definition: uv-common.h:258

References AF_INET, err, handle, INCREASE_ACTIVE_COUNT, loop, NULL, uv__handle_start, uv__io_active(), uv__io_start(), uv__udp_maybe_deferred_bind(), uv_addr_ip4_any_, UV_HANDLE_READ_PENDING, UV_HANDLE_READING, uv_translate_sys_error(), uv_udp_maybe_bind(), and uv_udp_queue_recv().

Referenced by uv_udp_recv_start().

◆ uv__udp_recv_stop()

int uv__udp_recv_stop ( uv_udp_t handle)

Definition at line 1322 of file udp.c.

1322  {
1323  uv__io_stop(handle->loop, &handle->io_watcher, POLLIN);
1324 
1325  if (!uv__io_active(&handle->io_watcher, POLLOUT))
1327 
1328  handle->alloc_cb = NULL;
1329  handle->recv_cb = NULL;
1330 
1331  return 0;
1332 }
void uv__io_stop(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: core.c:910
#define uv__handle_stop(h)
Definition: uv-common.h:266

References DECREASE_ACTIVE_COUNT, handle, loop, and UV_HANDLE_READING.

Referenced by uv_udp_recv_stop().

◆ uv__udp_send()

int uv__udp_send ( uv_udp_send_t req,
uv_udp_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
const struct sockaddr addr,
unsigned int  addrlen,
uv_udp_send_cb  send_cb 
)

Definition at line 650 of file udp.c.

656  {
657  int err;
658  int empty_queue;
659 
660  assert(nbufs > 0);
661 
662  if (addr) {
663  err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
664  if (err)
665  return err;
666  }
667 
668  /* It's legal for send_queue_count > 0 even when the write_queue is empty;
669  * it means there are error-state requests in the write_completed_queue that
670  * will touch up send_queue_size/count later.
671  */
672  empty_queue = (handle->send_queue_count == 0);
673 
674  uv__req_init(handle->loop, req, UV_UDP_SEND);
675  assert(addrlen <= sizeof(req->addr));
676  if (addr == NULL)
677  req->addr.ss_family = AF_UNSPEC;
678  else
679  memcpy(&req->addr, addr, addrlen);
680  req->send_cb = send_cb;
681  req->handle = handle;
682  req->nbufs = nbufs;
683 
684  req->bufs = req->bufsml;
685  if (nbufs > ARRAY_SIZE(req->bufsml))
686  req->bufs = uv__malloc(nbufs * sizeof(bufs[0]));
687 
688  if (req->bufs == NULL) {
689  uv__req_unregister(handle->loop, req);
690  return UV_ENOMEM;
691  }
692 
693  memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0]));
694  handle->send_queue_size += uv__count_bufs(req->bufs, req->nbufs);
695  handle->send_queue_count++;
696  QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue);
698 
699  if (empty_queue && !(handle->flags & UV_HANDLE_UDP_PROCESSING)) {
701 
702  /* `uv__udp_sendmsg` may not be able to do non-blocking write straight
703  * away. In such cases the `io_watcher` has to be queued for asynchronous
704  * write.
705  */
706  if (!QUEUE_EMPTY(&handle->write_queue))
707  uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
708  } else {
709  uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
710  }
711 
712  return 0;
713 }
#define ARRAY_SIZE(a)
#define QUEUE_INSERT_TAIL(h, q)
Definition: queue.h:92
static void uv__udp_sendmsg(uv_udp_t *handle)
Definition: udp.c:406
size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs)
Definition: uv-common.c:573
#define uv__req_unregister(loop, req)
Definition: uv-common.h:230

References addr, addrlen, AF_UNSPEC, ARRAY_SIZE, assert(), bufs, err, handle, memcpy(), NULL, QUEUE_EMPTY, QUEUE_INSERT_TAIL, req, uv__count_bufs(), uv__handle_start, uv__io_start(), uv__malloc(), uv__req_init, uv__req_unregister, uv__send(), uv__udp_maybe_deferred_bind(), uv__udp_sendmsg(), uv_addr_ip4_any_, uv_addr_ip6_any_, UV_HANDLE_BOUND, UV_HANDLE_UDP_PROCESSING, uv_translate_sys_error(), and uv_udp_maybe_bind().

Referenced by uv_udp_send().

◆ uv__udp_try_send()

int uv__udp_try_send ( uv_udp_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
const struct sockaddr addr,
unsigned int  addrlen 
)

Definition at line 716 of file udp.c.

720  {
721  int err;
722  struct msghdr h;
723  ssize_t size;
724 
725  assert(nbufs > 0);
726 
727  /* already sending a message */
728  if (handle->send_queue_count != 0)
729  return UV_EAGAIN;
730 
731  if (addr) {
732  err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
733  if (err)
734  return err;
735  } else {
737  }
738 
739  memset(&h, 0, sizeof h);
740  h.msg_name = (struct sockaddr*) addr;
741  h.msg_namelen = addrlen;
742  h.msg_iov = (struct iovec*) bufs;
743  h.msg_iovlen = nbufs;
744 
745  do {
746  size = sendmsg(handle->io_watcher.fd, &h, 0);
747  } while (size == -1 && errno == EINTR);
748 
749  if (size == -1) {
750  if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
751  return UV_EAGAIN;
752  else
753  return UV__ERR(errno);
754  }
755 
756  return size;
757 }
#define ENOBUFS
Definition: sftypes.h:165
#define EAGAIN
Definition: sftypes.h:121
int ssize_t
Definition: sftypes.h:39
Definition: sftypes.h:73

References addr, addrlen, assert(), bufs, bytes, DWORD, EAGAIN, EINTR, ENOBUFS, err, h, handle, memset(), NULL, uv__convert_to_localhost_if_unspecified(), UV__ERR, uv__udp_maybe_deferred_bind(), uv_addr_ip4_any_, uv_addr_ip6_any_, UV_HANDLE_BOUND, UV_HANDLE_UDP_CONNECTED, uv_translate_sys_error(), and uv_udp_maybe_bind().

Referenced by uv_udp_try_send().

◆ uv__work_done()

void uv__work_done ( uv_async_t handle)

Definition at line 295 of file threadpool.c.

295  {
296  struct uv__work* w;
297  uv_loop_t* loop;
298  QUEUE* q;
299  QUEUE wq;
300  int err;
301 
302  loop = container_of(handle, uv_loop_t, wq_async);
303  uv_mutex_lock(&loop->wq_mutex);
304  QUEUE_MOVE(&loop->wq, &wq);
305  uv_mutex_unlock(&loop->wq_mutex);
306 
307  while (!QUEUE_EMPTY(&wq)) {
308  q = QUEUE_HEAD(&wq);
309  QUEUE_REMOVE(q);
310 
311  w = container_of(q, struct uv__work, wq);
312  err = (w->work == uv__cancelled) ? UV_ECANCELED : 0;
313  w->done(w, err);
314  }
315 }
#define w
Definition: crypto_rc6.c:13
#define QUEUE_HEAD(q)
Definition: queue.h:42
#define QUEUE_MOVE(h, n)
Definition: queue.h:72
void * QUEUE[2]
Definition: queue.h:21
#define QUEUE_REMOVE(q)
Definition: queue.h:101
Definition: uv.h:1780
static void uv__cancelled(struct uv__work *w)
Definition: threadpool.c:49
static QUEUE wq
Definition: threadpool.c:41

References container_of, err, handle, loop, QUEUE_EMPTY, QUEUE_HEAD, QUEUE_MOVE, QUEUE_REMOVE, uv__cancelled(), uv_mutex_lock(), uv_mutex_unlock(), w, and wq.

Referenced by uv_loop_init().

◆ uv__work_submit()

void uv__work_submit ( uv_loop_t loop,
struct uv__work w,
enum uv__work_kind  kind,
void(*)(struct uv__work *w work,
void(*)(struct uv__work *w, int status done 
)

Definition at line 256 of file threadpool.c.

260  {
262  w->loop = loop;
263  w->work = work;
264  w->done = done;
265  post(&w->wq, kind);
266 }
struct tab * done
Definition: enough.c:233
static uv_once_t once
Definition: threadpool.c:32
static void init_once(void)
Definition: threadpool.c:243
UV_EXTERN void uv_once(uv_once_t *guard, void(*callback)(void))
Definition: thread.c:419

References done, init_once(), loop, once, post(), uv_once(), w, and uv__work::work.

Referenced by uv_getaddrinfo(), uv_getnameinfo(), uv_queue_work(), and uv_random().