diff --git a/server/abstractport.cpp b/server/abstractport.cpp index b43a312..1764d52 100644 --- a/server/abstractport.cpp +++ b/server/abstractport.cpp @@ -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 ret = true; diff --git a/server/abstractport.h b/server/abstractport.h index 426c475..da5c70e 100644 --- a/server/abstractport.h +++ b/server/abstractport.h @@ -87,6 +87,7 @@ public: const char* name() { return data_.name().c_str(); } void protoDataCopyInto(OstProto::Port *port) { port->CopyFrom(data_); } + bool canModify(const OstProto::Port &port, bool *dirty); bool modify(const OstProto::Port &port); virtual OstProto::LinkState linkState() { return linkState_; } diff --git a/server/myservice.cpp b/server/myservice.cpp index 88c627b..334853f 100644 --- a/server/myservice.cpp +++ b/server/myservice.cpp @@ -133,13 +133,20 @@ void MyService::modifyPort(::google::protobuf::RpcController* /*controller*/, id = port.port_id().id(); if (id < portInfo.size()) { - // FIXME: return error for any change in transmitMode/streamsType - // while transmit is on + bool dirty; + + 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(); portInfo[id]->modify(port); + if (dirty) + portInfo[id]->updatePacketList(); portLock[id]->unlock(); + notif->mutable_port_id_list()->add_port_id()->set_id(id); } }