Fix box.session.peer in box.session.on_disconnect triggers
iproto_connection_close() closes the connection fd and then pushes the disconnect message to tx, which runs session disconnect triggers. As a result, box.session.peer() return nil, when called from a box.session.on_disconnect() trigger, which prevents us from using the trigger for auditing the disconnect event in the EE version. Postponing close() until after the disconnect triggers have finished wouldn't help, because on OS X and BSD, in contrast to Linux, getpeername() fails if the socket was closed by the other end. To fix this issue, let's store the peer address in the session meta. Note, we need to remove box.session.peer() check from box-tap/session test. The check was added by commit d68050b9 ("Fix on_disconnect trigger"), which fixed a crash on attempt to use box.session.peer() from box.session.on_disconnect() trigger. This patch doesn't reintroduce the crash, but instead fixes the bug in a more extensive way and adds a dedicated test. Closes #7014 NO_DOC=bug fix
Showing
- changelogs/unreleased/gh-7014-session-disconnect-peer.md 5 additions, 0 deletionschangelogs/unreleased/gh-7014-session-disconnect-peer.md
- src/box/iproto.cc 17 additions, 5 deletionssrc/box/iproto.cc
- src/box/lua/session.c 15 additions, 17 deletionssrc/box/lua/session.c
- src/box/session.cc 10 additions, 0 deletionssrc/box/session.cc
- src/box/session.h 30 additions, 0 deletionssrc/box/session.h
- test/box-luatest/gh_7014_session_disconnect_peer_test.lua 37 additions, 0 deletionstest/box-luatest/gh_7014_session_disconnect_peer_test.lua
- test/box-tap/session.test.lua 1 addition, 6 deletionstest/box-tap/session.test.lua
Loading