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

Function create_unix_socket

dpdk/lib/vhost/socket.c:347–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347static int
348create_unix_socket(struct vhost_user_socket *vsocket)
349{
350 int fd;
351 struct sockaddr_un *un = &vsocket->un;
352
353 fd = socket(AF_UNIX, SOCK_STREAM, 0);
354 if (fd < 0)
355 return -1;
356 VHOST_LOG_CONFIG(vsocket->path, INFO, "vhost-user %s: socket created, fd: %d\n",
357 vsocket->is_server ? "server" : "client", fd);
358
359 if (!vsocket->is_server && fcntl(fd, F_SETFL, O_NONBLOCK)) {
360 VHOST_LOG_CONFIG(vsocket->path, ERR,
361 "vhost-user: can't set nonblocking mode for socket, fd: %d (%s)\n",
362 fd, strerror(errno));
363 close(fd);
364 return -1;
365 }
366
367 memset(un, 0, sizeof(*un));
368 un->sun_family = AF_UNIX;
369 strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
370 un->sun_path[sizeof(un->sun_path) - 1] = '\0';
371
372 vsocket->socket_fd = fd;
373 return 0;
374}
375
376static int
377vhost_user_start_server(struct vhost_user_socket *vsocket)

Callers 2

vhost_user_read_cbFunction · 0.85

Calls 5

memsetFunction · 0.85
strncpyFunction · 0.85
socketClass · 0.50
fcntlFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected