From d2ca0d52f2dfccf0ed1358c034438beb560af3be Mon Sep 17 00:00:00 2001 From: Brando Date: Tue, 29 Apr 2025 09:50:14 -0700 Subject: [PATCH 1/3] altering accessors --- bfnet/src/connection.cpp | 4 ++-- bfnet/src/connection.hpp | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bfnet/src/connection.cpp b/bfnet/src/connection.cpp index 41cd0aad..959d05c1 100644 --- a/bfnet/src/connection.cpp +++ b/bfnet/src/connection.cpp @@ -74,11 +74,11 @@ bool BF::Net::Connection::isactive() const { return true; } -const char BF::Net::Connection::mode() { +const char BF::Net::Connection::mode() const { return this->_sktref->mode(); } -void BF::Net::Connection::getuuid(uuid_t uuid) { +void BF::Net::Connection::getuuid(uuid_t uuid) const { memcpy(uuid, this->_uuid, sizeof(uuid_t)); } diff --git a/bfnet/src/connection.hpp b/bfnet/src/connection.hpp index 0b13f408..406d11a8 100644 --- a/bfnet/src/connection.hpp +++ b/bfnet/src/connection.hpp @@ -46,18 +46,17 @@ class Connection : public BF::Object { * data : data to be sent. this data is copied. Caller still owns * size : size of data buffer */ - //int queueData(const void * data, size_t size); int queueData(const BF::Data * buf); /** * see Socket::mode */ - const char mode(); + const char mode() const; /** * returns uuid */ - void getuuid(uuid_t uuid); + void getuuid(uuid_t uuid) const; /** * returns socket type [SOCK_STREAM, SOCK_DGRAM, ...] @@ -67,6 +66,11 @@ class Connection : public BF::Object { */ int type() const; + /** + * closes socket descriptor + */ + void closeConnection(); + private: /** @@ -75,11 +79,6 @@ class Connection : public BF::Object { Connection(int sd, Socket * sktref); virtual ~Connection(); - /** - * closes socket descriptor - */ - void closeConnection(); - int sendData(const BF::Data * buf); /** From 2a2a151d9c15be48abff93ec205aa8b9b59a5fb6 Mon Sep 17 00:00:00 2001 From: Brando Date: Tue, 29 Apr 2025 14:06:12 -0700 Subject: [PATCH 2/3] update todo --- bflibcpp/todo.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bflibcpp/todo.md b/bflibcpp/todo.md index 4cd32750..0c65fcc1 100644 --- a/bflibcpp/todo.md +++ b/bflibcpp/todo.md @@ -1,5 +1,3 @@ - -- [ ] BF::Array to use new/delete for memory allocation - [x] improve List sorting - [x] move sort logic to array and list - [x] reevaluate logic location, moved to sort.hpp @@ -15,10 +13,12 @@ - [ ] json to map - [ ] standard pair - [ ] tuple -- [ ] address compiler warning regarding ambiguous operations +- [x] address compiler warning regarding ambiguous operations - [ ] String to integer -- [ ] optimize String - - [ ] when appending to string, grab more memory so we don't have keep calling realloc all the time +- [ ] array memory optimization, improving virtual memory usage + - [ ] BF::Array to use new/delete for memory allocation + - [ ] optimize String + - [ ] when appending to string, grab more memory so we don't have keep calling realloc all the time - [x] collection sorting algorithm - [x] make sure there are no Delete() calls and must use BFRelease instead - [x] throw compiler warnings when using delete From 857d10340f4ea91a66a869b3e0db05d3601c5a3b Mon Sep 17 00:00:00 2001 From: Brando Date: Tue, 29 Apr 2025 15:48:44 -0700 Subject: [PATCH 3/3] cleaning up some logs --- bfnet/src/connection.cpp | 7 +++---- bfnet/src/socket.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bfnet/src/connection.cpp b/bfnet/src/connection.cpp index 959d05c1..0d176328 100644 --- a/bfnet/src/connection.cpp +++ b/bfnet/src/connection.cpp @@ -52,7 +52,6 @@ bool BF::Net::Connection::isready() const { bool BF::Net::Connection::isactive() const { if (this->_sd.get() == 0) { - BFNetLogDebug("%s - socket descriptor is 0", __FUNCTION__); return false; } @@ -147,11 +146,11 @@ int BF::Net::Connection::sendData(const Data * buf) { int BF::Net::Connection::recvData(Data * data) { if (this->_sd.get() == 0) { - return 1; + return 100; } else if (!this->isactive()) { - return 1; + return 101; } else if (!data) { - return 1; + return 102; } BFNetLogDebug("> recvData"); diff --git a/bfnet/src/socket.cpp b/bfnet/src/socket.cpp index 3ae6b3b1..210c86dc 100644 --- a/bfnet/src/socket.cpp +++ b/bfnet/src/socket.cpp @@ -138,7 +138,7 @@ void BF::Net::Socket::inStream(void * in) { int err = sc->recvData(&envelope->_data); if (err) { - BFNetLogDebug("%s - error returned from recvData: %d. Aborting reading socket...", __FUNCTION__, err); + BFNetLogDebug("%s - exiting recv loop %d", __FUNCTION__, err); BFRelease(envelope); break; } else {