luazmq_skt_setopt_* functions make a mistake getting option_value #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
lua use case:
socket,err = self.ctx:socket(zmq.XREQ)
assert(socket,err)
socket:setopt_int(zmq.SNDTIMEO,1000)
but the option value 1000 doesn't work.
please have a look at the codes below,
...
{"setopt_int", luazmq_skt_setopt_int },
...
static int luazmq_skt_setopt_int(lua_State *L){ return luazmq_skt_set_int(L, luaL_checkint(L,2)); }
...
static int luazmq_skt_set_int (lua_State *L, int option_name) {
zsocket *skt = luazmq_getsocket(L);
int option_value = luaL_checkint(L, 2);
int ret = zmq_setsockopt(skt->skt, option_name, &option_value, sizeof(option_value));
...
}
the paramter "option_value" is just the same as "option_name", because they're the same stack 2 of lua_State, it seems definitely a bug to me. so as the other functions,
luazmq_skt_set_i64
luazmq_skt_set_u64
luazmq_skt_set_str
the "option_value" should be the return value of "luaL_checkint(L, 3);"