easywsclient
easywsclient copied to clipboard
Error while send() and poll() at same Time
If the poll() function is called by multithread while an other thread is "masking" the data are send only masked on the first bytes and the sendData() function crashes.
workoround (easywsclient.cpp line 410):
std::vector<uint8_t> txbuftemp; txbuftemp.insert(txbuftemp.end(), header.begin(), header.end()); txbuftemp.insert(txbuftemp.end(), message_begin, message_end); if (useMask) { size_t message_offset = txbuftemp.size() - message_size; for (size_t i = 0; i != message_size; ++i) { txbuftemp[message_offset + i] ^= masking_key[i&0x3]; } } txbuf.insert(txbuf.end(), txbuftemp.begin(), txbuftemp.end());
Second little bug:
line 489: on error if (sscanf(line, "HTTP/1.1 %d", &status) != 1 || status != 101)
the socket isn't closed. By while(1){"Reconnect";} and unreachable Server, the application crashes because of "Too Many open Files".