socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

fix: resolve #254: avoid double close calls while closing sockets

Open AdrianDC opened this issue 4 years ago • 0 comments

Upon long-term usage, I sometimes triggered segmentation faults due to an already freed / closed socket.

The on_fail and on_open functions need to handle the socket properly.

Test: I will use my patched version for a few days and confirm within next week.

C++ client : test.cpp NodeJS server : test.js

docker run --rm -i -v "${PWD}:${PWD}" -w "${PWD}" centos:7.6.1810 <<EOF
# Dependencies
yum install -y cmake gcc gcc-c++ make openssl-devel psmisc
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum install -y nodejs
npm install socket.io

# Library
rm -rf ./build
mkdir -p ./build/
cd ./build/
cmake  ../
make install
cd ../

# Build
g++ -std=c++11 -Wall -lpthread -o test254 test.cpp /usr/local/lib*/libsioclient.a

# Test
{
  set +m;
  node ./test.js &
  time timeout -s9 10 ./test254
  killall node
}
EOF

AdrianDC avatar Feb 25 '21 19:02 AdrianDC