Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Lachu:SystemServices
Lachu-PackageKit
0023-Remove-some-problems-related-to-file-descr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0023-Remove-some-problems-related-to-file-descriptions-ca.patch of Package Lachu-PackageKit
From 8e1112bcc0b7c78fa14f5e36832ce2a2ec696aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl> Date: Sat, 20 Feb 2021 12:58:40 +0100 Subject: [PATCH 23/46] - Remove some problems related to file descriptions (case, where it's not closed or closed, but should not) - Remove possible case of high CPU usage --- backends/zypp/pk-backend-zypp.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp index e531c2932..36625cd25 100644 --- a/backends/zypp/pk-backend-zypp.cpp +++ b/backends/zypp/pk-backend-zypp.cpp @@ -1621,7 +1621,6 @@ static char *get_record(int fd, char *buffer) if (!done && 0 > count) { free(buffer); - close(fd); return NULL; } @@ -1772,19 +1771,18 @@ load_transaction_from_history(const char *type, const char *file, struct backend buffer = NULL; } - + close(fd); return TRUE; } -static void save_package_list(int fd, std::list<std::string>::iterator curr_pkg, std::list<std::string>::iterator end_pkg_list) +static gboolean save_package_list(int fd, std::list<std::string>::iterator curr_pkg, std::list<std::string>::iterator end_pkg_list) { while (curr_pkg != end_pkg_list) { if (strlen((*curr_pkg).c_str()) > write(fd, (*curr_pkg).c_str(), strlen((*curr_pkg).c_str()) + 1)) { - close(fd); - return; + return false; } ++curr_pkg; } @@ -1793,9 +1791,10 @@ static void save_package_list(int fd, std::list<std::string>::iterator curr_pkg, if (strlen("") > write(fd, "", 1)) { - close(fd); - return; + return false; } + + return true; } static void save_transaction_to_cache(const char *type, const char *file, struct msg_proc_helper *helper, @@ -1828,12 +1827,20 @@ static void save_transaction_to_cache(const char *type, const char *file, struct curr_pkg = to_install.begin(); end_pkg_list = to_install.end(); - save_package_list(fd, curr_pkg, end_pkg_list); + if (!save_package_list(fd, curr_pkg, end_pkg_list)) { + + close(fd); + return; + } curr_pkg = to_remove.begin(); end_pkg_list = to_remove.end(); - save_package_list(fd, curr_pkg, end_pkg_list); + if (!save_package_list(fd, curr_pkg, end_pkg_list)) { + + close(fd); + return; + } std::list<struct problem>::iterator curr_problem, end_of_problems; @@ -1914,7 +1921,7 @@ static char return NULL; } - while ((count = read(fd, &info->buffer[info->loaded], info->buff_len - 1 - info->loaded)) > 0 || (errno == EAGAIN && info->loaded < info->curr_old)) { + while ((count = read(fd, &info->buffer[info->loaded], info->buff_len - 1 - info->loaded)) > 0 || (((errno == EAGAIN) && (info->loaded < info->curr_old) && sleep(1))) { curr = info->loaded; info->loaded += count; @@ -2549,7 +2556,7 @@ zypp_perform_execution (PkBackendJob *job, ZYpp::Ptr zypp, PerformType type, gbo add_resolution_to_zypp(rjob->msg_proc_helper); apply_resoultion_from_cache(rjob, &rjob->msg_proc_helper->problems); // FIXME: Remove cache even if it shold be persist -#if 0 +#if 1 if (!pk_bitfield_contain (transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE)) { unlink(rjob->msg_proc_helper->path_to_cache); -- 2.32.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor