easywsclient icon indicating copy to clipboard operation
easywsclient copied to clipboard

Error while send() and poll() at same Time

Open Keden92 opened this issue 7 years ago • 0 comments

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".

Keden92 avatar Feb 01 '18 19:02 Keden92