<commit_before>#include "WebSocketPipe.h"
#include "../Interface/Server.h"
#include <algorithm>
#include <assert.h>
#include "../stringtools.h"
#include <memory>

WebSocketPipe::WebSocketPipe(IPipe* pipe, const bool mask_writes, const bool expect_read_mask, std::string pipe_add, bool destroy_pipe)
	: pipe(pipe), mask_writes(mask_writes), expect_read_mask(expect_read_mask), has_error(false),
	pipe_add(pipe_add), read_state(EReadState_Header1), destroy_pipe(destroy_pipe),
	read_mutex(Server->createMutex()), write_mutex(Server->createMutex())
{
	memset(masking_key, 0, sizeof(masking_key));

	if (mask_writes)
	{
		char zero_mask[4] = {};
		/*
		* Just use a fixed non-random masking key. We are not a browser, so the security implications
		* are a bit different
		*/
		while (memcmp(zero_mask, masking_key, sizeof(masking_key)) == 0)
		{
			Server->randomFill(masking_key, sizeof(masking_key));
		}
	}
}

WebSocketPipe::~WebSocketPipe()
{
	if (destroy_pipe)
		delete pipe;
}
<commit_msg>Add missing include<commit_after>#include "WebSocketPipe.h"
#include "../Interface/Server.h"
#include <algorithm>
#include <assert.h>
#include "../stringtools.h"
#include <memory.h>

WebSocketPipe::WebSocketPipe(IPipe* pipe, const bool mask_writes, const bool expect_read_mask, std::string pipe_add, bool destroy_pipe)
	: pipe(pipe), mask_writes(mask_writes), expect_read_mask(expect_read_mask), has_error(false),
	pipe_add(pipe_add), read_state(EReadState_Header1), destroy_pipe(destroy_pipe),
	read_mutex(Server->createMutex()), write_mutex(Server->createMutex())
{
	memset(masking_key, 0, sizeof(masking_key));

	if (mask_writes)
	{
		char zero_mask[4] = {};
		/*
		* Just use a fixed non-random masking key. We are not a browser, so the security implications
		* are a bit different
		*/
		while (memcmp(zero_mask, masking_key, sizeof(masking_key)) == 0)
		{
			Server->randomFill(masking_key, sizeof(masking_key));
		}
	}
}

WebSocketPipe::~WebSocketPipe()
{
	if (destroy_pipe)
		delete pipe;
}

{'fraction_non_alphanumeric': 0.13704819277108435, 'fraction_numerical': 0.004016064257028112, 'mean_word_length': 6.117857142857143, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4990067', 'n_tokens_mistral': 735, 'n_tokens_neox': 710, 'n_words': 146}