Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luazmq_skt_setopt_* functions make a mistake getting option_value #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

evanchen
Copy link

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);"

@moteus
Copy link
Member

moteus commented May 26, 2018

This is bug, but your fix is not correct.
Need create separate function to set arbitrary option.
You can use set_sndtimeo function

@evanchen
Copy link
Author

@moteus thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants