Skip to content

Commit

Permalink
adopt changes from agentzh bloody-dns-server
Browse files Browse the repository at this point in the history
  • Loading branch information
alonbg committed Sep 8, 2016
1 parent f28a4d7 commit b392061
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/ngx_stream_lua_socket_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,8 @@ ngx_stream_lua_socket_udp_receive(lua_State *L)
ngx_stream_lua_srv_conf_t *lscf;

nargs = lua_gettop(L);
if (nargs != 1) {
return luaL_error(L, "expecting 1 arguments "
if (nargs != 1 && nargs != 2) {
return luaL_error(L, "expecting 1 or 2 arguments "
"(including the object), but got %d", nargs);
}

Expand Down Expand Up @@ -1161,14 +1161,15 @@ ngx_stream_lua_socket_udp_receive(lua_State *L)

if (u->raw_downstream && !u->connected) {
u->received = c->buffer->last - c->buffer->pos;
c->buffer->pos = ngx_copy(ngx_stream_lua_socket_udp_buffer,
c->buffer->pos, u->received);
ngx_stream_lua_socket_udp_handle_success(s, u);
u->connected = 1;
rc = NGX_OK;
c->buffer->pos =
ngx_copy(ngx_stream_lua_socket_udp_buffer, c->buffer->pos,
u->received);
ngx_stream_lua_socket_udp_handle_success(s, u);
u->connected = 1;
rc = NGX_OK;

} else {
rc = ngx_stream_lua_socket_udp_read(s, u);
rc = ngx_stream_lua_socket_udp_read(s, u);
}

if (rc == NGX_ERROR) {
Expand Down Expand Up @@ -1507,8 +1508,9 @@ ngx_stream_lua_socket_udp_handler(ngx_event_t *ev)
c = ev->data;
u = c->data;
s = u->session;
c = s->connection;

ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0,
ngx_log_debug1(NGX_LOG_DEBUG_STREAM, c->log, 0,
"stream lua udp socket handler, wev %d", (int) ev->write);

u->read_event_handler(s, u);
Expand Down
4 changes: 2 additions & 2 deletions t/138-req-udp-socket.t
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ not supported in udp requests
content_by_lua_block {
local sock, err = ngx.req.udp_socket()
sock:send("")
sock:receive(5)
sock:receive(5,4)
}

--- dgram_response
--- error_log
expecting 1 arguments (including the object), but got 2
expecting 1 or 2 arguments (including the object), but got 3



Expand Down

0 comments on commit b392061

Please sign in to comment.