{"action":"created","issue":{"url":"https://api.github.com/repos/coreos/go-iptables/issues/15","repository_url":"https://api.github.com/repos/coreos/go-iptables","labels_url":"https://api.github.com/repos/coreos/go-iptables/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/coreos/go-iptables/issues/15/comments","events_url":"https://api.github.com/repos/coreos/go-iptables/issues/15/events","html_url":"https://github.com/coreos/go-iptables/pull/15","id":142737811,"number":15,"title":"Unlock the file instead of closing the fd","user":{"login":"freehan","id":1332699,"avatar_url":"https://avatars.githubusercontent.com/u/1332699?v=3","gravatar_id":"","url":"https://api.github.com/users/freehan","html_url":"https://github.com/freehan","followers_url":"https://api.github.com/users/freehan/followers","following_url":"https://api.github.com/users/freehan/following{/other_user}","gists_url":"https://api.github.com/users/freehan/gists{/gist_id}","starred_url":"https://api.github.com/users/freehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freehan/subscriptions","organizations_url":"https://api.github.com/users/freehan/orgs","repos_url":"https://api.github.com/users/freehan/repos","events_url":"https://api.github.com/users/freehan/events{/privacy}","received_events_url":"https://api.github.com/users/freehan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-22T18:25:35Z","updated_at":"2016-03-24T16:29:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/coreos/go-iptables/pulls/15","html_url":"https://github.com/coreos/go-iptables/pull/15","diff_url":"https://github.com/coreos/go-iptables/pull/15.diff","patch_url":"https://github.com/coreos/go-iptables/pull/15.patch"},"body":"Fix a problem when using CNI plugins on Debian with iptable version v1.4.14\r\n\r\nIf `AppendUnique` is called more than twice using the same iptables object. After 1st call, syscall will always return `bad file descriptor` error. \r\n"},"comment":{"url":"https://api.github.com/repos/coreos/go-iptables/issues/comments/200912390","html_url":"https://github.com/coreos/go-iptables/pull/15#issuecomment-200912390","issue_url":"https://api.github.com/repos/coreos/go-iptables/issues/15","id":200912390,"user":{"login":"dcbw","id":10926354,"avatar_url":"https://avatars.githubusercontent.com/u/10926354?v=3","gravatar_id":"","url":"https://api.github.com/users/dcbw","html_url":"https://github.com/dcbw","followers_url":"https://api.github.com/users/dcbw/followers","following_url":"https://api.github.com/users/dcbw/following{/other_user}","gists_url":"https://api.github.com/users/dcbw/gists{/gist_id}","starred_url":"https://api.github.com/users/dcbw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcbw/subscriptions","organizations_url":"https://api.github.com/users/dcbw/orgs","repos_url":"https://api.github.com/users/dcbw/repos","events_url":"https://api.github.com/users/dcbw/events{/privacy}","received_events_url":"https://api.github.com/users/dcbw/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T16:29:04Z","updated_at":"2016-03-24T16:29:04Z","body":"eg, like this?\r\n\r\n```\r\ndiff --git a/iptables/iptables.go b/iptables/iptables.go\r\nindex ea9fedf..a9f4a70 100644\r\n--- a/iptables/iptables.go\r\n+++ b/iptables/iptables.go\r\n@@ -44,8 +44,6 @@ type IPTables struct {\r\n        path     string\r\n        hasCheck bool\r\n        hasWait  bool\r\n-\r\n-       fmu *fileLock\r\n }\r\n \r\n func New() (*IPTables, error) {\r\n@@ -64,12 +62,6 @@ func New() (*IPTables, error) {\r\n                hasCheck: checkPresent,\r\n                hasWait:  waitPresent,\r\n        }\r\n-       if !waitPresent {\r\n-               ipt.fmu, err = newXtablesFileLock()\r\n-               if err != nil {\r\n-                       return nil, err\r\n-               }\r\n-       }\r\n        return &ipt, nil\r\n }\r\n \r\n@@ -183,7 +175,11 @@ func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {\r\n        if ipt.hasWait {\r\n                args = append(args, \"--wait\")\r\n        } else {\r\n-               ul, err := ipt.fmu.tryLock()\r\n+               fmu, err := newXtablesFileLock()\r\n+               if err != nil {\r\n+                       return err\r\n+               }\r\n+               ul, err := fmu.tryLock()\r\n                if err != nil {\r\n                        return err\r\n                }\r\n```"}}