<commit_before>/*
 * Copyright (C) 2008-2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file kernel/uconnection.cc
/// \brief Implementation of UConnection.

#include <libport/config.h>
#include <libport/cstring>
#include <libport/cstdio>
#include <libport/cassert>
#include <sstream>
#include <iomanip>

#include <libport/foreach.hh>
#include <libport/format.hh>
#include <libport/ref-pt.hh>

#include <ast/nary.hh>
#include <ast/print.hh>

#include <kernel/userver.hh>
#include <kernel/uconnection.hh>

#include <urbi/uvalue.hh> // SYNCLINE_WRAP

#include <urbi/object/lobby.hh>
#include <urbi/object/object.hh>
#include <object/symbols.hh>
#include <urbi/object/tag.hh>
#include <object/urbi-exception.hh>

#include <parser/uparser.hh>
#include <parser/transform.hh>

#include <binder/binder.hh>

#include <runner/sneaker.hh>
#include <runner/shell.hh>

namespace kernel
{

  UConnection::UConnection(UServer& server, size_t packetSize)
    : uerror_(USUCCESS)
    , closing_(false)
    , receiving_(false)
    , server_(server)
    , lobby_(new object::Lobby(this))
    , send_queue_(new queue_type(1024))
    , packet_size_(packetSize)
    , blocked_(false)
      // Initial state of the connection: unblocked, not receiving binary.
    , active_(true)
    , interactive_p_(true)
    , bytes_sent_(0)
    , bytes_received_(0)
    , stream_buffer_()
    , stream_(&stream_buffer_)
  {
    stream_.exceptions(std::ios::badbit);

    // Create the shell.
    shell_ = new runner::Shell(lobby_, server_.scheduler_get(), SYMBOL(shell), stream_);
    shell_->start_job();

    // Create the sneaker if it needs to be.
    dbg::create_sneaker_if_needed(lobby_, server_.scheduler_get());
  }

  UConnection::~UConnection()
  {
    lobby_->tag_get()->stop();
    shell_->terminate_now();
  }

  void
  UConnection::initialize()
  {
    received(SYNCLINE_WRAP("initialize(%s)|;",
                           kernel::urbiserver->opt_banner_get()));<commit_msg>Restore loading of global.u<commit_after>/*
 * Copyright (C) 2008-2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file kernel/uconnection.cc
/// \brief Implementation of UConnection.

#include <libport/config.h>
#include <libport/cstring>
#include <libport/cstdio>
#include <libport/cassert>
#include <sstream>
#include <iomanip>

#include <libport/foreach.hh>
#include <libport/format.hh>
#include <libport/ref-pt.hh>

#include <ast/nary.hh>
#include <ast/print.hh>

#include <kernel/userver.hh>
#include <kernel/uconnection.hh>

#include <urbi/uvalue.hh> // SYNCLINE_WRAP

#include <urbi/object/lobby.hh>
#include <urbi/object/object.hh>
#include <object/symbols.hh>
#include <urbi/object/tag.hh>
#include <object/urbi-exception.hh>

#include <parser/uparser.hh>
#include <parser/transform.hh>

#include <binder/binder.hh>

#include <runner/sneaker.hh>
#include <runner/shell.hh>

namespace kernel
{

  UConnection::UConnection(UServer& server, size_t packetSize)
    : uerror_(USUCCESS)
    , closing_(false)
    , receiving_(false)
    , server_(server)
    , lobby_(new object::Lobby(this))
    , send_queue_(new queue_type(1024))
    , packet_size_(packetSize)
    , blocked_(false)
      // Initial state of the connection: unblocked, not receiving binary.
    , active_(true)
    , interactive_p_(true)
    , bytes_sent_(0)
    , bytes_received_(0)
    , stream_buffer_()
    , stream_(&stream_buffer_)
  {
    stream_.exceptions(std::ios::badbit);

    // Create the shell.
    shell_ = new runner::Shell(lobby_, server_.scheduler_get(), SYMBOL(shell), stream_);
    shell_->start_job();

    // Create the sneaker if it needs to be.
    dbg::create_sneaker_if_needed(lobby_, server_.scheduler_get());
  }

  UConnection::~UConnection()
  {
    lobby_->tag_get()->stop();
    shell_->terminate_now();
  }

  void
  UConnection::initialize()
  {
    received(SYNCLINE_WRAP("initialize(%s, %s)|;",
                             kernel::urbiserver->opt_banner_get(),
                             &kernel::urbiserver->ghost_connection_get()==this));
{'fraction_non_alphanumeric': 0.14153915391539154, 'fraction_numerical': 0.0063006300630063005, 'mean_word_length': 3.8579234972677594, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 64, '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': '485028', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1491, 'n_words': 314}