mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-03 17:29:24 +00:00
Added more errors checks to p2pool_api
This commit is contained in:
parent
5eaf5d1f51
commit
1ad3fdfd46
3 changed files with 88 additions and 29 deletions
27
.github/workflows/test-sync.yml
vendored
27
.github/workflows/test-sync.yml
vendored
|
@ -30,13 +30,16 @@ jobs:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
./p2pool --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --loglevel 6
|
mkdir data
|
||||||
|
./p2pool --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --data-api data --local-api --loglevel 6
|
||||||
|
|
||||||
- name: Archive p2pool.log
|
- name: Archive p2pool.log
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: p2pool_ubuntu.log
|
name: p2pool_ubuntu_data
|
||||||
path: build/p2pool.log
|
path: |
|
||||||
|
build/p2pool.log
|
||||||
|
build/data/
|
||||||
|
|
||||||
sync-test-macos:
|
sync-test-macos:
|
||||||
|
|
||||||
|
@ -62,13 +65,16 @@ jobs:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
./p2pool --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --loglevel 6
|
mkdir data
|
||||||
|
./p2pool --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --data-api data --local-api --loglevel 6
|
||||||
|
|
||||||
- name: Archive p2pool.log
|
- name: Archive p2pool.log
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: p2pool_macos.log
|
name: p2pool_macos_data
|
||||||
path: build/p2pool.log
|
path: |
|
||||||
|
build/p2pool.log
|
||||||
|
build/data/
|
||||||
|
|
||||||
sync-test-windows:
|
sync-test-windows:
|
||||||
|
|
||||||
|
@ -94,10 +100,13 @@ jobs:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
run: |
|
run: |
|
||||||
cd build/Debug
|
cd build/Debug
|
||||||
./p2pool.exe --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --loglevel 6
|
mkdir data
|
||||||
|
./p2pool.exe --host p2pmd.xmrvsbeast.com --zmq-port 18084 --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --no-cache --data-api data --local-api --loglevel 6
|
||||||
|
|
||||||
- name: Archive p2pool.log
|
- name: Archive p2pool.log
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: p2pool_windows.log
|
name: p2pool_windows_data
|
||||||
path: build/Debug/p2pool.log
|
path: |
|
||||||
|
build/Debug/p2pool.log
|
||||||
|
build/Debug/data/
|
||||||
|
|
|
@ -170,59 +170,108 @@ void p2pool_api::on_fs_open(uv_fs_t* req)
|
||||||
buf[0].base = work->buf.data();
|
buf[0].base = work->buf.data();
|
||||||
buf[0].len = static_cast<uint32_t>(work->buf.size());
|
buf[0].len = static_cast<uint32_t>(work->buf.size());
|
||||||
|
|
||||||
const int result = uv_fs_write(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), buf, 1, 0, on_fs_write);
|
int result = uv_fs_write(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), buf, 1, -1, on_fs_write);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
LOGWARN(4, "failed to write to " << work->tmp_name << ", error " << uv_err_name(result));
|
LOGWARN(4, "failed to write to " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
|
||||||
|
result = uv_fs_close(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), on_fs_error_cleanup);
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
delete work;
|
delete work;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p2pool_api::on_fs_write(uv_fs_t* req)
|
void p2pool_api::on_fs_write(uv_fs_t* req)
|
||||||
{
|
{
|
||||||
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
||||||
|
int result = static_cast<int>(req->result);
|
||||||
if (req->result < 0) {
|
|
||||||
LOGWARN(4, "failed to write to " << work->tmp_name << ", error " << uv_err_name(static_cast<int>(req->result)));
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_fs_req_cleanup(req);
|
uv_fs_req_cleanup(req);
|
||||||
|
|
||||||
const int result = uv_fs_close(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), on_fs_close);
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to write to " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
}
|
||||||
|
else if (result && (static_cast<size_t>(result) < work->buf.size())) {
|
||||||
|
work->buf.erase(work->buf.begin(), work->buf.begin() + result);
|
||||||
|
|
||||||
|
uv_buf_t buf[1];
|
||||||
|
buf[0].base = work->buf.data();
|
||||||
|
buf[0].len = static_cast<uint32_t>(work->buf.size());
|
||||||
|
|
||||||
|
result = uv_fs_write(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), buf, 1, -1, on_fs_write);
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to write to " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
|
||||||
|
result = uv_fs_close(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), on_fs_error_cleanup);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(result));
|
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
delete work;
|
delete work;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = uv_fs_close(uv_default_loop_checked(), &work->req, static_cast<uv_file>(work->fd), on_fs_close);
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
delete work;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p2pool_api::on_fs_close(uv_fs_t* req)
|
void p2pool_api::on_fs_close(uv_fs_t* req)
|
||||||
{
|
{
|
||||||
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
||||||
|
int result = static_cast<int>(req->result);
|
||||||
if (req->result < 0) {
|
|
||||||
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(static_cast<int>(req->result)));
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_fs_req_cleanup(req);
|
uv_fs_req_cleanup(req);
|
||||||
|
|
||||||
const int result = uv_fs_rename(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), work->name.c_str(), on_fs_rename);
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to close " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
result = uv_fs_rename(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), work->name.c_str(), on_fs_rename);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
LOGWARN(4, "failed to rename " << work->tmp_name << " to " << work->name << ", error " << uv_err_name(result));
|
LOGWARN(4, "failed to rename " << work->tmp_name << " to " << work->name << ", error " << uv_err_name(result));
|
||||||
|
|
||||||
|
result = uv_fs_unlink(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), on_fs_error_cleanup);
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to delete " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
delete work;
|
delete work;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p2pool_api::on_fs_rename(uv_fs_t* req)
|
void p2pool_api::on_fs_rename(uv_fs_t* req)
|
||||||
{
|
{
|
||||||
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
||||||
|
int result = static_cast<int>(req->result);
|
||||||
|
uv_fs_req_cleanup(req);
|
||||||
|
|
||||||
if (req->result < 0) {
|
if (result < 0) {
|
||||||
LOGWARN(4, "failed to rename " << work->tmp_name << " to " << work->name << ", error " << uv_err_name(static_cast<int>(req->result)));
|
LOGWARN(4, "failed to rename " << work->tmp_name << " to " << work->name << ", error " << uv_err_name(result));
|
||||||
|
|
||||||
|
result = uv_fs_unlink(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), on_fs_error_cleanup);
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to delete " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
delete work;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete work;
|
||||||
|
}
|
||||||
|
|
||||||
|
void p2pool_api::on_fs_error_cleanup(uv_fs_t* req)
|
||||||
|
{
|
||||||
|
DumpFileWork* work = reinterpret_cast<DumpFileWork*>(req->data);
|
||||||
|
int result = static_cast<int>(req->result);
|
||||||
uv_fs_req_cleanup(req);
|
uv_fs_req_cleanup(req);
|
||||||
|
|
||||||
|
if (result < 0) {
|
||||||
|
LOGWARN(4, "failed to cleanup after previous errors " << work->tmp_name << ", error " << uv_err_name(result));
|
||||||
|
}
|
||||||
|
|
||||||
delete work;
|
delete work;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ private:
|
||||||
static void on_fs_write(uv_fs_t* req);
|
static void on_fs_write(uv_fs_t* req);
|
||||||
static void on_fs_close(uv_fs_t* req);
|
static void on_fs_close(uv_fs_t* req);
|
||||||
static void on_fs_rename(uv_fs_t* req);
|
static void on_fs_rename(uv_fs_t* req);
|
||||||
|
static void on_fs_error_cleanup(uv_fs_t* req);
|
||||||
|
|
||||||
std::string m_apiPath;
|
std::string m_apiPath;
|
||||||
std::string m_networkPath;
|
std::string m_networkPath;
|
||||||
|
|
Loading…
Reference in a new issue