Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebenezer-group committed Jan 13, 2025
1 parent 7964241 commit a3d5f31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/cmwBuffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using sockType=SOCKET;
#include<arpa/inet.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<unistd.h>//chdir,fsync
#include<unistd.h>//chdir
using sockType=int;
#endif

Expand Down Expand Up @@ -281,7 +281,6 @@ template<class R,class Z>class ReceiveBuffer{
int fd=fl();
Write(fd,rbuf+subTotal+rindex,sz);
rindex+=sz;
::fsync(fd);
fl.release();
return fd;
}
Expand Down
13 changes: 11 additions & 2 deletions src/tiers/cmwA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Socky{
constexpr ::uint64_t reedTag=1;
constexpr ::uint64_t closTag=2;
constexpr ::uint64_t sendtoTag=3;
constexpr ::uint64_t fsyncTag=4;
class ioUring{
::io_uring rng;
::iovec iov;
Expand Down Expand Up @@ -96,6 +97,14 @@ class ioUring{
::io_uring_sqe_set_flags(e,IOSQE_CQE_SKIP_SUCCESS);
}

void fsync (int fd){
auto e=getSqe();
::io_uring_prep_fsync(e,fd,0);
::io_uring_sqe_set_data64(e,fsyncTag);
::io_uring_sqe_set_flags(e,IOSQE_IO_HARDLINK|IOSQE_CQE_SKIP_SUCCESS);
clos(fd);
}

void sendto (Socky const&,auto...);
} *ring;

Expand Down Expand Up @@ -163,7 +172,7 @@ struct cmwRequest{

void ending (){
Write(fl(),(char*)&bday,sizeof bday);
ring->clos(cmwBuf.giveFile(path.append(".hh")));
ring->fsync(cmwBuf.giveFile(path.append(".hh")));
ring->clos(fl());
fl.release();
}
Expand Down Expand Up @@ -242,7 +251,7 @@ int main (int ac,char** av)try{

for(;;){
for(auto cq:ring->submit()){
if(cq->res<0||(cq->res==0&&cq->user_data==reedTag)){
if(cq->res<0||(cq->res==0&&reedTag==cq->user_data)){
::syslog(LOG_ERR,"Op failed %llu %d",cq->user_data,cq->res);
if(-EPIPE!=cq->res&&0!=cq->res)exitFailure();
rfrntBuf.reset();
Expand Down

0 comments on commit a3d5f31

Please sign in to comment.