Skip to content

Commit

Permalink
Changes to library
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebenezer-group committed Feb 23, 2025
1 parent 7a9d8ab commit 90a852c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/cmwBuffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ template<class R,class Z,int sz>class BufferCompressed:public SendBuffer<Z>,publ
char* compressedStart;
int compPacketSize;
int compIndex=0;
int bytesSent=0;
int bytesRead=0;
bool kosher=true;

Expand All @@ -472,12 +473,17 @@ template<class R,class Z,int sz>class BufferCompressed:public SendBuffer<Z>,publ
}

bool all (int bytes){
bytesSent-=bytes;
if((compIndex-=bytes)==0)return true;
::std::memmove(compBuf,compBuf+bytes,compIndex);
return false;
}

auto outDuo (){return ::std::span<char>(compBuf,compIndex);}
auto outDuo (){
auto sp=::std::span<char>(compBuf+bytesSent,compIndex-bytesSent);
bytesSent=compIndex;
return sp;
}

auto getDuo (){
return bytesRead<9?::std::span<char>(recBuf+bytesRead,9-bytesRead):
Expand Down Expand Up @@ -525,7 +531,7 @@ template<class R,class Z,int sz>class BufferCompressed:public SendBuffer<Z>,publ
this->reset();
comp={};
decomp={};
compIndex=bytesRead=0;
compIndex=bytesSent=bytesRead=0;
kosher=true;
}
};
Expand Down
16 changes: 8 additions & 8 deletions src/tiers/cmwA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ struct Socky{
::socklen_t len=sizeof addr;
};

constexpr ::int32_t bufSize=1101000;
BufferCompressed<SameFormat,::int32_t,bufSize> cmwBuf;
constexpr ::int32_t BufSize=1101000;
BufferCompressed<SameFormat,::int32_t,BufSize> cmwBuf;

class ioUring{
::io_uring rng;
::iovec iov;
int s2ind;
int const udpSock;
constexpr static int maxBatch=10;
constexpr static int MaxBatch=10;

auto getSqe (bool internal=false){
if(auto e=::io_uring_get_sqe(&rng);e)return e;
Expand Down Expand Up @@ -67,8 +67,8 @@ class ioUring{
if(-EINTR!=rc)raise("waitCqe",rc);
}
s2ind=-1;
static ::io_uring_cqe* cqes[maxBatch];
seen=::io_uring_peek_batch_cqe(&rng,&cqes[0],maxBatch);
static ::io_uring_cqe* cqes[MaxBatch];
seen=::io_uring_peek_batch_cqe(&rng,&cqes[0],MaxBatch);
return ::std::span<::io_uring_cqe*>(&cqes[0],seen);
}

Expand Down Expand Up @@ -178,12 +178,12 @@ struct cmwRequest{
#include"cmwA.mdl.hh"

void ioUring::sendto (Socky const& s,auto...t){
if(++s2ind>=maxBatch/2){
if(++s2ind>=MaxBatch/2){
::io_uring_submit(&rng);
s2ind=0;
}
auto e=getSqe();
static ::std::pair<BufferStack<SameFormat>,::sockaddr_in6> frnts[maxBatch/2];
static ::std::pair<BufferStack<SameFormat>,::sockaddr_in6> frnts[MaxBatch/2];
frnts[s2ind].first.reset();
::front::marshal<udpPacketMax>(frnts[s2ind].first,{t...});
auto sp=frnts[s2ind].first.outDuo();
Expand All @@ -204,7 +204,7 @@ void checkField (char const* fld,::std::string_view actl){

void login (cmwCredentials const& cred,auto& sa,bool signUp=false){
signUp? ::back::marshal<::messageID::signup>(cmwBuf,cred)
: ::back::marshal<::messageID::login>(cmwBuf,cred,bufSize);
: ::back::marshal<::messageID::login>(cmwBuf,cred,BufSize);
cmwBuf.compress();
cmwBuf.sock_=::socket(AF_INET,SOCK_STREAM,IPPROTO_SCTP);
while(::connect(cmwBuf.sock_,(::sockaddr*)&sa,sizeof sa)<0){
Expand Down

0 comments on commit 90a852c

Please sign in to comment.