<commit_before>#include "test_common.h"

#include <evpp/udp/sync_udp_client.h>
#include <evpp/udp/udp_server.h>

namespace {
static int g_count = 0;
static bool g_exit = false;
static uint64_t g_timeout_ms = 1000;
static void OnMessage(evpp::udp::Server* udpsrv, evpp::EventLoop* loop, const evpp::udp::MessagePtr msg) {
    g_count++;
    evpp::udp::SendMessage(msg);
    usleep(100);
    if (memcmp(msg->data(), "stop", msg->size()) == 0) {
        g_exit = true;
    }
}

static void Init() {
    g_count = 0;
    g_exit = false;
}
}

TEST_UNIT(testUDPServer) {
    LOG_TRACE << __func__;
    Init();
    std::vector<int> ports(2, 0);
    ports[0] = 15368;
    ports[1] = 15369;<commit_msg>Fix buffer overrun in udp_server_test.cc<commit_after>#include "test_common.h"

#include <evpp/udp/sync_udp_client.h>
#include <evpp/udp/udp_server.h>

namespace {
static int g_count = 0;
static bool g_exit = false;
static uint64_t g_timeout_ms = 1000;
static void OnMessage(evpp::udp::Server* udpsrv, evpp::EventLoop* loop, const evpp::udp::MessagePtr msg) {
    g_count++;
    evpp::udp::SendMessage(msg);
    usleep(100);
    if (msg->size() == 4 && memcmp(msg->data(), "stop", 4) == 0) {
        g_exit = true;
    }
}

static void Init() {
    g_count = 0;
    g_exit = false;
}
}

TEST_UNIT(testUDPServer) {
    LOG_TRACE << __func__;
    Init();
    std::vector<int> ports(2, 0);
    ports[0] = 15368;
    ports[1] = 15369;
{'fraction_non_alphanumeric': 0.16233309908643712, 'fraction_numerical': 0.03794799718903725, 'mean_word_length': 3.810810810810811, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2608455', 'n_tokens_mistral': 610, 'n_tokens_neox': 568, 'n_words': 117}