本文整理汇总了C++中PacketPtr::set_IncomingPktCount方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr::set_IncomingPktCount方法的具体用法?C++ PacketPtr::set_IncomingPktCount怎么用?C++ PacketPtr::set_IncomingPktCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketPtr
的用法示例。
在下文中一共展示了PacketPtr::set_IncomingPktCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recv
//.........这里部分代码省略.........
else {
using_prealloc = false;
buf = (char*) malloc( buf_len );
packet_sizes = (uint64_t*) malloc( sizeof(uint64_t) * num_buffers );
ncbufs = new XPlat::SocketUtils::NCBuf[num_buffers];
memset( (void*)ncbufs, 0,
num_buffers * sizeof(XPlat::SocketUtils::NCBuf) );
}
retval = MRN_recv( sock_fd, buf, buf_len );
if( retval != (ssize_t)buf_len ) {
mrn_dbg( 3, mrn_printf(FLF, stderr, "MRN_recv() %" PRIsszt" of %" PRIsszt" bytes received\n",
retval, buf_len ));
rc = -1;
goto recv_cleanup_return;
}
pdrmem_create( &pdrs, buf, buf_len, op, pdrmem_getbo() );
if( ! pdr_vector(&pdrs, (char*)packet_sizes, num_buffers,
sizeof(uint64_t), (pdrproc_t)pdr_uint64) ) {
mrn_dbg( 1, mrn_printf(FLF, stderr, "pdr_vector() failed\n" ));
rc = -1;
goto recv_cleanup_return;
}
/* NOTE: we tell users that packet header and data buffers will have similar
alignment characteristics to malloc, so if we ever stop using malloc
we will need to make sure that the buffers are properly aligned */
for( i = 0; i < num_buffers; i++ ) {
len = packet_sizes[i];
ncbufs[i].buf = (char*) malloc( size_t(len) );
ncbufs[i].len = size_t(len);
total_bytes += size_t(len);
}
retval = XPlat::SocketUtils::Recv( sock_fd, ncbufs, num_buffers );
if( retval != total_bytes ) {
mrn_dbg( 1, mrn_printf(FLF, stderr, "SocketUtils::Recv %" PRIsszt" of %" PRIsszt" bytes received\n",
retval, total_bytes) );
rc = -1;
goto recv_cleanup_return;
}
//
// post-processing
//
for( i = 0, j = 0; j < num_packets; i += 2, j++ ) {
PacketPtr new_packet( new Packet((unsigned int)ncbufs[i].len,
ncbufs[i].buf,
ncbufs[i+1].len,
ncbufs[i+1].buf,
iinlet_rank) );
if( new_packet->has_Error() ) {
mrn_dbg( 1, mrn_printf(FLF, stderr, "packet creation failed\n") );
rc = -1;
goto recv_cleanup_return;
}
packets_in.push_back( new_packet );
ncbufs[i].buf = NULL;
ncbufs[i+1].buf = NULL;
}
t1.stop();
pkt_size = (int) packets_in.size();
piter = packets_in.begin();
for( ; piter != packets_in.end(); piter++ ) {
pkt = *piter;
strm = _net->get_Stream( pkt->get_StreamId() );
if( strm != NULL ) {
// Time for packet at this point in time.
if( strm->get_PerfData()->is_Enabled(PERFDATA_MET_ELAPSED_SEC,
PERFDATA_CTX_PKT_RECV) ) {
pkt->set_Timer(PERFDATA_PKT_TIMERS_RECV, t1);
}
pkt->start_Timer(PERFDATA_PKT_TIMERS_RECV_TO_FILTER);
pkt->set_IncomingPktCount(pkt_size);
}
}
recv_cleanup_return:
if( -1 == rc ) {
for( unsigned u = 0; u < num_buffers; u++ ) {
if( NULL != ncbufs[u].buf )
free( (void*)(ncbufs[u].buf) );
}
}
if( ! using_prealloc ) {
free( buf );
free( packet_sizes );
delete[] ncbufs;
}
mrn_dbg_func_end();
return rc;
}