Commit bb37616b authored by Kirill Smelkov's avatar Kirill Smelkov

Merge branch 'master' into t

* master:
  wcfs: client: Adjust to be forward-compatible with upcoming pygolang changes
  wcfs: client: Adjust naming for os::File to match upcoming pygolang
parents 89bee96e 11e023cf
// Copyright (C) 2019-2021 Nexedi SA and Contributors. // Copyright (C) 2019-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "bigfile/_file_zodb.h" #include "bigfile/_file_zodb.h"
#include <ccan/container_of/container_of.h> #include <ccan/container_of/container_of.h>
using namespace xgolang;
static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blklen) { static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blklen) {
_ZBigFile* _zfile = container_of(file, _ZBigFile, __pyx_base.file); _ZBigFile* _zfile = container_of(file, _ZBigFile, __pyx_base.file);
...@@ -39,7 +41,7 @@ static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blkl ...@@ -39,7 +41,7 @@ static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blkl
tie(mmap, err) = fileh->mmap(blk, blklen, vma); tie(mmap, err) = fileh->mmap(blk, blklen, vma);
if (err != nil) { if (err != nil) {
log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem xlog::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
return -1; return -1;
} }
...@@ -56,7 +58,7 @@ static int zfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) { ...@@ -56,7 +58,7 @@ static int zfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) {
error err; error err;
err = mmap->remmap_blk(blk); err = mmap->remmap_blk(blk);
if (err != nil) { if (err != nil) {
log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem xlog::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
return -1; return -1;
} }
...@@ -74,7 +76,7 @@ static int zfile_munmap(VMA *vma, BigFile *file) { ...@@ -74,7 +76,7 @@ static int zfile_munmap(VMA *vma, BigFile *file) {
error err; error err;
err = mmap->unmap(); err = mmap->unmap();
if (err != nil) { if (err != nil) {
log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem xlog::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
return -1; return -1;
} }
......
// Copyright (C) 2018-2021 Nexedi SA and Contributors. // Copyright (C) 2018-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -229,7 +229,7 @@ using std::min; ...@@ -229,7 +229,7 @@ using std::min;
using std::max; using std::max;
using std::vector; using std::vector;
namespace ioutil = io::ioutil; namespace ioutil = xgolang::io::ioutil;
#define TRACE 0 #define TRACE 0
...@@ -755,7 +755,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -755,7 +755,7 @@ error _Conn::resync(zodb::Tid at) {
// update f._headfsize and remmap to head/f zero regions that are now covered by head/f // update f._headfsize and remmap to head/f zero regions that are now covered by head/f
struct stat st; struct stat st;
err = f->_headf->stat(&st); err = f->_headf->Stat(&st);
if (err != nil) if (err != nil)
return E(err); return E(err);
...@@ -956,18 +956,18 @@ error _FileH::_open() { ...@@ -956,18 +956,18 @@ error _FileH::_open() {
bool retok = false; bool retok = false;
defer([&]() { defer([&]() {
if (!retok) if (!retok)
f._headf->close(); f._headf->Close();
}); });
struct stat st; struct stat st;
err = f._headf->stat(&st); err = f._headf->Stat(&st);
if (err != nil) if (err != nil)
return err; return err;
f.blksize = st.st_blksize; f.blksize = st.st_blksize;
f._headfsize = st.st_size; f._headfsize = st.st_size;
if (!(f._headfsize % f.blksize == 0)) if (!(f._headfsize % f.blksize == 0))
return fmt::errorf("wcfs bug: %s size (%d) %% blksize (%d) != 0", return fmt::errorf("wcfs bug: %s size (%d) %% blksize (%d) != 0",
v(f._headf->name()), f._headfsize, f.blksize); v(f._headf->Name()), f._headfsize, f.blksize);
// start watching f // start watching f
// NOTE we are _not_ holding wconn.filehMu nor f.mmapMu - only wconn.atMu to rely on wconn.at being stable. // NOTE we are _not_ holding wconn.filehMu nor f.mmapMu - only wconn.atMu to rely on wconn.at being stable.
...@@ -1066,7 +1066,7 @@ error _FileH::_closeLocked(bool force) { ...@@ -1066,7 +1066,7 @@ error _FileH::_closeLocked(bool force) {
panic("BUG: fileh.close: wconn.filehTab[fileh.foid] != fileh"); panic("BUG: fileh.close: wconn.filehTab[fileh.foid] != fileh");
wconn->_filehTab.erase(fileh.foid); wconn->_filehTab.erase(fileh.foid);
reterr1(fileh._headf->close()); reterr1(fileh._headf->Close());
// change all fileh.mmaps to cause EFAULT on any access after fileh.close // change all fileh.mmaps to cause EFAULT on any access after fileh.close
fileh._mmapMu.lock(); fileh._mmapMu.lock();
...@@ -1110,7 +1110,7 @@ void _FileH::_afterFork() { ...@@ -1110,7 +1110,7 @@ void _FileH::_afterFork() {
panic("BUG: fileh.closeAfterFork: wconn.filehTab[fileh.foid] != fileh"); panic("BUG: fileh.closeAfterFork: wconn.filehTab[fileh.foid] != fileh");
wconn->_filehTab.erase(fileh.foid); wconn->_filehTab.erase(fileh.foid);
fileh._headf->close(); // ignore err fileh._headf->Close(); // ignore err
// change all fileh.mmaps to cause EFAULT on access // change all fileh.mmaps to cause EFAULT on access
for (auto mmap : fileh._mmaps) { for (auto mmap : fileh._mmaps) {
...@@ -1343,11 +1343,11 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) { ...@@ -1343,11 +1343,11 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
} }
defer([&]() { defer([&]() {
if (fclose) if (fclose)
fsfile->close(); fsfile->Close();
}); });
struct stat st; struct stat st;
err = fsfile->stat(&st); err = fsfile->Stat(&st);
if (err != nil) if (err != nil)
return E(err); return E(err);
if ((size_t)st.st_blksize != f->blksize) if ((size_t)st.st_blksize != f->blksize)
...@@ -1426,7 +1426,7 @@ string WCFS::_path(const string &obj) { ...@@ -1426,7 +1426,7 @@ string WCFS::_path(const string &obj) {
tuple<os::File, error> WCFS::_open(const string &path, int flags) { tuple<os::File, error> WCFS::_open(const string &path, int flags) {
WCFS& wc = *this; WCFS& wc = *this;
string path_ = wc._path(path); string path_ = wc._path(path);
return os::open(path_, flags); return os::Open(path_, flags);
} }
...@@ -1441,11 +1441,11 @@ static error mmap_zero_into(void *addr, size_t size, int prot) { ...@@ -1441,11 +1441,11 @@ static error mmap_zero_into(void *addr, size_t size, int prot) {
// this way the mapping will be able to be read, but no memory will be allocated to keep it. // this way the mapping will be able to be read, but no memory will be allocated to keep it.
os::File z; os::File z;
error err; error err;
tie(z, err) = os::open("/dev/zero"); tie(z, err) = os::Open("/dev/zero");
if (err != nil) if (err != nil)
return E(err); return E(err);
defer([&]() { defer([&]() {
z->close(); z->Close();
}); });
err = mm::map_into(addr, size, prot, MAP_SHARED | MAP_NORESERVE, z, 0); err = mm::map_into(addr, size, prot, MAP_SHARED | MAP_NORESERVE, z, 0);
if (err != nil) if (err != nil)
......
// Copyright (C) 2018-2021 Nexedi SA and Contributors. // Copyright (C) 2018-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -118,6 +118,10 @@ struct VMA; ...@@ -118,6 +118,10 @@ struct VMA;
namespace wcfs { namespace wcfs {
using namespace golang; using namespace golang;
namespace os = xgolang::xos;
namespace mm = xgolang::xmm;
namespace xstrconv = xgolang::xstrconv;
namespace log = xgolang::xlog;
using cxx::dict; using cxx::dict;
using cxx::set; using cxx::set;
using std::tuple; using std::tuple;
......
// Copyright (C) 2019-2021 Nexedi SA and Contributors. // Copyright (C) 2019-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -36,11 +36,13 @@ using namespace golang; ...@@ -36,11 +36,13 @@ using namespace golang;
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
// golang:: // xgolang::
namespace golang { namespace xgolang {
// os:: // xos::
namespace os { namespace xos {
namespace io = golang::io;
global<error> ErrClosed = errors::New("file already closed"); global<error> ErrClosed = errors::New("file already closed");
...@@ -49,8 +51,8 @@ global<error> ErrClosed = errors::New("file already closed"); ...@@ -49,8 +51,8 @@ global<error> ErrClosed = errors::New("file already closed");
static error _pathError(const char *op, const string &path, int syserr); static error _pathError(const char *op, const string &path, int syserr);
static string _sysErrString(int syserr); static string _sysErrString(int syserr);
int _File::fd() const { return _fd; } int _File::_sysfd() const { return _fd; }
string _File::name() const { return _path; } string _File::Name() const { return _path; }
_File::_File() {} _File::_File() {}
_File::~_File() {} _File::~_File() {}
...@@ -60,7 +62,7 @@ void _File::decref() { ...@@ -60,7 +62,7 @@ void _File::decref() {
} }
tuple<File, error> open(const string &path, int flags, mode_t mode) { tuple<File, error> Open(const string &path, int flags, mode_t mode) {
int fd = ::open(path.c_str(), flags, mode); int fd = ::open(path.c_str(), flags, mode);
if (fd == -1) if (fd == -1)
return make_tuple(nil, _pathError("open", path, errno)); return make_tuple(nil, _pathError("open", path, errno));
...@@ -71,7 +73,7 @@ tuple<File, error> open(const string &path, int flags, mode_t mode) { ...@@ -71,7 +73,7 @@ tuple<File, error> open(const string &path, int flags, mode_t mode) {
return make_tuple(f, nil); return make_tuple(f, nil);
} }
error _File::close() { error _File::Close() {
_File& f = *this; _File& f = *this;
int err = ::close(f._fd); int err = ::close(f._fd);
...@@ -81,7 +83,7 @@ error _File::close() { ...@@ -81,7 +83,7 @@ error _File::close() {
return nil; return nil;
} }
tuple<int, error> _File::read(void *buf, size_t count) { tuple<int, error> _File::Read(void *buf, size_t count) {
_File& f = *this; _File& f = *this;
int n; int n;
...@@ -94,7 +96,7 @@ tuple<int, error> _File::read(void *buf, size_t count) { ...@@ -94,7 +96,7 @@ tuple<int, error> _File::read(void *buf, size_t count) {
return make_tuple(n, nil); return make_tuple(n, nil);
} }
tuple <int, error> _File::write(const void *buf, size_t count) { tuple <int, error> _File::Write(const void *buf, size_t count) {
_File& f = *this; _File& f = *this;
int n, wrote=0; int n, wrote=0;
...@@ -112,7 +114,7 @@ tuple <int, error> _File::write(const void *buf, size_t count) { ...@@ -112,7 +114,7 @@ tuple <int, error> _File::write(const void *buf, size_t count) {
return make_tuple(wrote, nil); return make_tuple(wrote, nil);
} }
error _File::stat(struct stat *st) { error _File::Stat(struct stat *st) {
_File& f = *this; _File& f = *this;
int err = fstat(f._fd, st); int err = fstat(f._fd, st);
...@@ -196,24 +198,24 @@ static string _sysErrString(int syserr) { ...@@ -196,24 +198,24 @@ static string _sysErrString(int syserr) {
return string(estr); return string(estr);
} }
} // os:: } // xos::
// mm:: // xmm::
namespace mm { namespace xmm {
// map memory-maps f.fd[offset +size) somewhere into memory. // map memory-maps f.fd[offset +size) somewhere into memory.
// prot is PROT_* from mmap(2). // prot is PROT_* from mmap(2).
// flags is MAP_* from mmap(2); MAP_FIXED must not be used. // flags is MAP_* from mmap(2); MAP_FIXED must not be used.
tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t size) { tuple<uint8_t*, error> map(int prot, int flags, xos::File f, off_t offset, size_t size) {
void *addr; void *addr;
if (flags & MAP_FIXED) if (flags & MAP_FIXED)
panic("MAP_FIXED not allowed for map - use map_into"); panic("MAP_FIXED not allowed for map - use map_into");
addr = ::mmap(nil, size, prot, flags, f->fd(), offset); addr = ::mmap(nil, size, prot, flags, f->_sysfd(), offset);
if (addr == MAP_FAILED) if (addr == MAP_FAILED)
return make_tuple(nil, os::_pathError("mmap", f->name(), errno)); return make_tuple(nil, xos::_pathError("mmap", f->Name(), errno));
return make_tuple((uint8_t*)addr, nil); return make_tuple((uint8_t*)addr, nil);
} }
...@@ -221,12 +223,12 @@ tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t ...@@ -221,12 +223,12 @@ tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t
// map_into memory-maps f.fd[offset +size) into [addr +size). // map_into memory-maps f.fd[offset +size) into [addr +size).
// prot is PROT_* from mmap(2). // prot is PROT_* from mmap(2).
// flags is MAP_* from mmap(2); MAP_FIXED is added automatically. // flags is MAP_* from mmap(2); MAP_FIXED is added automatically.
error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t offset) { error map_into(void *addr, size_t size, int prot, int flags, xos::File f, off_t offset) {
void *addr2; void *addr2;
addr2 = ::mmap(addr, size, prot, MAP_FIXED | flags, f->fd(), offset); addr2 = ::mmap(addr, size, prot, MAP_FIXED | flags, f->_sysfd(), offset);
if (addr2 == MAP_FAILED) if (addr2 == MAP_FAILED)
return os::_pathError("mmap", f->name(), errno); return xos::_pathError("mmap", f->Name(), errno);
if (addr2 != addr) if (addr2 != addr)
panic("mmap(addr, MAP_FIXED): returned !addr"); panic("mmap(addr, MAP_FIXED): returned !addr");
return nil; return nil;
...@@ -236,11 +238,11 @@ error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t o ...@@ -236,11 +238,11 @@ error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t o
error unmap(void *addr, size_t size) { error unmap(void *addr, size_t size) {
int err = ::munmap(addr, size); int err = ::munmap(addr, size);
if (err != 0) if (err != 0)
return os::_pathError("munmap", "<memory>", errno); return xos::_pathError("munmap", "<memory>", errno);
return nil; return nil;
} }
} // mm:: } // xmm::
// io::ioutil:: // io::ioutil::
...@@ -249,10 +251,10 @@ namespace ioutil { ...@@ -249,10 +251,10 @@ namespace ioutil {
tuple<string, error> ReadFile(const string& path) { tuple<string, error> ReadFile(const string& path) {
// errctx is ok as returned by all calls. // errctx is ok as returned by all calls.
os::File f; xos::File f;
error err; error err;
tie(f, err) = os::open(path); tie(f, err) = xos::Open(path);
if (err != nil) if (err != nil)
return make_tuple("", err); return make_tuple("", err);
...@@ -261,16 +263,16 @@ tuple<string, error> ReadFile(const string& path) { ...@@ -261,16 +263,16 @@ tuple<string, error> ReadFile(const string& path) {
while (1) { while (1) {
int n; int n;
tie(n, err) = f->read(&buf[0], buf.size()); tie(n, err) = f->Read(&buf[0], buf.size());
data.append(&buf[0], n); data.append(&buf[0], n);
if (err != nil) { if (err != nil) {
if (err == io::EOF_) if (err == golang::io::EOF_)
err = nil; err = nil;
break; break;
} }
} }
error err2 = f->close(); error err2 = f->Close();
if (err == nil) if (err == nil)
err = err2; err = err2;
if (err != nil) if (err != nil)
...@@ -318,7 +320,7 @@ tuple<uint64_t, error> parseUint(const string& s) { ...@@ -318,7 +320,7 @@ tuple<uint64_t, error> parseUint(const string& s) {
} // xstrconv:: } // xstrconv::
} // golang:: } // xgolang::
// xerr:: // xerr::
...@@ -354,9 +356,9 @@ error Contextf::operator() (error err) const { ...@@ -354,9 +356,9 @@ error Contextf::operator() (error err) const {
#include <sys/types.h> #include <sys/types.h>
#include <sys/syscall.h> #include <sys/syscall.h>
// golang::log:: // xgolang::xlog::
namespace golang { namespace xgolang {
namespace log { namespace xlog {
void __Logf(const char *file, int line, char level, const char *format, ...) { void __Logf(const char *file, int line, char level, const char *format, ...) {
double t = time::now(); double t = time::now();
...@@ -385,7 +387,7 @@ void __Logf(const char *file, int line, char level, const char *format, ...) { ...@@ -385,7 +387,7 @@ void __Logf(const char *file, int line, char level, const char *format, ...) {
funlockfile(stderr); funlockfile(stderr);
} }
}} // golang::log:: }} // xgolang::xlog::
// wcfs:: // wcfs::
......
// Copyright (C) 2019-2021 Nexedi SA and Contributors. // Copyright (C) 2019-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -55,11 +55,11 @@ using std::vector; ...@@ -55,11 +55,11 @@ using std::vector;
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
// golang:: // xgolang::
namespace golang { namespace xgolang {
// os:: // xos::
namespace os { namespace xos {
extern global<error> ErrClosed; extern global<error> ErrClosed;
...@@ -75,34 +75,34 @@ class _File : public object { ...@@ -75,34 +75,34 @@ class _File : public object {
private: private:
_File(); _File();
~_File(); ~_File();
friend tuple<File, error> open(const string &path, int flags, mode_t mode); friend tuple<File, error> Open(const string &path, int flags, mode_t mode);
public: public:
void decref(); void decref();
public: public:
int fd() const; int _sysfd() const;
string name() const; string Name() const;
error close(); error Close();
// read implements io.Reader from Go: it reads into buf up-to count bytes. // read implements io.Reader from Go: it reads into buf up-to count bytes.
// XXX buf -> slice<byte> ? // XXX buf -> slice<byte> ?
tuple<int, error> read(void *buf, size_t count); tuple<int, error> Read(void *buf, size_t count);
// write implements io.Writer from Go: it writes all data from buf. // write implements io.Writer from Go: it writes all data from buf.
// //
// NOTE write behaves like io.Writer in Go - it tries to write as much // NOTE write behaves like io.Writer in Go - it tries to write as much
// bytes as requested, and if it could write only less - it returns error. // bytes as requested, and if it could write only less - it returns error.
// XXX buf -> slice<byte> ? // XXX buf -> slice<byte> ?
tuple<int, error> write(const void *buf, size_t count); tuple<int, error> Write(const void *buf, size_t count);
error stat(struct stat *st); error Stat(struct stat *st);
private: private:
error _errno(const char *op); error _errno(const char *op);
}; };
// open opens file @path. // Open opens file @path.
tuple<File, error> open(const string &path, int flags = O_RDONLY, tuple<File, error> Open(const string &path, int flags = O_RDONLY,
mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP | S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH); S_IROTH | S_IWOTH | S_IXOTH);
...@@ -126,15 +126,15 @@ void RegisterAfterFork(IAfterFork obj); ...@@ -126,15 +126,15 @@ void RegisterAfterFork(IAfterFork obj);
// It is noop if obj was not registered. // It is noop if obj was not registered.
void UnregisterAfterFork(IAfterFork obj); void UnregisterAfterFork(IAfterFork obj);
} // os:: } // xos::
// mm:: // xmm::
namespace mm { namespace xmm {
tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t size); tuple<uint8_t*, error> map(int prot, int flags, xos::File f, off_t offset, size_t size);
error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t offset); error map_into(void *addr, size_t size, int prot, int flags, xos::File f, off_t offset);
error unmap(void *addr, size_t size); error unmap(void *addr, size_t size);
} // mm:: } // xmm::
// io::ioutil:: // io::ioutil::
...@@ -157,8 +157,8 @@ tuple<uint64_t, error> parseUint(const string& s); ...@@ -157,8 +157,8 @@ tuple<uint64_t, error> parseUint(const string& s);
} // xstrconv:: } // xstrconv::
// log:: // xlog::
namespace log { namespace xlog {
#define Debugf(format, ...) __Logf(__FILE__, __LINE__, 'D', format, ##__VA_ARGS__) #define Debugf(format, ...) __Logf(__FILE__, __LINE__, 'D', format, ##__VA_ARGS__)
#define Infof(format, ...) __Logf(__FILE__, __LINE__, 'I', format, ##__VA_ARGS__) #define Infof(format, ...) __Logf(__FILE__, __LINE__, 'I', format, ##__VA_ARGS__)
...@@ -167,9 +167,9 @@ namespace log { ...@@ -167,9 +167,9 @@ namespace log {
#define Fatalf(format, ...) __Logf(__FILE__, __LINE__, 'F', format, ##__VA_ARGS__) #define Fatalf(format, ...) __Logf(__FILE__, __LINE__, 'F', format, ##__VA_ARGS__)
void __Logf(const char *file, int line, char level, const char *format, ...); void __Logf(const char *file, int line, char level, const char *format, ...);
} // log:: } // xlog::
} // golang:: } // xgolang::
// zodb:: // zodb::
......
// Copyright (C) 2018-2021 Nexedi SA and Contributors. // Copyright (C) 2018-2022 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -94,7 +94,7 @@ error _WatchLink::close() { ...@@ -94,7 +94,7 @@ error _WatchLink::close() {
errors::Is(err2, ErrLinkDown)) // link shutdown due to logic error; details logged errors::Is(err2, ErrLinkDown)) // link shutdown due to logic error; details logged
err2 = nil; err2 = nil;
error err3 = wlink._f->close(); error err3 = wlink._f->Close();
if (err == nil) if (err == nil)
err = err2; err = err2;
if (err == nil) if (err == nil)
...@@ -115,7 +115,7 @@ void _WatchLink::afterFork() { ...@@ -115,7 +115,7 @@ void _WatchLink::afterFork() {
// _serveRX is not running. Just release the file handle, that fork // _serveRX is not running. Just release the file handle, that fork
// duplicated, to make sure that child cannot send anything to wcfs and // duplicated, to make sure that child cannot send anything to wcfs and
// interfere into parent-wcfs exchange. // interfere into parent-wcfs exchange.
wlink._f->close(); // ignore err wlink._f->Close(); // ignore err
} }
// closeWrite closes send half of the link. // closeWrite closes send half of the link.
...@@ -386,7 +386,7 @@ error _WatchLink::_write(const string &pkt) { ...@@ -386,7 +386,7 @@ error _WatchLink::_write(const string &pkt) {
int n; int n;
error err; error err;
tie(n, err) = wlink._f->write(pkt.c_str(), pkt.size()); tie(n, err) = wlink._f->Write(pkt.c_str(), pkt.size());
return err; return err;
} }
...@@ -454,7 +454,7 @@ tuple<string, error> _WatchLink::_readline() { ...@@ -454,7 +454,7 @@ tuple<string, error> _WatchLink::_readline() {
int n; int n;
error err; error err;
tie(n, err) = wlink._f->read(buf, sizeof(buf)); tie(n, err) = wlink._f->Read(buf, sizeof(buf));
if (n > 0) { if (n > 0) {
wlink._rxbuf += string(buf, n); wlink._rxbuf += string(buf, n);
continue; continue;
...@@ -515,12 +515,12 @@ void _WatchLink::decref() { ...@@ -515,12 +515,12 @@ void _WatchLink::decref() {
string _WatchLink::String() const { string _WatchLink::String() const {
const _WatchLink& wlink = *this; const _WatchLink& wlink = *this;
// XXX don't include wcfs as prefix here? (see Conn.String for details) // XXX don't include wcfs as prefix here? (see Conn.String for details)
return fmt::sprintf("%s: wlink%d", v(wlink._wc), wlink._f->fd()); return fmt::sprintf("%s: wlink%d", v(wlink._wc), wlink._f->_sysfd());
} }
int _WatchLink::fd() const { int _WatchLink::fd() const {
const _WatchLink& wlink = *this; const _WatchLink& wlink = *this;
return wlink._f->fd(); return wlink._f->_sysfd();
} }
// _nextReqID returns stream ID for next client-originating request to be made. // _nextReqID returns stream ID for next client-originating request to be made.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment