Esempio n. 1
0
static int luazmq_skt_destroy (lua_State *L) {
  zsocket *skt = (zsocket *)luazmq_checkudatap (L, 1, LUAZMQ_SOCKET);
  luaL_argcheck (L, skt != NULL, 1, LUAZMQ_PREFIX"socket expected");
  if(!(skt->flags & LUAZMQ_FLAG_CLOSED)){
    int ret;
    luazmq_skt_before_close(L, skt);
    if(!(skt->flags & LUAZMQ_FLAG_DONT_DESTROY)){
      if(lua_isnumber(L, 2)){
        int linger = luaL_optint(L, 2, 0);
        zmq_setsockopt(skt->skt, ZMQ_LINGER, &linger, sizeof(linger));
      }
      ret = zmq_close(skt->skt);
      assert(ret != -1);
      // if(ret == -1)return luazmq_fail(L, skt);
    }

#if LZMQ_SOCKET_COUNT
    if(skt->ctx){
      skt->ctx->socket_count--;
      assert(skt->ctx->socket_count >= 0);
    }
#endif

    skt->flags |= LUAZMQ_FLAG_CLOSED;
  }
  return luazmq_pass(L);
}
Esempio n. 2
0
File: zmsg.c Progetto: jrossi/lzmq
int luazmq_msg_close(lua_State *L){
  zmessage *zmsg = (zmessage *)luazmq_checkudatap (L, 1, LUAZMQ_MESSAGE);
  luaL_argcheck (L, zmsg != NULL, 1, LUAZMQ_PREFIX"message expected");
  if(!(zmsg->flags & LUAZMQ_FLAG_CLOSED)){
    zmq_msg_close(&zmsg->msg);
    zmsg->flags |= LUAZMQ_FLAG_CLOSED;
  }
  return luazmq_pass(L);
}
Esempio n. 3
0
File: zmsg.c Progetto: jrossi/lzmq
static int luazmq_msg_closed (lua_State *L) {
  zmessage *zmsg = (zmessage *)luazmq_checkudatap (L, 1, LUAZMQ_MESSAGE);
  luaL_argcheck (L, zmsg != NULL, 1, LUAZMQ_PREFIX"message expected");
  lua_pushboolean(L, zmsg->flags & LUAZMQ_FLAG_CLOSED);
  return 1;
}
Esempio n. 4
0
static int luazmq_skt_closed (lua_State *L) {
  zsocket *skt = (zsocket *)luazmq_checkudatap (L, 1, LUAZMQ_SOCKET);
  luaL_argcheck (L, skt != NULL, 1, LUAZMQ_PREFIX"socket expected");
  lua_pushboolean(L, skt->flags & LUAZMQ_FLAG_CLOSED);
  return 1;
}