Skip to content

Commit 1c991ad

Browse files
committed
uni15_test(1) works for backlog and new files
1 parent 0a448f6 commit 1c991ad

23 files changed

+356
-271
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ set(CPACK_GENERATOR DEB STGZ RPM) # RPM needs yum(1)-compatible UPC software rep
107107
include(CPack)
108108

109109
# Configure deployment and testing
110-
configure_file(deploy.sh deploy)
111-
configure_file(uni15-test.sh uni15-test)
110+
configure_file(deploy.sh deploy @ONLY)
111+
configure_file(uni15-test.sh uni15-test @ONLY)

main/BicastProto.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "BicastProto.h"
2424

2525
#include "error.h"
26+
#include "logging.h"
2627
#include "Xprt.h"
2728

2829
#include <chrono>
@@ -157,11 +158,13 @@ class ProdIdSet::Impl
157158
* @retval false Connection lost
158159
*/
159160
bool write(Xprt& xprt) const {
160-
if (!xprt.write(static_cast<uint32_t>(prodIds.size())))
161+
uint32_t size = prodIds.size();
162+
if (!xprt.write(size))
161163
return false;
162-
for (auto iter = prodIds.begin(), end = prodIds.end(); iter != end; ++iter)
164+
for (auto iter = prodIds.begin(), end = prodIds.end(); iter != end; ++iter, --size)
163165
if (!iter->write(xprt))
164166
return false;
167+
LOG_ASSERT(size == 0);
165168
return true;
166169
}
167170

@@ -177,7 +180,7 @@ class ProdIdSet::Impl
177180
return false;
178181
prodIds.clear();
179182
prodIds.reserve(size);
180-
for (uint32_t i; i < size; ++i) {
183+
while (size--) {
181184
ProdId prodId;
182185
if (!prodId.read(xprt))
183186
return false;

main/BicastProto.h

-16
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,6 @@ class DataSeg final : public XprtAble
468468
std::shared_ptr<Impl> pImpl;
469469

470470
public:
471-
/**
472-
* Sets the maximum size of a data-segment.
473-
*
474-
* @param[in] maxSegSize Maximum data-segment size in bytes
475-
* @return Previous value
476-
* @throw InvalidArgument Argument is not positive
477-
*/
478-
static SegSize setMaxSegSize(const SegSize maxSegSize) noexcept;
479-
480-
/**
481-
* Gets the maximum size of a data-segment.
482-
*
483-
* @return Maximum size of a data-segment in bytes
484-
*/
485-
static SegSize getMaxSegSize() noexcept;
486-
487471
/**
488472
* Returns the size of a given data-segment.
489473
*

main/inet/Xprt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace bicast {
3737
/// An implementation of a transport
3838
class Xprt::Impl
3939
{
40-
const Socket sock; ///< Underlying socket
40+
const Socket sock; ///< Underlying socket
4141

4242
inline bool hton(const bool value) {
4343
return value;

main/node/Node.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ class PubNodeImpl final : public PubNode, public NodeImpl
436436
, repo(FileUtil::pathname(RunPar::pubRoot, "products"), lastTransmission->recall())
437437
, maxSegSize{RunPar::maxSegSize}
438438
, senderThread()
439-
{
440-
DataSeg::setMaxSegSize(maxSegSize);
441-
}
439+
{}
442440

443441
~PubNodeImpl() noexcept {
444442
//LOG_DEBUG("Publisher-node being destroyed");
@@ -676,7 +674,7 @@ class SubNodeImpl final : public SubNode, public NodeImpl
676674
, mcastSub{McastSub::create(subInfo.mcast.dstAddr, subInfo.mcast.srcAddr, this)}
677675
, client(client)
678676
{
679-
DataSeg::setMaxSegSize(subInfo.maxSegSize);
677+
RunPar::maxSegSize = subInfo.maxSegSize;
680678
}
681679

682680
~SubNodeImpl() noexcept {

main/p2p/DataSeg.cpp

+12-47
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
* @file: DataSeg.cpp
55
* @author: Steven R. Emmerson <[email protected]>
66
*
7-
* Copyright 2021 University Corporation for Atmospheric Research
7+
* Copyright 2023 University Corporation for Atmospheric Research
88
*
9-
* Licensed under the Apache License, Version 2.0 (the "License");
10-
* you may not use this file except in compliance with the License.
11-
* You may obtain a copy of the License at
9+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
10+
* in compliance with the License. You may obtain a copy of the License at
1211
*
1312
* http://www.apache.org/licenses/LICENSE-2.0
1413
*
15-
* Unless required by applicable law or agreed to in writing, software
16-
* distributed under the License is distributed on an "AS IS" BASIS,
17-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18-
* See the License for the specific language governing permissions and
19-
* limitations under the License.
14+
* Unless required by applicable law or agreed to in writing, software distributed under the License
15+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
16+
* or implied. See the License for the specific language governing permissions and limitations under
17+
* the License.
2018
*/
2119

2220
#include "config.h"
2321

2422
#include "BicastProto.h"
2523
#include "error.h"
24+
#include "RunPar.h"
2625
#include "Socket.h"
2726
#include "Xprt.h"
2827

@@ -34,37 +33,13 @@ namespace bicast {
3433
/// An implementation of a data segment
3534
class DataSeg::Impl
3635
{
37-
static std::atomic<SegSize> maxSegSize; ///< Maximum data-segment size in bytes
38-
3936
public:
4037
DataSegId segId; ///< Data-segment identifier
4138
/// Product size in bytes (for when product notice is missed)
4239
ProdSize prodSize;
4340
SegSize bufSize; ///< Size of buffer in bytes
4441
char* buf; ///< buffer for data
4542

46-
/**
47-
* Sets the maximum size, in bytes, of a data segment. All segments except the last will be this
48-
* size.
49-
* @param[in] maxSegSize Maximum size of a data segment
50-
* @return The previous maximum segment size
51-
*/
52-
static SegSize setMaxSegSize(const SegSize maxSegSize) {
53-
if (maxSegSize <= 0)
54-
throw INVALID_ARGUMENT("Argument is not positive: " + std::to_string(maxSegSize));
55-
SegSize prev = Impl::maxSegSize;
56-
Impl::maxSegSize = maxSegSize;
57-
return prev;
58-
}
59-
60-
/**
61-
* Returns the maximum size of a data segment.
62-
* @return The maximum size of a data segment
63-
*/
64-
static SegSize getMaxSegSize() {
65-
return maxSegSize;
66-
}
67-
6843
/**
6944
* Returns the expected size of a data segment.
7045
* @param[in] prodSize Size of the containing data product in bytes
@@ -75,9 +50,9 @@ class DataSeg::Impl
7550
const ProdSize prodSize,
7651
const SegOffset offset) noexcept {
7752
const auto nbytes = prodSize - offset;
78-
return (nbytes <= maxSegSize)
53+
return (nbytes <= RunPar::maxSegSize)
7954
? nbytes
80-
: static_cast<SegSize>(maxSegSize);
55+
: RunPar::maxSegSize;
8156
}
8257

8358
/**
@@ -86,7 +61,7 @@ class DataSeg::Impl
8661
* @return The number of data segments in the product
8762
*/
8863
static ProdSize numSegs(const ProdSize prodSize) noexcept {
89-
return (prodSize + (maxSegSize - 1)) / maxSegSize;
64+
return (prodSize + (RunPar::maxSegSize - 1)) / RunPar::maxSegSize;
9065
}
9166

9267
/**
@@ -95,7 +70,7 @@ class DataSeg::Impl
9570
* @return The origin-0 index of the data segment
9671
*/
9772
static ProdSize getSegIndex(const ProdSize offset) {
98-
return offset/maxSegSize;
73+
return offset/RunPar::maxSegSize;
9974
}
10075

10176
Impl()
@@ -232,18 +207,8 @@ class DataSeg::Impl
232207
}
233208
};
234209

235-
std::atomic<SegSize> DataSeg::Impl::maxSegSize; ///< Maximum data-segment size in bytes
236-
237210
/******************************************************************************/
238211

239-
SegSize DataSeg::setMaxSegSize(const SegSize maxSegSize) noexcept {
240-
return Impl::setMaxSegSize(maxSegSize);
241-
}
242-
243-
SegSize DataSeg::getMaxSegSize() noexcept {
244-
return Impl::getMaxSegSize();
245-
}
246-
247212
SegSize DataSeg::size(
248213
const ProdSize prodSize,
249214
const SegOffset offset) noexcept {

0 commit comments

Comments
 (0)