Bug 198571 - [af_netlink]missing wakeup while closing af_netlink socket
Summary: [af_netlink]missing wakeup while closing af_netlink socket
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-24 12:20 UTC by Shouhua Yu
Modified: 2018-01-24 21:18 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.32
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Shouhua Yu 2018-01-24 12:20:00 UTC
In a multithread program, thread A wait for a message from a af_netlink socket with the interface select first. Then thread B calls close to this socket. In this situation, thread A would not be woken up forever. This problem may be caused by missing call to the funtion release_sock to the socket in the funthon netlink_release. Can anyone fix this problem?
Comment 1 Shouhua Yu 2018-01-24 12:27:48 UTC
The situation is as follows:

Thread A                                               Thread B
fd = socket(AF_NETLINK, NETLINK_GENERIC);
ret = bind(fd)
select(fd)
                                                       close(fd) 

After close(fd), thread A would not be woken up.
Comment 2 Cong Wang 2018-01-24 21:10:08 UTC
Are you sure? netlink_release() is supposed to be called when the last reference of socket fd is gone, since Thread A is still select()'ing, how could it be released?
Comment 3 Cong Wang 2018-01-24 21:18:33 UTC
Also, you misunderstand release_sock(), it is paired with lock_sock(). sock_release() is called when the last fd reference is gone and it is independent to socket type:

static int sock_close(struct inode *inode, struct file *filp)
{
        sock_release(SOCKET_I(inode));
        return 0;
}

Note You need to log in before you can comment on or make changes to this bug.