{"action":"created","issue":{"url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/625","labels_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/625/labels{/name}","comments_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/625/comments","events_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/625/events","html_url":"https://github.com/openresty/lua-nginx-module/pull/625","id":122437142,"number":625,"title":"feature: allow tcpsock:setkeepalive() to receive nil args","user":{"login":"thibaultCha","id":1125431,"avatar_url":"https://avatars.githubusercontent.com/u/1125431?v=3","gravatar_id":"","url":"https://api.github.com/users/thibaultCha","html_url":"https://github.com/thibaultCha","followers_url":"https://api.github.com/users/thibaultCha/followers","following_url":"https://api.github.com/users/thibaultCha/following{/other_user}","gists_url":"https://api.github.com/users/thibaultCha/gists{/gist_id}","starred_url":"https://api.github.com/users/thibaultCha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thibaultCha/subscriptions","organizations_url":"https://api.github.com/users/thibaultCha/orgs","repos_url":"https://api.github.com/users/thibaultCha/repos","events_url":"https://api.github.com/users/thibaultCha/events{/privacy}","received_events_url":"https://api.github.com/users/thibaultCha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-16T06:12:26Z","updated_at":"2015-12-16T07:19:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/openresty/lua-nginx-module/pulls/625","html_url":"https://github.com/openresty/lua-nginx-module/pull/625","diff_url":"https://github.com/openresty/lua-nginx-module/pull/625.diff","patch_url":"https://github.com/openresty/lua-nginx-module/pull/625.patch"},"body":"`tcpsock:setkeepalive()` arguments are documented as being optional, yet they cannot be `nil`. This patch proposes to check if those arguments are `nil` before checking their type. If they are nil, then the configuration values are used as one would expect.\r\n\r\nIt comes handy when doing things like `sock:setkeepalive(var1, var2)` and if `var1` and `var2` are actually `nil`. It also allows one to do `sock:setkeepalive(nil, 25)`, though I hope this particular usage does not break the API.\r\n\r\nIt was motivated by an edge-case I encountered [here](https://github.com/thibaultCha/lua-cassandra/commit/759289d7404ff47a24779ee1c554861648e05adb#diff-ec126ebe12c61abf0bec8b3f0d0a3180R365) with this [travis failure](https://travis-ci.org/thibaultCha/lua-cassandra/jobs/96895510), in a scenario where a user of a lua-resty module can configure those options for the sockets used by that module.\r\n\r\n---\r\n\r\nSide note:\r\n\r\nI would like to say I ran the tests but sadly I did not.\r\n- I first followed the ngx_lua development instructions (I wanted to run all the tests with the full mysql/redis/memcached environment) but it seems [util/build2.sh](https://github.com/openresty/lua-nginx-module/blob/master/util/build2.sh) is outdated (some modules apparently got renamed, some paths are hard-coded, the Nginx version looks somewhat old).\r\n- Fair enough, I decided to update it and slightly tweak it for my system, but so far drizzle has prevented me from finishing this. I have it compiled but `drizzle-nginx-module` does not seem to like any `LIBDRIZZLE_LIB` I am giving to it (granted this is totally outside the scope of this PR).\r\n- I decided to simply download the latest OpenResty bundle and only run the `068-socket-keepalive.t` tests against it, without much success since the tests are failing, mainly due to the response size being checked:\r\n```\r\n# -received response of 156 bytes\r\n# +received response of 160 bytes\r\n```\r\nI decided to ignore them (assumed it was a platform issue) and did not investigate. \r\n\r\n- I thought I'd make my changes to ngx_lua and compiled the bundle directly with it:\r\n```\r\n./configure --without-http_lua_module --add-module=../lua-nginx-module\r\n```\r\nAnd I added my test with an `--- ONLY` flag. However, the Nginx process cannot start when I compile OpenResty this way (with or without my changes):\r\n```\r\nt/068-socket-keepalive.t .. # I found ONLY: maybe you're debugging?\r\nnginx: [error] failed to initialize Lua VM in /path/to/openresty-dev/lua-nginx-module/t/servroot/conf/nginx.conf:103\r\nBailout called.  Further testing stopped:  TEST 10b: sock:keepalive_timeout(nil) - Cannot start nginx using command \"nginx -p /path/to/openresty-dev/lua-nginx-module/t/servroot/ -c /path/to/openresty-dev/lua-nginx-module/t/servroot/conf/nginx.conf > /dev/null\".\r\n```\r\n\r\nIs there any recommended development installation (maybe more recent than `build2.sh`?) or have I done something wrong along the way? (I am on OS X btw). I am fine with using a VM if you think it would be easier. **Sorry for the long note!**"},"comment":{"url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/comments/165021114","html_url":"https://github.com/openresty/lua-nginx-module/pull/625#issuecomment-165021114","issue_url":"https://api.github.com/repos/openresty/lua-nginx-module/issues/625","id":165021114,"user":{"login":"agentzh","id":56241,"avatar_url":"https://avatars.githubusercontent.com/u/56241?v=3","gravatar_id":"","url":"https://api.github.com/users/agentzh","html_url":"https://github.com/agentzh","followers_url":"https://api.github.com/users/agentzh/followers","following_url":"https://api.github.com/users/agentzh/following{/other_user}","gists_url":"https://api.github.com/users/agentzh/gists{/gist_id}","starred_url":"https://api.github.com/users/agentzh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agentzh/subscriptions","organizations_url":"https://api.github.com/users/agentzh/orgs","repos_url":"https://api.github.com/users/agentzh/repos","events_url":"https://api.github.com/users/agentzh/events{/privacy}","received_events_url":"https://api.github.com/users/agentzh/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T07:19:35Z","updated_at":"2015-12-16T07:19:35Z","body":"@thibaultCha Oh, I haven't updated the default nginx version there for years since I always explicitly specify a version when invoking it, as in `./util/build2.sh 1.9.7`."}}