Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. From 685a5475ce93f59f8d733fd045caa778e8a0cf65 Wed Oct 21 09:00:00 2015
  2. From: Chris Card <ctcard@hotmail.com>
  3. Date: Wed, 21 Oct 2015 08:50:21 +0100
  4. Subject: [patch libteam] Log more detailed error messages from
  5. get_ifinfo_list() and retry if nl_recvmsgs() returns NLE_DUMP_INTR
  6. Signed-off-by: Chris Card <ctcard@hotmail.com>
  7.  
  8. ---
  9. libteam/ifinfo.c | 57 +++++++++++++++++++++++++++++++++++++++-----------------
  10. 1 file changed, 40 insertions(+), 17 deletions(-)
  11.  
  12. diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
  13. index 47b342c..9754ffa 100644
  14. --- a/libteam/ifinfo.c
  15. +++ b/libteam/ifinfo.c
  16. @@ -367,23 +367,46 @@ int get_ifinfo_list(struct team_handle *th)
  17. };
  18. int ret;
  19.  
  20. - ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP,
  21. - &rt_hdr, sizeof(rt_hdr));
  22. - if (ret < 0)
  23. - return -nl2syserr(ret);
  24. - orig_cb = nl_socket_get_cb(th->nl_cli.sock);
  25. - cb = nl_cb_clone(orig_cb);
  26. - nl_cb_put(orig_cb);
  27. - if (!cb)
  28. - return -ENOMEM;
  29. -
  30. - nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th);
  31. -
  32. - ret = nl_recvmsgs(th->nl_cli.sock, cb);
  33. - nl_cb_put(cb);
  34. - if (ret < 0)
  35. - return -nl2syserr(ret);
  36. - return check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
  37. + int retry = 1;
  38. + while (retry)
  39. + {
  40. + retry = 0;
  41. + ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP,
  42. + &rt_hdr, sizeof(rt_hdr));
  43. + if (ret < 0)
  44. + {
  45. + err(th, "get_ifinfo_list: nl_send_simple failed: ret = %d", ret);
  46. + return -nl2syserr(ret);
  47. + }
  48. + orig_cb = nl_socket_get_cb(th->nl_cli.sock);
  49. + cb = nl_cb_clone(orig_cb);
  50. + nl_cb_put(orig_cb);
  51. + if (!cb)
  52. + {
  53. + err(th, "get_ifinfo_list: nl_cb_clone failed");
  54. + return -ENOMEM;
  55. + }
  56. +
  57. + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th);
  58. +
  59. + ret = nl_recvmsgs(th->nl_cli.sock, cb);
  60. + nl_cb_put(cb);
  61. + if (ret < 0)
  62. + {
  63. + err(th, "get_ifinfo_list: nl_recvmsgs failed: ret = %d", ret);
  64. + if (ret != -NLE_DUMP_INTR)
  65. + {
  66. + return -nl2syserr(ret);
  67. + }
  68. + retry = 1;
  69. + }
  70. + }
  71. + ret = check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
  72. + if (ret < 0)
  73. + {
  74. + err(th, "get_ifinfo_list: check_call_change_handers failed: ret = %d", ret);
  75. + }
  76. + return ret;
  77. }
  78.  
  79. int ifinfo_list_init(struct team_handle *th)
  80. --
  81. 1.8.3.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement