Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional improvements and bug fixes #56

Merged
merged 1 commit into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/build_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,15 @@ elif [ "X${OPT_IS_FORCE_PUBLISH}" = "Xtrue" ]; then
# FORCE PUBLISH
#
if [ ${IN_SCHEDULE_PROCESS} -ne 1 ]; then
if [ "X${PUBLISH_TAG_NAME}" ! "X" ]; then
echo "[INFO] ${PRGNAME} : specified \"--use-packagecloudio-repo(-usepc)\" option, then forcibly publish"
if [ "X${PUBLISH_TAG_NAME}" != "X" ]; then
echo "[INFO] ${PRGNAME} : specified \"--force-publish(-p)\" option, then forcibly publish"
IS_PUBLISH=1
else
echo "[WARNING] ${PRGNAME} : specified \"--force-publish(-p)\" option, but not find relase tag."
IS_PUBLISH=0
fi
IS_PUBLISH=1
else
echo "[WARNING] ${PRGNAME} : specified \"--use-packagecloudio-repo(-usepc)\" option, but not publish because this process is kicked by scheduler."
echo "[WARNING] ${PRGNAME} : specified \"--force-publish(-p)\" option, but not publish because this process is kicked by scheduler."
IS_PUBLISH=0
fi
else
Expand Down
3 changes: 2 additions & 1 deletion lib/k2harchive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ bool K2HArchive::Load(K2HShm* pShm) const
unsigned char* bySKey;
unsigned char* byAttrs;
unsigned char* byExdata;
for(offset = 0L, byKey = NULL, byVal = NULL, bySKey = NULL, byAttrs = NULL; NULL != (pBinCom = static_cast<PBCOM>(ReadFile(fd, sizeof(BCOM), offset))); offset += scom_total_length(pBinCom->scom), k2harchive_load_init_vals(pBinCom, byKey, byVal, bySKey, byAttrs, byExdata)){
for(offset = 0L, byKey = NULL, byVal = NULL, bySKey = NULL, byAttrs = NULL, byExdata = NULL; NULL != (pBinCom = static_cast<PBCOM>(ReadFile(fd, sizeof(BCOM), offset))); offset += scom_total_length(pBinCom->scom), k2harchive_load_init_vals(pBinCom, byKey, byVal, bySKey, byAttrs, byExdata)){
// check type
if(pBinCom->scom.type < SCOM_TYPE_MIN || SCOM_TYPE_MAX < pBinCom->scom.type){
if(isErrSkip){
Expand Down Expand Up @@ -348,6 +348,7 @@ bool K2HArchive::Load(K2HShm* pShm) const
K2HDAccess daccess(pShm, K2HDAccess::WRITE_ACCESS);
OWVAL_EXDATA exdata;

exdata.valoffset = 0;
memcpy(exdata.byData, byExdata, pBinCom->scom.exdata_length);
if( !daccess.Open(byKey, pBinCom->scom.key_length) ||
!daccess.SetWriteOffset(exdata.valoffset) ||
Expand Down
28 changes: 25 additions & 3 deletions lib/k2hfilemonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ using namespace std;
//---------------------------------------------------------
// Symbols & macros
//---------------------------------------------------------
#define MONITORFILE_BASE "/tmp/.k2h_"
#define MONITORFILE_DIRPATH "/var/lib/antpickax"
#define MONITORFILE_DIRPATH_SUB "/tmp"
#define MONITORFILE_BASE_NAME ".k2h_"

#define OPEN_LOCK_POS 0L
#define INODE_LOCK_POS static_cast<off_t>(sizeof(unsigned char) * sizeof(long))
Expand All @@ -53,17 +55,37 @@ using namespace std;
#define ARR_INODECNT_VALPOS 1
#define ARR_AREACNT_VALPOS 1

//---------------------------------------------------------
// const variables in local
//---------------------------------------------------------
const char _base_prefix[] = MONITORFILE_DIRPATH "/" MONITORFILE_BASE_NAME;
const char _base_prefix_sub[] = MONITORFILE_DIRPATH_SUB "/" MONITORFILE_BASE_NAME;

//---------------------------------------------------------
// Class variable
//---------------------------------------------------------
const char K2HFileMonitor::base_prefix[] = MONITORFILE_BASE;
const char* K2HFileMonitor::base_prefix = NULL;
mode_t K2HFileMonitor::file_umask = 0;

//---------------------------------------------------------
// Constructor / Destructor
//---------------------------------------------------------
K2HFileMonitor::K2HFileMonitor() : bup_shmfile(""), bup_monfile(""), psfmon(NULL), fmfd(-1), bup_inode_cnt(0), bup_area_cnt(0), bup_inode_val(0)
{
if(!K2HFileMonitor::base_prefix){
struct stat st;
if(0 != stat(MONITORFILE_DIRPATH, &st)){
WAN_K2HPRN("%s directory is not existed, then use %s", MONITORFILE_DIRPATH, MONITORFILE_DIRPATH_SUB);
K2HFileMonitor::base_prefix = _base_prefix_sub;
}else{
if(0 == (st.st_mode & S_IFDIR)){
WAN_K2HPRN("%s is not directory, then use %s", MONITORFILE_DIRPATH, MONITORFILE_DIRPATH_SUB);
K2HFileMonitor::base_prefix = _base_prefix_sub;
}else{
K2HFileMonitor::base_prefix = _base_prefix;
}
}
}
}

K2HFileMonitor::~K2HFileMonitor()
Expand Down Expand Up @@ -204,7 +226,7 @@ bool K2HFileMonitor::InitializeFileMonitor(PSFMONWRAP pfmonwrap, bool noupdate)
need_init_size = false;

// open or create file
if(-1 != (fmfd = open(bup_monfile.c_str(), O_RDWR | O_CREAT | O_EXCL | O_FSYNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))){
if(-1 != (fmfd = open(bup_monfile.c_str(), O_RDWR | O_CREAT | O_EXCL | O_SYNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH))){
// created new file

// [NOTE]
Expand Down
4 changes: 2 additions & 2 deletions lib/k2hfilemonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// This class is for checking k2hash file replaced and mmap area expanded.
// The logic for these is check one byte data in temporary file for each
// k2hash file. The temporary file makes this class from k2hash file path
// which has prefix ".k2_" in "/tmp" directory. After prefix for the file
// which has prefix ".k2_" in "/var/lib" directory. After prefix for the file
// is number of 64bit hex string which is made from hashed k2hash file
// full path.
//
Expand Down Expand Up @@ -75,7 +75,7 @@ typedef union share_file_monitor_wrap{
class K2HFileMonitor
{
private:
static const char base_prefix[];
static const char* base_prefix;
static mode_t file_umask; // umask for monitor file

std::string bup_shmfile;
Expand Down
1 change: 1 addition & 0 deletions tests/k2hbench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <errno.h>
#include <stdarg.h>
#include <pthread.h>
#include <libgen.h>

#include <map>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion tests/k2hlinetool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4416,7 +4416,7 @@ static bool ShellCommand(void)
return true;
}

static bool EchoCommand(params_t& params)
static bool EchoCommand(const params_t& params)
{
string strDisp("");
for(size_t cnt = 0; cnt < params.size(); ++cnt){
Expand Down
5 changes: 3 additions & 2 deletions tests/k2htouch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ int CheckParameter(int argc, char **argv)
#define CMASK_BITCNT 8
#define MAX_ELEMENT_CNT 512
#define PAGESIZE 128
#define _K2H_PAGESIZE 128

// minisize attach parameter
#define SMALL_MASK_BITCNT 2
Expand Down Expand Up @@ -304,7 +305,7 @@ bool AttachK2FileMini(K2HShm* k2hash)
bool answer = true ;

if(!k2hash->Attach(argFilename.c_str(), ISREADONLY, ISCREATE, ISTEMPFILE, ISFULLMAPPING ,
SMALL_MASK_BITCNT, SMALL_CMASK_BITCNT, SMALL_MAX_ELEMENT_CNT, PAGESIZE)) {
SMALL_MASK_BITCNT, SMALL_CMASK_BITCNT, SMALL_MAX_ELEMENT_CNT, _K2H_PAGESIZE)) {
cerr << "Attach Failed. k2file is maybe readonly or have not permission." << endl ;
answer = false ;
}
Expand All @@ -318,7 +319,7 @@ bool AttachK2File(K2HShm* k2hash)
// Attach
bool answer = true ;
if(!k2hash->Attach(argFilename.c_str(), ISREADONLY, ISCREATE, ISTEMPFILE, ISFULLMAPPING ,
MASK_BITCNT, CMASK_BITCNT, MAX_ELEMENT_CNT, PAGESIZE)) {
MASK_BITCNT, CMASK_BITCNT, MAX_ELEMENT_CNT, _K2H_PAGESIZE)) {
cerr << "Attach Failed. k2file is maybe readonly or have not permission." << endl ;
exit(EXIT_FAILURE);
}
Expand Down