mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
mISDN: switch to sock_recvmsg()
here we do need to reinitialize ->msg_iter on each call - the data in buffer is overwritten every time, not appended to. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
f7765c3646
commit
956a27ecfa
@ -645,8 +645,10 @@ l1oip_socket_thread(void *data)
|
||||
{
|
||||
struct l1oip *hc = (struct l1oip *)data;
|
||||
int ret = 0;
|
||||
struct msghdr msg;
|
||||
struct sockaddr_in sin_rx;
|
||||
struct kvec iov;
|
||||
struct msghdr msg = {.msg_name = &sin_rx,
|
||||
.msg_namelen = sizeof(sin_rx)};
|
||||
unsigned char *recvbuf;
|
||||
size_t recvbuf_size = 1500;
|
||||
int recvlen;
|
||||
@ -661,6 +663,9 @@ l1oip_socket_thread(void *data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
iov.iov_base = recvbuf;
|
||||
iov.iov_len = recvbuf_size;
|
||||
|
||||
/* make daemon */
|
||||
allow_signal(SIGTERM);
|
||||
|
||||
@ -697,12 +702,6 @@ l1oip_socket_thread(void *data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* build receive message */
|
||||
msg.msg_name = &sin_rx;
|
||||
msg.msg_namelen = sizeof(sin_rx);
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
|
||||
/* build send message */
|
||||
hc->sendmsg.msg_name = &hc->sin_remote;
|
||||
hc->sendmsg.msg_namelen = sizeof(hc->sin_remote);
|
||||
@ -719,12 +718,9 @@ l1oip_socket_thread(void *data)
|
||||
printk(KERN_DEBUG "%s: socket created and open\n",
|
||||
__func__);
|
||||
while (!signal_pending(current)) {
|
||||
struct kvec iov = {
|
||||
.iov_base = recvbuf,
|
||||
.iov_len = recvbuf_size,
|
||||
};
|
||||
recvlen = kernel_recvmsg(socket, &msg, &iov, 1,
|
||||
recvbuf_size, 0);
|
||||
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1,
|
||||
recvbuf_size);
|
||||
recvlen = sock_recvmsg(socket, &msg, 0);
|
||||
if (recvlen > 0) {
|
||||
l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user