Upgrading dependencies to gorealis v2 and thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-12-26 17:25:59 -08:00
parent 7cbbea498b
commit 54b8d7942a
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1327 changed files with 137391 additions and 61476 deletions

View file

@ -23,9 +23,9 @@ SUBDIRS = .
lib_LTLIBRARIES = \
libluasocket.la \
liblualongnumber.la \
libluabpack.la \
libluabitwise.la \
liblualongnumber.la
libluabitwise.la
libluasocket_la_SOURCES = \
src/luasocket.c \

View file

@ -100,7 +100,7 @@ function TFramedTransport:flush()
local tmp = self.wBuf
self.wBuf = ''
local frame_len_buf = libluabpack.bpack("i", string.len(tmp))
self.trans:write(frame_len_buf)
tmp = frame_len_buf .. tmp
self.trans:write(tmp)
self.trans:flush()
end

View file

@ -25,7 +25,7 @@ THttpTransport = TTransportBase:new{
wBuf = '',
rBuf = '',
CRLF = '\r\n',
VERSION = '0.10.0',
VERSION = '0.12.0',
isServer = true
}

View file

@ -48,7 +48,7 @@ function ttable_size(t)
return count
end
version = 0.10
version = '0.12.0'
TType = {
STOP = 0,

View file

@ -104,10 +104,10 @@ static int l_bunpack(lua_State *L) {
const char *code = luaL_checkstring(L, 1);
luaL_argcheck(L, code[1] == '\0', 0, "Format code must be one character.");
const char *data = luaL_checkstring(L, 2);
#ifdef _LUA51_
size_t len = lua_objlen(L, 2);
#else
#if LUA_VERSION_NUM >= 502
size_t len = lua_rawlen(L, 2);
#else
size_t len = lua_objlen(L, 2);
#endif
switch (code[0]) {

View file

@ -51,8 +51,8 @@ T_ERRCODE socket_send(p_socket sock, const char *data, size_t len, int timeout);
T_ERRCODE socket_recv(p_socket sock, char *data, size_t len, int timeout,
int *received);
void socket_setblocking(p_socket sock);
void socket_setnonblocking(p_socket sock);
T_ERRCODE socket_setblocking(p_socket sock);
T_ERRCODE socket_setnonblocking(p_socket sock);
T_ERRCODE socket_accept(p_socket sock, p_socket sibling,
p_sa addr, socklen_t *addr_len, int timeout);

View file

@ -113,7 +113,7 @@ T_ERRCODE socket_create(p_socket sock, int domain, int type, int protocol) {
T_ERRCODE socket_destroy(p_socket sock) {
// TODO Figure out if I should be free-ing this
if (*sock > 0) {
socket_setblocking(sock);
(void)socket_setblocking(sock);
close(*sock);
*sock = -1;
}
@ -121,13 +121,15 @@ T_ERRCODE socket_destroy(p_socket sock) {
}
T_ERRCODE socket_bind(p_socket sock, p_sa addr, int addr_len) {
int ret = SUCCESS;
socket_setblocking(sock);
int ret = socket_setblocking(sock);
if (ret != SUCCESS) {
return ret;
}
if (bind(*sock, addr, addr_len)) {
ret = errno;
}
socket_setnonblocking(sock);
return ret;
int ret2 = socket_setnonblocking(sock);
return ret == SUCCESS ? ret2 : ret;
}
T_ERRCODE socket_get_info(p_socket sock, short *port, char *buf, size_t len) {
@ -168,22 +170,25 @@ T_ERRCODE socket_accept(p_socket sock, p_socket client,
if (*client > 0) {
return SUCCESS;
}
err = errno;
} while (err != EINTR);
} while ((err = errno) == EINTR);
if (err == EAGAIN || err == ECONNABORTED) {
return socket_wait(sock, WAIT_MODE_R, timeout);
}
return err;
}
T_ERRCODE socket_listen(p_socket sock, int backlog) {
int ret = SUCCESS;
socket_setblocking(sock);
int ret = socket_setblocking(sock);
if (ret != SUCCESS) {
return ret;
}
if (listen(*sock, backlog)) {
ret = errno;
}
socket_setnonblocking(sock);
return ret;
int ret2 = socket_setnonblocking(sock);
return ret == SUCCESS ? ret2 : ret;
}
////////////////////////////////////////////////////////////////////////////////
@ -217,12 +222,12 @@ T_ERRCODE socket_send(
if (put > 0) {
return SUCCESS;
}
err = errno;
} while (err != EINTR);
} while ((err = errno) == EINTR);
if (err == EAGAIN) {
return socket_wait(sock, WAIT_MODE_W, timeout);
}
return err;
}
@ -232,8 +237,8 @@ T_ERRCODE socket_recv(
if (*sock < 0) {
return CLOSED;
}
*received = 0;
int flags = fcntl(*sock, F_GETFL, 0);
do {
got = recv(*sock, data, len, 0);
if (got > 0) {
@ -246,27 +251,28 @@ T_ERRCODE socket_recv(
if (got == 0) {
return CLOSED;
}
} while (err != EINTR);
} while (err == EINTR);
if (err == EAGAIN) {
return socket_wait(sock, WAIT_MODE_R, timeout);
}
return err;
}
////////////////////////////////////////////////////////////////////////////////
// Util
void socket_setnonblocking(p_socket sock) {
T_ERRCODE socket_setnonblocking(p_socket sock) {
int flags = fcntl(*sock, F_GETFL, 0);
flags |= O_NONBLOCK;
fcntl(*sock, F_SETFL, flags);
return fcntl(*sock, F_SETFL, flags) != -1 ? SUCCESS : errno;
}
void socket_setblocking(p_socket sock) {
T_ERRCODE socket_setblocking(p_socket sock) {
int flags = fcntl(*sock, F_GETFL, 0);
flags &= (~(O_NONBLOCK));
fcntl(*sock, F_SETFL, flags);
return fcntl(*sock, F_SETFL, flags) != -1 ? SUCCESS : errno;
}
////////////////////////////////////////////////////////////////////////////////