MAY_LJMP(check_args(L, 1, "close"));
socket = MAY_LJMP(hlua_checksocket(L, 1));
+
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
peer = xref_get_peer(&socket->xref);
if (!peer) {
xref_disconnect(&socket->xref);
WILL_LJMP(luaL_error(L, "The 'receive' function is only allowed in "
"'frontend', 'backend' or 'task'"));
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
socket = MAY_LJMP(hlua_checksocket(L, 1));
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for pattern. */
if (lua_gettop(L) >= 2) {
type = lua_type(L, 2);
buf = MAY_LJMP(luaL_checklstring(L, 2, &buf_len));
sent = MAY_LJMP(luaL_checkinteger(L, 3));
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
socket = MAY_LJMP(hlua_checksocket(L, 1));
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
socket = MAY_LJMP(hlua_checksocket(L, 1));
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
struct stream_interface *si;
struct stream *s;
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
si = appctx->owner;
s = si_strm(si);
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* Check for connection close. */
if (!hlua || channel_output_closed(&s->req)) {
lua_pushnil(L);
/* Get args. */
socket = MAY_LJMP(hlua_checksocket(L, 1));
+
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
ip = MAY_LJMP(luaL_checkstring(L, 2));
if (lua_gettop(L) >= 3)
port = MAY_LJMP(luaL_checkinteger(L, 3));
socket = MAY_LJMP(hlua_checksocket(L, 1));
tmout = MAY_LJMP(luaL_checkinteger(L, 2)) * 1000;
+ /* Check if we run on the same thread than the xreator thread.
+ * We cannot access to the socket if the thread is different.
+ */
+ if (socket->tid != tid)
+ WILL_LJMP(luaL_error(L, "connect: cannot use socket on other thread"));
+
/* check for connection break. If some data where read, return it. */
peer = xref_get_peer(&socket->xref);
if (!peer) {
socket = MAY_LJMP(lua_newuserdata(L, sizeof(*socket)));
lua_rawseti(L, -2, 0);
memset(socket, 0, sizeof(*socket));
+ socket->tid = tid;
/* Check if the various memory pools are intialized. */
if (!pool2_stream || !pool2_buffer) {