<commit_before>// Copyright (c) 2014 Yandex LLC. All rights reserved.
// Author: <NAME> <<EMAIL>>

#include "spdy_transport.H"

#include <pd/base/config.H>
#include <phantom/module.H>

namespace phantom { namespace io_benchmark { namespace method_stream {

MODULE(io_benchmark_method_stream_spdy);

namespace {
    // Thread local SPDY framer
    bq_spec_decl(spdy_framer_t, cur_framer);

    // Connection for SPDY.
    // It's created thread local by method_stream_t.
    // So we piggy back on it and create SPDY framer alongside.
	class conn_ssl_t : public conn_t {
		bq_conn_ssl_t bq_conn_ssl;

		virtual operator bq_conn_t &() {
            return bq_conn_ssl;
        }

	public:
		inline conn_ssl_t(
			int fd, ssl_ctx_t const &ctx, interval_t _timeout, fd_ctl_t const *_ctl
		) : conn_t(fd), bq_conn_ssl(fd, ctx, _timeout, _ctl) {
            // Reset framer for new con
            delete cur_framer;
            cur_framer = new spdy_framer_t(ctx);
        }

		virtual ~conn_ssl_t() throw() {
            delete cur_framer;
        }
	};
}

spdy_transport_t::~spdy_transport_t() throw() {}

conn_t *spdy_transport_t::new_connect(int fd, fd_ctl_t const *_ctl) const {
    return new conn_ssl_t(fd, ctx, timeout, _ctl);
}

spdy_framer_t* spdy_transport_t::current_framer() {<commit_msg>Avoid double deletion of framer.<commit_after>// Copyright (c) 2014 Yandex LLC. All rights reserved.
// Author: <NAME> <<EMAIL>>

#include "spdy_transport.H"

#include <pd/base/config.H>
#include <phantom/module.H>

namespace phantom { namespace io_benchmark { namespace method_stream {

MODULE(io_benchmark_method_stream_spdy);

namespace {
    // Thread local SPDY framer
    bq_spec_decl(spdy_framer_t, cur_framer);

    // Connection for SPDY.
    // It's created thread local by method_stream_t.
    // So we piggy back on it and create SPDY framer alongside.
	class conn_ssl_t : public conn_t {
		bq_conn_ssl_t bq_conn_ssl;

		virtual operator bq_conn_t &() {
            return bq_conn_ssl;
        }

	public:
		inline conn_ssl_t(
			int fd, ssl_ctx_t const &ctx, interval_t _timeout, fd_ctl_t const *_ctl
		) : conn_t(fd), bq_conn_ssl(fd, ctx, _timeout, _ctl) {
            // Reset framer for new con
            delete cur_framer;
            cur_framer = new spdy_framer_t(ctx);
        }

		virtual ~conn_ssl_t() throw() {
            delete cur_framer;
            cur_framer = nullptr;
        }
	};
}

spdy_transport_t::~spdy_transport_t() throw() {}

conn_t *spdy_transport_t::new_connect(int fd, fd_ctl_t const *_ctl) const {
    return new conn_ssl_t(fd, ctx, timeout, _ctl);
}

spdy_framer_t* spdy_transport_t::current_framer() {
{'fraction_non_alphanumeric': 0.10094517958412098, 'fraction_numerical': 0.0030245746691871457, 'mean_word_length': 3.247191011235955, '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': '5041147', 'n_tokens_mistral': 989, 'n_tokens_neox': 947, 'n_words': 232}