MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / recv_fd

Function recv_fd

cdb2api/cdb2api.c:645–659  ·  view source on GitHub ↗

This wrapper ensures that on error we close any file descriptor that we * may have received before the error occured. Alse we make sure that we * preserve the value of errno which may be needed if the error was * PASSFD_RECVMSG. */

Source from the content-addressed store, hash-verified

643 * preserve the value of errno which may be needed if the error was
644 * PASSFD_RECVMSG. */
645static int recv_fd(int sockfd, void *data, size_t nbytes, int *fd_recvd)
646{
647 int rc;
648 rc = recv_fd_int(sockfd, data, nbytes, fd_recvd);
649 if (rc != 0 && *fd_recvd != -1) {
650 int errno_save = errno;
651 if (close(*fd_recvd) == -1) {
652 fprintf(stderr, "%s: close(%d) error: %d %s\n", __func__, *fd_recvd,
653 errno, strerror(errno));
654 }
655 *fd_recvd = -1;
656 errno = errno_save;
657 }
658 return rc;
659}
660
661static int send_fd_to(int sockfd, const void *data, size_t nbytes,
662 int fd_to_send, int timeoutms)

Callers 1

cdb2_socket_pool_get_llFunction · 0.70

Calls 1

recv_fd_intFunction · 0.70

Tested by

no test coverage detected