mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Fixed rigctl server
This commit is contained in:
@ -63,7 +63,7 @@ namespace net {
|
||||
connectionOpenCnd.wait(lck, [this]() { return !connectionOpen; });
|
||||
}
|
||||
|
||||
int ConnClass::read(int count, uint8_t* buf) {
|
||||
int ConnClass::read(int count, uint8_t* buf, bool enforceSize) {
|
||||
if (!connectionOpen) { return -1; }
|
||||
std::lock_guard lck(readMtx);
|
||||
int ret;
|
||||
@ -95,6 +95,8 @@ namespace net {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!enforceSize) { return ret; }
|
||||
|
||||
beenRead += ret;
|
||||
}
|
||||
|
||||
@ -135,7 +137,7 @@ namespace net {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConnClass::readAsync(int count, uint8_t* buf, void (*handler)(int count, uint8_t* buf, void* ctx), void* ctx) {
|
||||
void ConnClass::readAsync(int count, uint8_t* buf, void (*handler)(int count, uint8_t* buf, void* ctx), void* ctx, bool enforceSize) {
|
||||
if (!connectionOpen) { return; }
|
||||
// Create entry
|
||||
ConnReadEntry entry;
|
||||
@ -143,6 +145,7 @@ namespace net {
|
||||
entry.buf = buf;
|
||||
entry.handler = handler;
|
||||
entry.ctx = ctx;
|
||||
entry.enforceSize = enforceSize;
|
||||
|
||||
// Add entry to queue
|
||||
{
|
||||
@ -184,7 +187,7 @@ namespace net {
|
||||
lck.unlock();
|
||||
|
||||
// Read from socket and send data to the handler
|
||||
int ret = read(entry.count, entry.buf);
|
||||
int ret = read(entry.count, entry.buf, entry.enforceSize);
|
||||
if (ret <= 0) {
|
||||
{
|
||||
std::lock_guard lck(connectionOpenMtx);
|
||||
|
@ -33,6 +33,7 @@ namespace net {
|
||||
uint8_t* buf;
|
||||
void (*handler)(int count, uint8_t* buf, void* ctx);
|
||||
void* ctx;
|
||||
bool enforceSize;
|
||||
};
|
||||
|
||||
struct ConnWriteEntry {
|
||||
@ -49,9 +50,9 @@ namespace net {
|
||||
bool isOpen();
|
||||
void waitForEnd();
|
||||
|
||||
int read(int count, uint8_t* buf);
|
||||
int read(int count, uint8_t* buf, bool enforceSize = true);
|
||||
bool write(int count, uint8_t* buf);
|
||||
void readAsync(int count, uint8_t* buf, void (*handler)(int count, uint8_t* buf, void* ctx), void* ctx);
|
||||
void readAsync(int count, uint8_t* buf, void (*handler)(int count, uint8_t* buf, void* ctx), void* ctx, bool enforceSize = true);
|
||||
void writeAsync(int count, uint8_t* buf);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user