MCPcopy Create free account
hub / github.com/F-Stack/f-stack / open_socket_fd

Function open_socket_fd

dpdk/lib/eal/common/eal_common_proc.c:561–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561static int
562open_socket_fd(void)
563{
564 struct sockaddr_un un;
565
566 peer_name[0] = '\0';
567 if (rte_eal_process_type() == RTE_PROC_SECONDARY)
568 snprintf(peer_name, sizeof(peer_name),
569 "%d_%"PRIx64, getpid(), rte_rdtsc());
570
571 mp_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
572 if (mp_fd < 0) {
573 RTE_LOG(ERR, EAL, "failed to create unix socket\n");
574 return -1;
575 }
576
577 memset(&un, 0, sizeof(un));
578 un.sun_family = AF_UNIX;
579
580 create_socket_path(peer_name, un.sun_path, sizeof(un.sun_path));
581
582 unlink(un.sun_path); /* May still exist since last run */
583
584 if (bind(mp_fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
585 RTE_LOG(ERR, EAL, "failed to bind %s: %s\n",
586 un.sun_path, strerror(errno));
587 close(mp_fd);
588 return -1;
589 }
590
591 RTE_LOG(INFO, EAL, "Multi-process socket %s\n", un.sun_path);
592 return mp_fd;
593}
594
595static void
596close_socket_fd(int fd)

Callers 1

rte_mp_channel_initFunction · 0.85

Calls 8

rte_eal_process_typeFunction · 0.85
snprintfFunction · 0.85
memsetFunction · 0.85
create_socket_pathFunction · 0.85
rte_rdtscFunction · 0.50
socketClass · 0.50
bindFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected