sign: Do not allow port TxMode/StreamsType to be changed while tx is on
This commit is contained in:
parent
a79bbb1fcd
commit
9de3f96b20
@ -65,6 +65,28 @@ void AbstractPort::init()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Can we modify Port with these params? Should modify cause port dirty? */
|
||||||
|
bool AbstractPort::canModify(const OstProto::Port &port, bool *dirty)
|
||||||
|
{
|
||||||
|
bool allow = true;
|
||||||
|
|
||||||
|
*dirty = false;
|
||||||
|
|
||||||
|
if (port.has_transmit_mode()
|
||||||
|
&& (port.transmit_mode() != data_.transmit_mode())) {
|
||||||
|
*dirty = true;
|
||||||
|
allow = !isTransmitOn();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port.has_streams_type()
|
||||||
|
&& (port.streams_type() != data_.streams_type())) {
|
||||||
|
*dirty = true;
|
||||||
|
allow = !isTransmitOn();
|
||||||
|
}
|
||||||
|
|
||||||
|
return allow;
|
||||||
|
}
|
||||||
|
|
||||||
bool AbstractPort::modify(const OstProto::Port &port)
|
bool AbstractPort::modify(const OstProto::Port &port)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
@ -87,6 +87,7 @@ public:
|
|||||||
const char* name() { return data_.name().c_str(); }
|
const char* name() { return data_.name().c_str(); }
|
||||||
void protoDataCopyInto(OstProto::Port *port) { port->CopyFrom(data_); }
|
void protoDataCopyInto(OstProto::Port *port) { port->CopyFrom(data_); }
|
||||||
|
|
||||||
|
bool canModify(const OstProto::Port &port, bool *dirty);
|
||||||
bool modify(const OstProto::Port &port);
|
bool modify(const OstProto::Port &port);
|
||||||
|
|
||||||
virtual OstProto::LinkState linkState() { return linkState_; }
|
virtual OstProto::LinkState linkState() { return linkState_; }
|
||||||
|
@ -133,13 +133,20 @@ void MyService::modifyPort(::google::protobuf::RpcController* /*controller*/,
|
|||||||
id = port.port_id().id();
|
id = port.port_id().id();
|
||||||
if (id < portInfo.size())
|
if (id < portInfo.size())
|
||||||
{
|
{
|
||||||
// FIXME: return error for any change in transmitMode/streamsType
|
bool dirty;
|
||||||
// while transmit is on
|
|
||||||
|
if (!portInfo[id]->canModify(port, &dirty)) {
|
||||||
|
qDebug("Port %d cannot be modified - stop tx and retry", id);
|
||||||
|
continue; //! \todo(LOW): Partial status of RPC
|
||||||
|
}
|
||||||
|
|
||||||
portLock[id]->lockForWrite();
|
portLock[id]->lockForWrite();
|
||||||
portInfo[id]->modify(port);
|
portInfo[id]->modify(port);
|
||||||
|
if (dirty)
|
||||||
|
portInfo[id]->updatePacketList();
|
||||||
portLock[id]->unlock();
|
portLock[id]->unlock();
|
||||||
|
|
||||||
|
|
||||||
notif->mutable_port_id_list()->add_port_id()->set_id(id);
|
notif->mutable_port_id_list()->add_port_id()->set_id(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user