Beispiel #1
0
    void serialize_certificate(Archive& archive, Connection & connection,
        std::set<boost::uint32_t>& localities, parcel const& p)
    {
        // We send the certificate corresponding to the originating locality
        // of the parcel if this is the first message over this connection
        // or if the originating locality is not the current one.
        boost::uint32_t locality_id =
            naming::get_locality_id_from_gid(p.get_parcel_id());
        error_code ec(lightweight);
        boost::uint32_t this_locality_id = get_locality_id(ec);
        if (ec) {
            // this should only happen during bootstrap
            HPX_ASSERT(hpx::is_starting());
            this_locality_id = locality_id;
        }

        bool has_certificate = false;
        if ((connection.first_message_ || locality_id != this_locality_id) &&
            localities.find(locality_id) == localities.end())
        {
            // the first message must originate from this locality
            HPX_ASSERT(!connection.first_message_ || locality_id == this_locality_id);

            components::security::signed_certificate const& certificate =
                hpx::get_locality_certificate(locality_id, ec);

            if (!ec) {
                has_certificate = true;
                if (locality_id == this_locality_id)
                    connection.first_message_ = false;
                archive << has_certificate << certificate;

                // keep track of all certificates already prepended for this message
                localities.insert(locality_id);
            }
            else {
                // if the certificate is not available we have to still be on
                // the 'first' message (it's too early for a certificate)
                HPX_ASSERT(connection.first_message_);
                archive << has_certificate;
            }
        }
        else {
            archive << has_certificate;
        }
    }
Beispiel #2
0
    void parcelport::put_parcel(parcel const& p, write_handler_type const& f)
    {
        typedef pending_parcels_map::iterator iterator;
        typedef pending_parcels_map::mapped_type mapped_type;

        naming::locality locality_id = p.get_destination_locality();
        naming::gid_type parcel_id = p.get_parcel_id();

        // enqueue the incoming parcel ...
        {
            lcos::local::spinlock::scoped_lock l(mtx_);

            mapped_type& e = pending_parcels_[locality_id];
            e.first.push_back(p);
            e.second.push_back(f);
        }

        get_connection_and_send_parcels(locality_id, parcel_id);
    }
Beispiel #3
0
 boost::shared_ptr<parcel_buffer_type> get_buffer(parcel const & p, std::size_t arg_size)
 {
     // generate the name for this data_buffer
     std::string data_buffer_name(p.get_parcel_id().to_string());
     if(!buffer_)
     {
         // clear and preallocate out_buffer_ (or fetch from cache)
         buffer_ = boost::make_shared<parcel_buffer_type>(
             get_data_buffer((arg_size * 12) / 10 + 1024,
                 data_buffer_name)
         );
     }
     else
     {
         buffer_->data_ =
             get_data_buffer((arg_size * 12) / 10 + 1024,
                 data_buffer_name);
     }
     return buffer_;
 }
Beispiel #4
0
    void parcelhandler::put_parcel(parcel& p, write_handler_type f)
    {
        // properly initialize parcel
        init_parcel(p);

        std::vector<naming::gid_type> const& gids = p.get_destinations();
        std::vector<naming::address>& addrs = p.get_destination_addrs();

        if (1 == gids.size()) {
            if (!addrs[0])
                resolver_.resolve(gids[0], addrs[0]);
        }
        else {
            boost::dynamic_bitset<> locals;
            resolver_.resolve(gids, addrs, locals);
        }

        if (!p.get_parcel_id())
            p.set_parcel_id(parcel::generate_unique_id());

        pp_.put_parcel(p, f);
    }
Beispiel #5
0
        bool add_parcel(parcel const& p)
        {
            naming::gid_type id(p.get_parcel_id());

            // Add parcel to queue.
            {
                mutex_type::scoped_lock l(mtx_);
                std::pair<parcel_map_type::iterator, bool> ret =
                    parcels_.insert(parcel_map_type::value_type(id, p));

                if (!ret.second) {
                    HPX_THROW_EXCEPTION(bad_parameter,
                        "global_parcelhandler_queue::add_parcel",
                        "Could not add received parcel to the parcelhandler "
                        "queue");
                    return false;
                }
            }

            // do some work (notify event handlers)
            HPX_ASSERT(ph_ != 0);
            notify_(*ph_, id);
            return true;
        }