]> git.pld-linux.org Git - packages/ggaoed.git/blob - ggaoed-netlink-rx-buffer-realloc.patch
- peek & read netlink message in one shot since the default algorithm doesn't work...
[packages/ggaoed.git] / ggaoed-netlink-rx-buffer-realloc.patch
1 --- ggaoed-1.1/netlink.c.orig   2011-06-20 19:57:17.000000000 +0200
2 +++ ggaoed-1.1/netlink.c        2011-06-20 20:27:47.426951722 +0200
3 @@ -174,7 +174,7 @@
4         int len;
5  
6         addrlen = sizeof(from_addr);
7 -       len = recvfrom(nl_fd, recvbuf, recvlen, MSG_TRUNC | MSG_DONTWAIT,
8 +       len = recvfrom(nl_fd, recvbuf, recvlen, MSG_TRUNC | MSG_DONTWAIT | MSG_PEEK,
9                 (struct sockaddr *)&from_addr, &addrlen);
10         if (!len)
11                 return;
12 @@ -185,13 +185,12 @@
13         }
14         if (len > recvlen)
15         {
16 -               /* The buffer was too small. Increase it and request a
17 -                * new enumeration */
18 -               recvlen <<= 1;
19 +               /* The buffer was too small. Increase it and try again... */
20 +               recvlen = len;
21                 recvbuf = g_realloc(recvbuf, recvlen);
22 -               netmon_enumerate();
23 -               return;
24         }
25 +       len = recvfrom(nl_fd, recvbuf, recvlen, MSG_TRUNC | MSG_DONTWAIT,
26 +               (struct sockaddr *)&from_addr, &addrlen);
27  
28         for (msg = (struct nlmsghdr *)recvbuf; NLMSG_OK(msg, (unsigned)len);
29                         msg = NLMSG_NEXT(msg, len))
This page took 0.067631 seconds and 3 git commands to generate.