ssize_t len;
if (fd < 0) {
- ERR("Invalid file description");
+ ERR("Attempt to send invalid file descriptor to master (fd = %i)", fd);
+ /* Return 0 as this is not a fatal error. */
return 0;
}
{
ssize_t len;
- if (*fd < 0) {
- ERR("Invalid file description");
- return 0;
- }
-
len = lttcomm_recv_fds_unix_sock(sock, fd, 1);
if (!len) {
PERROR("lttcomm_recv_fds_unix_sock");
return -1;
}
+ if (*fd < 0) {
+ ERR("Invalid file descriptor received from worker (fd = %i)", *fd);
+ /* Return 0 as this is not a fatal error. */
+ return 0;
+ }
+
return 0;
}
return 0;
}
+ if (fd < 0) {
+ ERR("Refusing to send invalid fd to worker (fd = %i)", fd);
+ return -1;
+ }
+
ret = do_send_fd(worker->sockpair[0], fd);
if (ret < 0) {
PERROR("do_send_fd");
return 0;
}
+ if (fd < 0) {
+ DBG("Not sending file descriptor to master as it is invalid (fd = %i)", fd);
+ return 0;
+ }
ret = do_send_fd(worker->sockpair[1], fd);
if (ret < 0) {
PERROR("do_send_fd error");
ret = -1;
}
- if (fd < 0) {
- goto end;
- }
ret_close = close(fd);
if (ret_close < 0) {
PERROR("close");
}
-end:
+
return ret;
}
goto end;
}
+ if (ret_value->_error) {
+ /* Skip stage 5 on error as there will be no fd to receive. */
+ goto end;
+ }
+
/*
* Stage 5: Receive file descriptor if needed
*/