* @param link Private descriptor for pipe/socket.
* @param groups KUC broadcast group to listen to
* (can be null for unicast to this pid)
+ * @param rfd_flags flags for read side of pipe (e.g. O_NONBLOCK)
*/
-int libcfs_ukuc_start(lustre_kernelcomm *link, int group)
+int libcfs_ukuc_start(lustre_kernelcomm *link, int group, int rfd_flags)
{
int pfd[2];
+ int rc;
link->lk_rfd = link->lk_wfd = LK_NOFD;
if (pipe(pfd) < 0)
return -errno;
+ if (fcntl(pfd[0], F_SETFL, rfd_flags) < 0) {
+ rc = -errno;
+ close(pfd[0]);
+ close(pfd[1]);
+ return rc;
+ }
+
memset(link, 0, sizeof(*link));
link->lk_rfd = pfd[0];
link->lk_wfd = pfd[1];
return rc;
}
+/** Returns the file descriptor for the read side of the pipe,
+ * to be used with poll/select.
+ * @param link Private descriptor for pipe/socket.
+ */
+int libcfs_ukuc_get_rfd(lustre_kernelcomm *link)
+{
+ return link->lk_rfd;
+}
+
#define lhsz sizeof(*kuch)
/** Read a message from the link.
int one_success = 0;
ENTRY;
- down_read(&kg_sem);
+ down_write(&kg_sem);
list_for_each_entry(reg, &kkuc_groups[group], kr_chain) {
if (reg->kr_fp != NULL) {
rc = libcfs_kkuc_msg_put(reg->kr_fp, payload);
}
}
}
- up_read(&kg_sem);
+ up_write(&kg_sem);
/* don't return an error if the message has been delivered
* at least to one agent */