我有以下函数从内核模块中的内核线程调用它:
static int ksocket_receive(struct socket* sock, struct sockaddr_in* addr, unsigned char* buf, int len)
{
struct msghdr msg;
mm_segment_t oldfs;
int size = 0;
if (sock->sk == NULL) return 0;
msg.msg_flags = 0;
msg.msg_name = addr;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_iocb = NULL;
oldfs = get_fs();
set_fs(KERNEL_DS);
size = sock_recvmsg(sock,&msg,len,msg.msg_flags);
set_fs(oldfs);
return size;
}
它在sock_recvmsg()中阻止内部。有没有办法让sock_recvmsg()的非阻塞版本?
类似于用户空间中等效的MSG_DONTWAIT和O_NONBLOCK标志 - recvmsg()......