uv-common.c
Go to the documentation of this file.
1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19  * IN THE SOFTWARE.
20  */
21 
22 #include "uv.h"
23 #include "uv-common.h"
24 
25 #include <assert.h>
26 #include <errno.h>
27 #include <stdarg.h>
28 #include <stddef.h> /* NULL */
29 #include <stdio.h>
30 #include <stdlib.h> /* malloc */
31 #include <string.h> /* memset */
32 
33 #if defined(_WIN32)
34 # include <malloc.h> /* malloc */
35 #else
36 # include <net/if.h> /* if_nametoindex */
37 # include <sys/un.h> /* AF_UNIX, sockaddr_un */
38 #endif
39 
40 
41 typedef struct {
47 
49  malloc,
50  realloc,
51  calloc,
52  free,
53 };
54 
55 char* uv__strdup(const char* s) {
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 }
62 
63 char* uv__strndup(const char* s, size_t n) {
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 }
74 
75 void* uv__malloc(size_t size) {
76  if (size > 0)
78  return NULL;
79 }
80 
81 void uv__free(void* ptr) {
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 }
91 
92 void* uv__calloc(size_t count, size_t size) {
94 }
95 
96 void* uv__realloc(void* ptr, size_t size) {
97  if (size > 0)
99  uv__free(ptr);
100  return NULL;
101 }
102 
103 void* uv__reallocf(void* ptr, size_t size) {
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 }
113 
115  uv_realloc_func realloc_func,
116  uv_calloc_func calloc_func,
117  uv_free_func free_func) {
118  if (malloc_func == NULL || realloc_func == NULL ||
119  calloc_func == NULL || free_func == NULL) {
120  return UV_EINVAL;
121  }
122 
123  uv__allocator.local_malloc = malloc_func;
124  uv__allocator.local_realloc = realloc_func;
125  uv__allocator.local_calloc = calloc_func;
126  uv__allocator.local_free = free_func;
127 
128  return 0;
129 }
130 
131 #define XX(uc, lc) case UV_##uc: return sizeof(uv_##lc##_t);
132 
134  switch (type) {
136  default:
137  return -1;
138  }
139 }
140 
142  switch(type) {
144  default:
145  return -1;
146  }
147 }
148 
149 #undef XX
150 
151 
152 size_t uv_loop_size(void) {
153  return sizeof(uv_loop_t);
154 }
155 
156 
157 uv_buf_t uv_buf_init(char* base, unsigned int len) {
158  uv_buf_t buf;
159  buf.base = base;
160  buf.len = len;
161  return buf;
162 }
163 
164 
165 static const char* uv__unknown_err_code(int err) {
166  char buf[32];
167  char* copy;
168 
169  snprintf(buf, sizeof(buf), "Unknown system error %d", err);
170  copy = uv__strdup(buf);
171 
172  return copy != NULL ? copy : "Unknown system error";
173 }
174 
175 #define UV_ERR_NAME_GEN_R(name, _) \
176 case UV_## name: \
177  uv__strscpy(buf, #name, buflen); break;
178 char* uv_err_name_r(int err, char* buf, size_t buflen) {
179  switch (err) {
181  default: snprintf(buf, buflen, "Unknown system error %d", err);
182  }
183  return buf;
184 }
185 #undef UV_ERR_NAME_GEN_R
186 
187 
188 #define UV_ERR_NAME_GEN(name, _) case UV_ ## name: return #name;
189 const char* uv_err_name(int err) {
190  switch (err) {
192  }
193  return uv__unknown_err_code(err);
194 }
195 #undef UV_ERR_NAME_GEN
196 
197 
198 #define UV_STRERROR_GEN_R(name, msg) \
199 case UV_ ## name: \
200  snprintf(buf, buflen, "%s", msg); break;
201 char* uv_strerror_r(int err, char* buf, size_t buflen) {
202  switch (err) {
204  default: snprintf(buf, buflen, "Unknown system error %d", err);
205  }
206  return buf;
207 }
208 #undef UV_STRERROR_GEN_R
209 
210 
211 #define UV_STRERROR_GEN(name, msg) case UV_ ## name: return msg;
212 const char* uv_strerror(int err) {
213  switch (err) {
215  }
216  return uv__unknown_err_code(err);
217 }
218 #undef UV_STRERROR_GEN
219 
220 
221 int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) {
222  memset(addr, 0, sizeof(*addr));
223  addr->sin_family = AF_INET;
224  addr->sin_port = htons(port);
225 #ifdef SIN6_LEN
226  addr->sin_len = sizeof(*addr);
227 #endif
228  return uv_inet_pton(AF_INET, ip, &(addr->sin_addr.s_addr));
229 }
230 
231 
232 int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) {
233  char address_part[40];
234  size_t address_part_size;
235  const char* zone_index;
236 
237  memset(addr, 0, sizeof(*addr));
238  addr->sin6_family = AF_INET6;
239  addr->sin6_port = htons(port);
240 #ifdef SIN6_LEN
241  addr->sin6_len = sizeof(*addr);
242 #endif
243 
244  zone_index = strchr(ip, '%');
245  if (zone_index != NULL) {
246  address_part_size = zone_index - ip;
247  if (address_part_size >= sizeof(address_part))
248  address_part_size = sizeof(address_part) - 1;
249 
250  memcpy(address_part, ip, address_part_size);
251  address_part[address_part_size] = '\0';
252  ip = address_part;
253 
254  zone_index++; /* skip '%' */
255  /* NOTE: unknown interface (id=0) is silently ignored */
256 #ifdef _WIN32
257  addr->sin6_scope_id = atoi(zone_index);
258 #else
259  addr->sin6_scope_id = if_nametoindex(zone_index);
260 #endif
261  }
262 
263  return uv_inet_pton(AF_INET6, ip, &addr->sin6_addr);
264 }
265 
266 
267 int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size) {
268  return uv_inet_ntop(AF_INET, &src->sin_addr, dst, size);
269 }
270 
271 
272 int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size) {
273  return uv_inet_ntop(AF_INET6, &src->sin6_addr, dst, size);
274 }
275 
276 
278  const struct sockaddr* addr,
279  unsigned int flags) {
280  unsigned int addrlen;
281 
282  if (handle->type != UV_TCP)
283  return UV_EINVAL;
284 
285  if (addr->sa_family == AF_INET)
286  addrlen = sizeof(struct sockaddr_in);
287  else if (addr->sa_family == AF_INET6)
288  addrlen = sizeof(struct sockaddr_in6);
289  else
290  return UV_EINVAL;
291 
292  return uv__tcp_bind(handle, addr, addrlen, flags);
293 }
294 
295 
297  const struct sockaddr* addr,
298  unsigned int flags) {
299  unsigned int addrlen;
300 
301  if (handle->type != UV_UDP)
302  return UV_EINVAL;
303 
304  if (addr->sa_family == AF_INET)
305  addrlen = sizeof(struct sockaddr_in);
306  else if (addr->sa_family == AF_INET6)
307  addrlen = sizeof(struct sockaddr_in6);
308  else
309  return UV_EINVAL;
310 
311  return uv__udp_bind(handle, addr, addrlen, flags);
312 }
313 
314 
316  uv_tcp_t* handle,
317  const struct sockaddr* addr,
318  uv_connect_cb cb) {
319  unsigned int addrlen;
320 
321  if (handle->type != UV_TCP)
322  return UV_EINVAL;
323 
324  if (addr->sa_family == AF_INET)
325  addrlen = sizeof(struct sockaddr_in);
326  else if (addr->sa_family == AF_INET6)
327  addrlen = sizeof(struct sockaddr_in6);
328  else
329  return UV_EINVAL;
330 
331  return uv__tcp_connect(req, handle, addr, addrlen, cb);
332 }
333 
334 
335 int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr) {
336  unsigned int addrlen;
337 
338  if (handle->type != UV_UDP)
339  return UV_EINVAL;
340 
341  /* Disconnect the handle */
342  if (addr == NULL) {
343  if (!(handle->flags & UV_HANDLE_UDP_CONNECTED))
344  return UV_ENOTCONN;
345 
346  return uv__udp_disconnect(handle);
347  }
348 
349  if (addr->sa_family == AF_INET)
350  addrlen = sizeof(struct sockaddr_in);
351  else if (addr->sa_family == AF_INET6)
352  addrlen = sizeof(struct sockaddr_in6);
353  else
354  return UV_EINVAL;
355 
356  if (handle->flags & UV_HANDLE_UDP_CONNECTED)
357  return UV_EISCONN;
358 
359  return uv__udp_connect(handle, addr, addrlen);
360 }
361 
362 
364  struct sockaddr_storage addr;
365  int addrlen;
366  if (handle->type != UV_UDP)
367  return 0;
368 
369  addrlen = sizeof(addr);
370  if (uv_udp_getpeername(handle, (struct sockaddr*) &addr, &addrlen) != 0)
371  return 0;
372 
373  return addrlen > 0;
374 }
375 
376 
377 int uv__udp_check_before_send(uv_udp_t* handle, const struct sockaddr* addr) {
378  unsigned int addrlen;
379 
380  if (handle->type != UV_UDP)
381  return UV_EINVAL;
382 
383  if (addr != NULL && (handle->flags & UV_HANDLE_UDP_CONNECTED))
384  return UV_EISCONN;
385 
386  if (addr == NULL && !(handle->flags & UV_HANDLE_UDP_CONNECTED))
387  return UV_EDESTADDRREQ;
388 
389  if (addr != NULL) {
390  if (addr->sa_family == AF_INET)
391  addrlen = sizeof(struct sockaddr_in);
392  else if (addr->sa_family == AF_INET6)
393  addrlen = sizeof(struct sockaddr_in6);
394 #if defined(AF_UNIX) && !defined(_WIN32)
395  else if (addr->sa_family == AF_UNIX)
396  addrlen = sizeof(struct sockaddr_un);
397 #endif
398  else
399  return UV_EINVAL;
400  } else {
401  addrlen = 0;
402  }
403 
404  return addrlen;
405 }
406 
407 
409  uv_udp_t* handle,
410  const uv_buf_t bufs[],
411  unsigned int nbufs,
412  const struct sockaddr* addr,
414  int addrlen;
415 
417  if (addrlen < 0)
418  return addrlen;
419 
420  return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb);
421 }
422 
423 
425  const uv_buf_t bufs[],
426  unsigned int nbufs,
427  const struct sockaddr* addr) {
428  int addrlen;
429 
431  if (addrlen < 0)
432  return addrlen;
433 
434  return uv__udp_try_send(handle, bufs, nbufs, addr, addrlen);
435 }
436 
437 
441  if (handle->type != UV_UDP || alloc_cb == NULL || recv_cb == NULL)
442  return UV_EINVAL;
443  else
445 }
446 
447 
449  if (handle->type != UV_UDP)
450  return UV_EINVAL;
451  else
452  return uv__udp_recv_stop(handle);
453 }
454 
455 
457  QUEUE queue;
458  QUEUE* q;
459  uv_handle_t* h;
460 
461  QUEUE_MOVE(&loop->handle_queue, &queue);
462  while (!QUEUE_EMPTY(&queue)) {
463  q = QUEUE_HEAD(&queue);
464  h = QUEUE_DATA(q, uv_handle_t, handle_queue);
465 
466  QUEUE_REMOVE(q);
467  QUEUE_INSERT_TAIL(&loop->handle_queue, q);
468 
469  if (h->flags & UV_HANDLE_INTERNAL) continue;
470  walk_cb(h, arg);
471  }
472 }
473 
474 
475 static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) {
476  const char* type;
477  QUEUE* q;
478  uv_handle_t* h;
479 
480  if (loop == NULL)
481  loop = uv_default_loop();
482 
483  QUEUE_FOREACH(q, &loop->handle_queue) {
484  h = QUEUE_DATA(q, uv_handle_t, handle_queue);
485 
486  if (only_active && !uv__is_active(h))
487  continue;
488 
489  switch (h->type) {
490 #define X(uc, lc) case UV_##uc: type = #lc; break;
492 #undef X
493  default: type = "<unknown>";
494  }
495 
496  fprintf(stream,
497  "[%c%c%c] %-8s %p\n",
498  "R-"[!(h->flags & UV_HANDLE_REF)],
499  "A-"[!(h->flags & UV_HANDLE_ACTIVE)],
500  "I-"[!(h->flags & UV_HANDLE_INTERNAL)],
501  type,
502  (void*)h);
503  }
504 }
505 
506 
509 }
510 
511 
514 }
515 
516 
519 }
520 
521 
524 }
525 
526 
528  return uv__has_ref(handle);
529 }
530 
531 
533  loop->stop_flag = 1;
534 }
535 
536 
538  return loop->time;
539 }
540 
541 
542 
543 size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs) {
544  unsigned int i;
545  size_t bytes;
546 
547  bytes = 0;
548  for (i = 0; i < nbufs; i++)
549  bytes += (size_t) bufs[i].len;
550 
551  return bytes;
552 }
553 
555  return uv__socket_sockopt(handle, SO_RCVBUF, value);
556 }
557 
559  return uv__socket_sockopt(handle, SO_SNDBUF, value);
560 }
561 
563  size_t required_len;
564 
565  if (!uv__is_active(handle)) {
566  *size = 0;
567  return UV_EINVAL;
568  }
569 
570  required_len = strlen(handle->path);
571  if (required_len >= *size) {
572  *size = required_len + 1;
573  return UV_ENOBUFS;
574  }
575 
576  memcpy(buffer, handle->path, required_len);
577  *size = required_len;
578  buffer[required_len] = '\0';
579 
580  return 0;
581 }
582 
583 /* The windows implementation does not have the same structure layout as
584  * the unix implementation (nbufs is not directly inside req but is
585  * contained in a nested union/struct) so this function locates it.
586 */
587 static unsigned int* uv__get_nbufs(uv_fs_t* req) {
588 #ifdef _WIN32
589  return &req->fs.info.nbufs;
590 #else
591  return &req->nbufs;
592 #endif
593 }
594 
595 /* uv_fs_scandir() uses the system allocator to allocate memory on non-Windows
596  * systems. So, the memory should be released using free(). On Windows,
597  * uv__malloc() is used, so use uv__free() to free memory.
598 */
599 #ifdef _WIN32
600 # define uv__fs_scandir_free uv__free
601 #else
602 # define uv__fs_scandir_free free
603 #endif
604 
606  uv__dirent_t** dents;
607 
608  unsigned int* nbufs = uv__get_nbufs(req);
609 
610  dents = req->ptr;
611  if (*nbufs > 0 && *nbufs != (unsigned int) req->result)
612  (*nbufs)--;
613  for (; *nbufs < (unsigned int) req->result; (*nbufs)++)
614  uv__fs_scandir_free(dents[*nbufs]);
615 
616  uv__fs_scandir_free(req->ptr);
617  req->ptr = NULL;
618 }
619 
620 
622  uv__dirent_t** dents;
623  uv__dirent_t* dent;
624  unsigned int* nbufs;
625 
626  /* Check to see if req passed */
627  if (req->result < 0)
628  return req->result;
629 
630  /* Ptr will be null if req was canceled or no files found */
631  if (!req->ptr)
632  return UV_EOF;
633 
634  nbufs = uv__get_nbufs(req);
635  assert(nbufs);
636 
637  dents = req->ptr;
638 
639  /* Free previous entity */
640  if (*nbufs > 0)
641  uv__fs_scandir_free(dents[*nbufs - 1]);
642 
643  /* End was already reached */
644  if (*nbufs == (unsigned int) req->result) {
645  uv__fs_scandir_free(dents);
646  req->ptr = NULL;
647  return UV_EOF;
648  }
649 
650  dent = dents[(*nbufs)++];
651 
652  ent->name = dent->d_name;
653  ent->type = uv__fs_get_dirent_type(dent);
654 
655  return 0;
656 }
657 
660 
661 #ifdef HAVE_DIRENT_TYPES
662  switch (dent->d_type) {
663  case UV__DT_DIR:
665  break;
666  case UV__DT_FILE:
668  break;
669  case UV__DT_LINK:
671  break;
672  case UV__DT_FIFO:
674  break;
675  case UV__DT_SOCKET:
677  break;
678  case UV__DT_CHAR:
680  break;
681  case UV__DT_BLOCK:
683  break;
684  default:
686  }
687 #else
689 #endif
690 
691  return type;
692 }
693 
695  uv_dir_t* dir;
697  int i;
698 
699  if (req->ptr == NULL)
700  return;
701 
702  dir = req->ptr;
703  dirents = dir->dirents;
704  req->ptr = NULL;
705 
706  if (dirents == NULL)
707  return;
708 
709  for (i = 0; i < req->result; ++i) {
710  uv__free((char*) dirents[i].name);
711  dirents[i].name = NULL;
712  }
713 }
714 
715 
717  va_list ap;
718  int err;
719 
720  va_start(ap, option);
721  /* Any platform-agnostic options should be handled here. */
723  va_end(ap);
724 
725  return err;
726 }
727 
728 
731 
732 
734  if (default_loop_ptr != NULL)
735  return default_loop_ptr;
736 
738  return NULL;
739 
741  return default_loop_ptr;
742 }
743 
744 
746  uv_loop_t* loop;
747 
748  loop = uv__malloc(sizeof(*loop));
749  if (loop == NULL)
750  return NULL;
751 
752  if (uv_loop_init(loop)) {
753  uv__free(loop);
754  return NULL;
755  }
756 
757  return loop;
758 }
759 
760 
762  QUEUE* q;
763  uv_handle_t* h;
764 #ifndef NDEBUG
765  void* saved_data;
766 #endif
767 
769  return UV_EBUSY;
770 
771  QUEUE_FOREACH(q, &loop->handle_queue) {
772  h = QUEUE_DATA(q, uv_handle_t, handle_queue);
773  if (!(h->flags & UV_HANDLE_INTERNAL))
774  return UV_EBUSY;
775  }
776 
778 
779 #ifndef NDEBUG
780  saved_data = loop->data;
781  memset(loop, -1, sizeof(*loop));
782  loop->data = saved_data;
783 #endif
784  if (loop == default_loop_ptr)
785  default_loop_ptr = NULL;
786 
787  return 0;
788 }
789 
790 
792  uv_loop_t* default_loop;
793  int err;
794 
795  default_loop = default_loop_ptr;
796 
798  (void) err; /* Squelch compiler warnings. */
799  assert(err == 0);
800  if (loop != default_loop)
801  uv__free(loop);
802 }
803 
804 
805 void uv_os_free_environ(uv_env_item_t* envitems, int count) {
806  int i;
807 
808  for (i = 0; i < count; i++) {
809  uv__free(envitems[i].name);
810  }
811 
812  uv__free(envitems);
813 }
814 
815 
816 void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
817  int i;
818 
819  for (i = 0; i < count; i++)
820  uv__free(cpu_infos[i].model);
821 
822  uv__free(cpu_infos);
823 }
XX
#define XX(uc, lc)
Definition: uv-common.c:131
UV__DT_LINK
#define UV__DT_LINK
Definition: win.h:312
uv__is_active
#define uv__is_active(h)
Definition: uv-common.h:235
uv_udp_recv_stop
int uv_udp_recv_stop(uv_udp_t *handle)
Definition: uv-common.c:448
uv__udp_check_before_send
int uv__udp_check_before_send(uv_udp_t *handle, const struct sockaddr *addr)
Definition: uv-common.c:377
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
async_greeter_server_with_graceful_shutdown.loop
loop
Definition: async_greeter_server_with_graceful_shutdown.py:59
uv_strerror_r
char * uv_strerror_r(int err, char *buf, size_t buflen)
Definition: uv-common.c:201
UV_DIRENT_LINK
@ UV_DIRENT_LINK
Definition: uv.h:1132
uv_fs_event_s
Definition: uv.h:1533
UV_DIRENT_BLOCK
@ UV_DIRENT_BLOCK
Definition: uv.h:1136
uv_inet_pton
UV_EXTERN int uv_inet_pton(int af, const char *src, void *dst)
Definition: inet.c:150
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
uv_calloc_func
void *(* uv_calloc_func)(size_t count, size_t size)
Definition: uv.h:265
uv_req_type
uv_req_type
Definition: uv.h:198
UV__DT_FILE
#define UV__DT_FILE
Definition: win.h:311
uv_realloc_func
void *(* uv_realloc_func)(void *ptr, size_t size)
Definition: uv.h:264
uv_free_cpu_info
void uv_free_cpu_info(uv_cpu_info_t *cpu_infos, int count)
Definition: uv-common.c:816
uv__unknown_err_code
static const char * uv__unknown_err_code(int err)
Definition: uv-common.c:165
uv_print_all_handles
void uv_print_all_handles(uv_loop_t *loop, FILE *stream)
Definition: uv-common.c:507
uv_os_free_environ
void uv_os_free_environ(uv_env_item_t *envitems, int count)
Definition: uv-common.c:805
uv__loop_close
void uv__loop_close(uv_loop_t *loop)
Definition: loop.c:146
uv_default_loop
uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:733
uv__udp_is_connected
int uv__udp_is_connected(uv_udp_t *handle)
Definition: uv-common.c:363
UV_ERR_NAME_GEN
#define UV_ERR_NAME_GEN(name, _)
Definition: uv-common.c:188
AF_INET6
#define AF_INET6
Definition: ares_setup.h:208
uv_cpu_info_s
Definition: uv.h:1079
uv_err_name
const char * uv_err_name(int err)
Definition: uv-common.c:189
memset
return memset(p, 0, total)
uv__print_handles
static void uv__print_handles(uv_loop_t *loop, int only_active, FILE *stream)
Definition: uv-common.c:475
uv_handle_type
uv_handle_type
Definition: uv.h:189
uv_connect_s
Definition: uv.h:580
uv_loop_new
uv_loop_t * uv_loop_new(void)
Definition: uv-common.c:745
uv_tcp_connect
int uv_tcp_connect(uv_connect_t *req, uv_tcp_t *handle, const struct sockaddr *addr, uv_connect_cb cb)
Definition: uv-common.c:315
uv_walk
void uv_walk(uv_loop_t *loop, uv_walk_cb walk_cb, void *arg)
Definition: uv-common.c:456
UV_DIRENT_FILE
@ UV_DIRENT_FILE
Definition: uv.h:1130
uv_dir_s
Definition: uv.h:1286
uv_handle_size
size_t uv_handle_size(uv_handle_type type)
Definition: uv-common.c:133
uv__malloc
void * uv__malloc(size_t size)
Definition: uv-common.c:75
UV_HANDLE_UDP_CONNECTED
@ UV_HANDLE_UDP_CONNECTED
Definition: uv-common.h:106
uv__has_ref
#define uv__has_ref(h)
Definition: uv-common.h:275
uv_fs_event_getpath
int uv_fs_event_getpath(uv_fs_event_t *handle, char *buffer, size_t *size)
Definition: uv-common.c:562
UV__DT_SOCKET
#define UV__DT_SOCKET
Definition: win.h:314
uv-common.h
string.h
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
error_ref_leak.err
err
Definition: error_ref_leak.py:35
uv_udp_connect
int uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr)
Definition: uv-common.c:335
QUEUE_HEAD
#define QUEUE_HEAD(q)
Definition: queue.h:42
uv__fs_get_dirent_type
uv_dirent_type_t uv__fs_get_dirent_type(uv__dirent_t *dent)
Definition: uv-common.c:658
uv__dirent_t
struct dirent uv__dirent_t
Definition: unix.h:169
alloc_cb
static void alloc_cb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
Definition: benchmark-pound.c:84
send_cb
static void send_cb(uv_udp_send_t *req, int status)
Definition: benchmark-udp-pummel.c:72
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, uv_udp_send_cb send_cb)
Definition: uv-common.c:408
UV_STRERROR_GEN_R
#define UV_STRERROR_GEN_R(name, msg)
Definition: uv-common.c:198
uv_walk_cb
void(* uv_walk_cb)(uv_handle_t *handle, void *arg)
Definition: uv.h:324
uv__udp_recv_stop
int uv__udp_recv_stop(uv_udp_t *handle)
Definition: unix/udp.c:1329
setup.name
name
Definition: setup.py:542
uv_loop_size
size_t uv_loop_size(void)
Definition: uv-common.c:152
UV__DT_BLOCK
#define UV__DT_BLOCK
Definition: win.h:316
uv_udp_bind
int uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int flags)
Definition: uv-common.c:296
QUEUE_DATA
#define QUEUE_DATA(ptr, type, field)
Definition: queue.h:30
uv_fs_s
Definition: uv.h:1294
uv__handle_ref
#define uv__handle_ref(h)
Definition: uv-common.h:257
uv__handle_unref
#define uv__handle_unref(h)
Definition: uv-common.h:266
UV_HANDLE_TYPE_MAP
#define UV_HANDLE_TYPE_MAP(XX)
Definition: uv.h:152
QUEUE_MOVE
#define QUEUE_MOVE(h, n)
Definition: queue.h:72
uv_ref
void uv_ref(uv_handle_t *handle)
Definition: uv-common.c:517
uv_req_size
size_t uv_req_size(uv_req_type type)
Definition: uv-common.c:141
uv_alloc_cb
void(* uv_alloc_cb)(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
Definition: uv.h:306
uv_unref
void uv_unref(uv_handle_t *handle)
Definition: uv-common.c:522
uv_free_func
void(* uv_free_func)(void *ptr)
Definition: uv.h:266
dirents
static uv_dirent_t dirents[1]
Definition: test-fs-readdir.c:31
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
uv_tcp_bind
int uv_tcp_bind(uv_tcp_t *handle, const struct sockaddr *addr, unsigned int flags)
Definition: uv-common.c:277
uv__udp_bind
int uv__udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
Definition: unix/udp.c:503
uv_print_active_handles
void uv_print_active_handles(uv_loop_t *loop, FILE *stream)
Definition: uv-common.c:512
xds_interop_client.int
int
Definition: xds_interop_client.py:113
sockaddr_in6
Definition: ares_ipv6.h:25
queue
Definition: sync_test.cc:39
uv__udp_disconnect
int uv__udp_disconnect(uv_udp_t *handle)
Definition: unix/udp.c:628
uv_ip6_addr
int uv_ip6_addr(const char *ip, int port, struct sockaddr_in6 *addr)
Definition: uv-common.c:232
req
static uv_connect_t req
Definition: test-connection-fail.c:30
uv_env_item_s
Definition: uv.h:1218
uv__strdup
char * uv__strdup(const char *s)
Definition: uv-common.c:55
uv_udp_s
Definition: uv.h:629
uv__allocator_t::local_realloc
uv_realloc_func local_realloc
Definition: uv-common.c:43
X
#define X(uc, lc)
uv_send_buffer_size
int uv_send_buffer_size(uv_handle_t *handle, int *value)
Definition: uv-common.c:558
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
uv__get_nbufs
static unsigned int * uv__get_nbufs(uv_fs_t *req)
Definition: uv-common.c:587
uv_dirent_s::name
const char * name
Definition: uv.h:1140
UV_DIRENT_SOCKET
@ UV_DIRENT_SOCKET
Definition: uv.h:1134
uv_fs_scandir_next
int uv_fs_scandir_next(uv_fs_t *req, uv_dirent_t *ent)
Definition: uv-common.c:621
UV_HANDLE_INTERNAL
@ UV_HANDLE_INTERNAL
Definition: uv-common.h:70
uv_udp_getpeername
UV_EXTERN int uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, int *namelen)
Definition: unix/udp.c:1283
uv_stop
void uv_stop(uv_loop_t *loop)
Definition: uv-common.c:532
uv_loop_option
uv_loop_option
Definition: uv.h:249
uv_now
uint64_t uv_now(const uv_loop_t *loop)
Definition: uv-common.c:537
UV_DIRENT_CHAR
@ UV_DIRENT_CHAR
Definition: uv.h:1135
arg
Definition: cmdline.cc:40
uv__allocator_t
Definition: uv-common.c:41
uv_dirent_s::type
uv_dirent_type_t type
Definition: uv.h:1141
uv__udp_connect
int uv__udp_connect(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen)
Definition: unix/udp.c:605
uv__calloc
void * uv__calloc(size_t count, size_t size)
Definition: uv-common.c:92
uv_udp_send_cb
void(* uv_udp_send_cb)(uv_udp_send_t *req, int status)
Definition: uv.h:621
UV_ERR_NAME_GEN_R
#define UV_ERR_NAME_GEN_R(name, _)
Definition: uv-common.c:175
uv__free
void uv__free(void *ptr)
Definition: uv-common.c:81
uv_loop_t
struct uv_loop_s uv_loop_t
Definition: uv.h:209
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
uv_loop_init
UV_EXTERN int uv_loop_init(uv_loop_t *loop)
Definition: loop.c:30
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
recv_cb
static void recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags)
Definition: benchmark-udp-pummel.c:109
uv_udp_recv_cb
void(* uv_udp_recv_cb)(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags)
Definition: uv.h:622
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: unix/udp.c:649
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)
Definition: uv-common.c:424
uv_loop_delete
void uv_loop_delete(uv_loop_t *loop)
Definition: uv-common.c:791
uv__realloc
void * uv__realloc(void *ptr, size_t size)
Definition: uv-common.c:96
uv_buf_init
uv_buf_t uv_buf_init(char *base, unsigned int len)
Definition: uv-common.c:157
QUEUE_REMOVE
#define QUEUE_REMOVE(q)
Definition: queue.h:101
UV_ERRNO_MAP
#define UV_ERRNO_MAP(XX)
Definition: uv.h:70
uv__reallocf
void * uv__reallocf(void *ptr, size_t size)
Definition: uv-common.c:103
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
uv_replace_allocator
int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func)
Definition: uv-common.c:114
uv_tcp_s
Definition: uv.h:544
QUEUE_EMPTY
#define QUEUE_EMPTY(q)
Definition: queue.h:39
uv_connect_cb
void(* uv_connect_cb)(uv_connect_t *req, int status)
Definition: uv.h:313
uv__has_active_reqs
#define uv__has_active_reqs(loop)
Definition: uv-common.h:204
uv_udp_send_s
Definition: uv.h:645
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
uv_loop_close
int uv_loop_close(uv_loop_t *loop)
Definition: uv-common.c:761
bufs
static uv_buf_t bufs[5]
Definition: benchmark-udp-pummel.c:51
value
const char * value
Definition: hpack_parser_table.cc:165
uv.h
UV_DIRENT_FIFO
@ UV_DIRENT_FIFO
Definition: uv.h:1133
uv_ip4_addr
int uv_ip4_addr(const char *ip, int port, struct sockaddr_in *addr)
Definition: uv-common.c:221
uv_dirent_s
Definition: uv.h:1139
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: unix/tcp.c:204
queue
struct queue queue
uv_buf_t
Definition: unix.h:121
uv__allocator_t::local_free
uv_free_func local_free
Definition: uv-common.c:45
benchmark.FILE
FILE
Definition: benchmark.py:21
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
uv__udp_recv_start
int uv__udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
Definition: unix/udp.c:1304
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
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: unix/udp.c:715
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
walk_cb
static void walk_cb(uv_handle_t *handle, void *arg)
Definition: test-walk-handles.c:33
uv__allocator_t::local_calloc
uv_calloc_func local_calloc
Definition: uv-common.c:44
uv_strerror
const char * uv_strerror(int err)
Definition: uv-common.c:212
uv__fs_scandir_cleanup
void uv__fs_scandir_cleanup(uv_fs_t *req)
Definition: uv-common.c:605
uv_inet_ntop
UV_EXTERN int uv_inet_ntop(int af, const void *src, char *dst, size_t size)
Definition: inet.c:40
uv_recv_buffer_size
int uv_recv_buffer_size(uv_handle_t *handle, int *value)
Definition: uv-common.c:554
QUEUE_FOREACH
#define QUEUE_FOREACH(q, h)
Definition: queue.h:36
uv__socket_sockopt
int uv__socket_sockopt(uv_handle_t *handle, int optname, int *value)
Definition: unix/core.c:184
uv_malloc_func
void *(* uv_malloc_func)(size_t size)
Definition: uv.h:263
default_loop_struct
static uv_loop_t default_loop_struct
Definition: uv-common.c:729
uv__tcp_bind
int uv__tcp_bind(uv_tcp_t *tcp, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
Definition: unix/tcp.c:148
uv_buf_t::len
size_t len
Definition: unix.h:123
UV_HANDLE_REF
@ UV_HANDLE_REF
Definition: uv-common.h:69
UV__DT_DIR
#define UV__DT_DIR
Definition: win.h:310
uv__fs_readdir_cleanup
void uv__fs_readdir_cleanup(uv_fs_t *req)
Definition: uv-common.c:694
uv_ip4_name
int uv_ip4_name(const struct sockaddr_in *src, char *dst, size_t size)
Definition: uv-common.c:267
uv__strndup
char * uv__strndup(const char *s, size_t n)
Definition: uv-common.c:63
sockaddr_in6::sin6_addr
struct ares_in6_addr sin6_addr
Definition: ares_ipv6.h:30
UV_STRERROR_GEN
#define UV_STRERROR_GEN(name, msg)
Definition: uv-common.c:211
uv_loop_configure
int uv_loop_configure(uv_loop_t *loop, uv_loop_option option,...)
Definition: uv-common.c:716
handle
static csh handle
Definition: test_arm_regression.c:16
uv_handle_s
Definition: uv.h:441
uv_udp_recv_start
int uv_udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
Definition: uv-common.c:438
uv__fs_scandir_free
#define uv__fs_scandir_free
Definition: uv-common.c:602
uv_loop_s
Definition: uv.h:1767
uv__count_bufs
size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs)
Definition: uv-common.c:543
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
default_loop_ptr
static uv_loop_t * default_loop_ptr
Definition: uv-common.c:730
UV__DT_FIFO
#define UV__DT_FIFO
Definition: win.h:313
uv__allocator
static uv__allocator_t uv__allocator
Definition: uv-common.c:48
uv_ip6_name
int uv_ip6_name(const struct sockaddr_in6 *src, char *dst, size_t size)
Definition: uv-common.c:272
regress.m
m
Definition: regress/regress.py:25
uv_err_name_r
char * uv_err_name_r(int err, char *buf, size_t buflen)
Definition: uv-common.c:178
UV__DT_CHAR
#define UV__DT_CHAR
Definition: win.h:315
uv_dirent_type_t
uv_dirent_type_t
Definition: uv.h:1128
uv__loop_configure
int uv__loop_configure(uv_loop_t *loop, uv_loop_option option, va_list ap)
Definition: loop.c:185
google_benchmark.option
option
Definition: third_party/benchmark/bindings/python/google_benchmark/__init__.py:115
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
QUEUE_INSERT_TAIL
#define QUEUE_INSERT_TAIL(h, q)
Definition: queue.h:92
UV_DIRENT_UNKNOWN
@ UV_DIRENT_UNKNOWN
Definition: uv.h:1129
UV_DIRENT_DIR
@ UV_DIRENT_DIR
Definition: uv.h:1131
UV_REQ_TYPE_MAP
#define UV_REQ_TYPE_MAP(XX)
Definition: uv.h:170
errno.h
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
uv_dir_s::dirents
uv_dirent_t * dirents
Definition: uv.h:1287
uv_has_ref
int uv_has_ref(const uv_handle_t *handle)
Definition: uv-common.c:527
UV_HANDLE_ACTIVE
@ UV_HANDLE_ACTIVE
Definition: uv-common.h:68
QUEUE
void * QUEUE[2]
Definition: queue.h:21
uv__allocator_t::local_malloc
uv_malloc_func local_malloc
Definition: uv-common.c:42
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:49