summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
Commit message (Collapse)AuthorAgeFilesLines
* drop explicit check for EWOULDBLOCK if it has the same value as EAGAINDavid Kalnischkies2016-01-261-0/+4
| | | | | | | | | gcc correctly reports that we check for the same value twice, expect that the manpage of read(2) tells us to do it for portability, so to make both sides happy lets add a little #if'ing here. Reported-By: gcc-6 Git-Dch: Ignore
* string_view: Drop constexpr constructor for standard compatibilityJulian Andres Klode2016-01-151-10/+4
| | | | | | | | | | | | | APT::StringView is supposed to be a temporary measure, until support for the standardized string_view is widely available. Introducing additional unstandardized features just makes porting to the standard version harder. The constexpr constructor also won't have any real effect on most systems, as the compiler will happily optimise the strlen() call away for constant strings. Gbp-Dch: ignore
* provide a constexpr char[] overload for APT::StringViewDavid Kalnischkies2016-01-151-4/+10
| | | | | | The commit also adds a few trivial tests Git-Dch: Ignore
* return correct position in APT::StringView::(r)findDavid Kalnischkies2016-01-151-8/+16
| | | | | | | The position returned is supposed to be the position of the character counted from the start of the string, but if we used the substr calling overloads the skipped over prefix wasn't considered. The pos parameter of rfind had also the wrong semantic.
* Store the size of strings in the cacheJulian Andres Klode2016-01-081-2/+9
| | | | | By storing the size of the string in the cache, we can make use of it when comparing the names in the hashtable in pkgCache::FindGrp.
* HashSumValue::Set: Do not provide const char* overloadJulian Andres Klode2016-01-081-6/+3
| | | | | | | Hide the std::string overload instead of providing a const char * one, the old variant was stupid. Gbp-Dch: ignore
* operator==(char*, StringView) use StringView.operator==Julian Andres Klode2016-01-081-1/+1
| | | | | | | | Use the same path for both comparisons, as the operator== path is faster than just calling compare() - it avoids any comparison if the size differs. Gbp-Dch: ignore
* StringView: rfind: pos should be end of substr, not startJulian Andres Klode2016-01-071-1/+1
| | | | Gbp-Dch: ignore
* StringView: pos argument default should be nposJulian Andres Klode2016-01-071-2/+2
| | | | Gbp-Dch: ignore
* StringView::rfind(): Call rfind() instead of find() on substJulian Andres Klode2016-01-071-1/+1
| | | | | Thanks: Niels Thykier for reporting on IRC Gbp-Dch: ignore
* Switch performance critical code to use APT::StringViewJulian Andres Klode2016-01-073-3/+37
| | | | | | This improves performance of the cache generation on my ARM platform (4x Cortex A15) by about 10% to 20% from 2.35-2.50 to 2.1 seconds.
* Introduce internal APT::StringView classJulian Andres Klode2016-01-071-0/+112
| | | | | | | The class APT::StringView implements a drop-in replacement for a subset of C++17 std::string_view() features. It will be dropped at a later point and may not be used in public interfaces.
* CopyFile: Use 64 * 1024 instead of 64000 as buffer sizeJulian Andres Klode2016-01-071-7/+9
| | | | | | | | This is a multiple of the page size and thus results in less page faults, speeding up copying. Also, while we're at at, unify all uses of that size in a constant variable APT_BUFFER_SIZE.
* FileFd: (native) LZ4 supportJulian Andres Klode2016-01-072-1/+162
| | | | | Implement native support for LZ4 compression, using the official lz4 library.
* simple_compressor: Provide some accessors for end and freeJulian Andres Klode2016-01-031-0/+3
| | | | | | This makes code easier to read, and somewhat more correct. Gbp-Dch: ignore
* simple_buffer: Allow buffer size to changeJulian Andres Klode2016-01-031-2/+18
| | | | Gbp-Dch: ignore
* strutl.cc: Add declarations for the compat _ascii() functionsJulian Andres Klode2015-12-291-0/+2
| | | | | | This shuts up gcc Gbp-Dch: ignore
* Turn tolower_ascii() and isspace_ascii() into inline functionsJulian Andres Klode2015-12-292-11/+21
| | | | | | | | | | To preserve compatibility, the new inline functions have _inline as a suffix, and a macro defines the old names to refer to the inline variants. The old functions are still preserved for binary compatibility. Also simplify the implementation of both functions.
* BufferedFileFdPrivate: Make InternalFlush() save against errorsJulian Andres Klode2015-12-281-8/+8
| | | | | | | | | | | Previously, if flush errored inside the loop, data could have already been written to the wrapped descriptor without having been removed from the buffer. Also try to work around EINTR here. A better solution might be to have the individual privates detect an interrupt and return 0 in such a case, instead of relying on errno being untouched in between the syscall and the return from InternalWrite.
* BufferedWriter: flushing: Check for written < size instead of <=Julian Andres Klode2015-12-281-3/+1
| | | | | This avoids some issues with InternalWrite returning 0 because it just cannot write stuff at the moment.
* FileFd: Add a buffered writing modeJulian Andres Klode2015-12-272-0/+153
| | | | | This is somewhat experimental right now, and might not work for everyone, so it is on an opt-in basis.
* FildFd: Introduce a Flush() function and call it from Close()Julian Andres Klode2015-12-272-0/+16
| | | | The flush function can be used for buffered writers.
* FileFdPrivate: Add getter and setter for fieldsJulian Andres Klode2015-12-271-9/+42
| | | | | We will soon implement a buffered writing decorator and we will need to forward attribute changes to those.
* fileutl: simple_buffer: Add write() and full() methodsJulian Andres Klode2015-12-271-0/+11
| | | | | | These can be used to implement write buffering Gbp-Dch: ignore
* fileutl: simple_buffer: Mark accessors as constJulian Andres Klode2015-12-271-2/+3
| | | | | | Suggested by David. Gbp-Dch: ignore
* FileFdPrivate: Extract SimpleBuffer and mark it as hiddenJulian Andres Klode2015-12-271-21/+24
| | | | Gbp-Dch: ignore
* Hex2Digit: Do not use isxdigit()Niels Thykier2015-12-271-4/+9
| | | | | | | We directly check if we are a hex digit in HexDigit, so use that information. [jak@debian.org: Commit message wording]
* Convert most callers of isspace() to isspace_ascii()Julian Andres Klode2015-12-271-2/+2
| | | | | This converts all callers that read machine-generated data, callers that might work with user input are not converted.
* Introduce isspace_ascii() for use by parsersJulian Andres Klode2015-12-272-0/+19
| | | | This is like isspace(), but ignores the current locale.
* Refactor InternalReadLine to not unroll Size == 0 caseJulian Andres Klode2015-12-261-5/+4
| | | | | | There is not much point and this is more readable. Gbp-Dch: ignore
* Change InternalReadLine to always use buffer.read() return valueJulian Andres Klode2015-12-261-12/+8
| | | | | | | | | This is mostly a documentation issue, as the size we want to read is always less than or equal to the size of the buffer, so the return value will be the same as the size argument. Nonetheless, people wondered about it, and it seems clearer to just always use the return value.
* Get rid of memmove() in our read bufferingJulian Andres Klode2015-12-261-76/+57
| | | | | | This further improves our performance, and rred on uncompressed files now spents 78% of its time in writing. Which means that we should really look at buffering those.
* Use a hardcoded buffer size of 4096 to fix performanceJulian Andres Klode2015-12-261-4/+2
| | | | | | | | | | | | | | The code uses memmove() to move parts of the buffer to the front when the buffer is only partially read. By simply reading one page at a time, the maximum size of bytes that must be moved has a hard limit, and performance improves: In one test case, consisting of a 430 MB Contents file, and a 75K PDiff, applying the PDiff previously took about 48 seconds and now completes in 2 seconds. Further speed up can be achieved by buffering writes, they account for about 60% of the run-time now.
* Mark all FileFdPrivate classes as hidden1.1.6Julian Andres Klode2015-12-241-6/+6
| | | | Gbp-Dch: ignore
* fix new[] vs delete mismatch introduced by b3db9d81David Kalnischkies2015-12-231-7/+7
| | | | | | | | And as we are at it lets fix the 'style' issue I introduced with the filefd changes as well. Reported-By: gcc -fsanitize's & cppcheck Git-Dch: Ignore
* use a dynamic buffer for ReadLineDavid Kalnischkies2015-12-231-15/+22
| | | | | | | | | We don't need the buffer that often - only for ReadLine - as it is only occasionally used, so it is actually more efficient to allocate it if needed instead of statically by default. It also allows the caller to influence the buffer size instead of hardcoding it. Git-Dch: Ignore
* implement a buffer system for FileFd::ReadLineDavid Kalnischkies2015-12-231-27/+140
| | | | | | | | | | | | | | | The default implementation of ReadLine was very naive by just reading each character one-by-one. That is kinda okay for libraries implementing compression as they have internal buffers (but still not great), but while working with files directly or via a pipe as there is no buffer there so all those reads are in fact system calls. This commit introduces an internal buffer in the FileFd implementation which is only used by ReadLine. The more low-level Read and all other actions remain unbuffered – they just changed to deal with potential "left-overs" in the buffer correctly. Closes: 808579
* parse xz-compression level from configurationDavid Kalnischkies2015-12-221-2/+28
| | | | | | | If we use the library to compress xz, still try to understand and pick up the arguments we would have used to call xz to figure out which level the user wants us to use instead of defaulting to level 6 (which is the default level of xz).
* follow dpkg and xz and use CRC64 for xz compressionDavid Kalnischkies2015-12-221-1/+1
| | | | | | | | dpkg switched from CRC32 to CRC64 in 777915108d9d36d022dc4fc4151a615fc95e5032 with the message: | This is the default CRC used by the xz command-line tool, align with | it and switch from CRC32 to CRC64. It should provide slightly better | detection against damaged data, at a negligible speed difference.
* shuffle compressor-specific code into private subclassesDavid Kalnischkies2015-12-222-635/+692
| | | | | | | | | | | | | | This isn't implementing any new features, it is "just" moving code around from FileFd methods which decided on each call how to handle the request by including all logic for all possible compressor backends in the method body to a model in which backend-specifics are implemented in a FileFdPrivate subclass. This avoids a big chunk of #ifdef's and should make it a tiny bit more obvious which backend uses which code. The execution of the idea is slightly uglified by the need to preserve ABI and API which causes liberal befriending. Git-Dch: Ignore
* Do not try to read in FileFd::Read() if Size is 0Julian Andres Klode2015-12-191-3/+2
| | | | | | | There's no point trying to read 0 bytes, so let's just not do this and switch to a while loop like in Write(). Gbp-Dch: ignore
* Do nothing in FileFd::Write() if Size is 0Julian Andres Klode2015-12-191-7/+5
| | | | | | | | | | | Turn the do-while loop into while loops, so it simply does nothing if the Size is already 0. This reverts commit c0b271edc2f6d9e5dea5ac82fbc911f0e3adfa7a which introduced a fix for a specific instance of the issue in the CopyFile() function. Closes: #808381
* CopyFile: avoid failing on EOF on some systemsPino Toscano2015-12-191-1/+1
| | | | | | | | | On EOF, ToRead will be 0, which might trigger on some systems (e.g. on the Hurd) an error due to the invalid byte count passed to write(). The whole loop already checks for ToRead != 0, so perform the writing step only when there was actual data read. Closes: #808381
* CopyFile: fix BufSize to a sane valuePino Toscano2015-12-191-2/+2
| | | | | | | | | | | | | | Commit e977b8b9234ac5db32f2f0ad7e183139b988340d tries to make BufSize calculated based on the size of the buffer; the problem is that std::unique_ptr::size() returns a pointer to the data, so sizeof() equals to the size of a pointer (later divided by sizeof(char), which is 1). The result is that the CopyFile copies in chunks of 8 bytes, which is not exactly ideal... As solution, declare BufSize in advance, and use its value to allocate the Buf array. Closes: #808381
* fix typos and docs in GlobalError documentationDavid Kalnischkies2015-12-131-10/+9
| | | | | Reported-By: Manuel A. Fernandez Montecelo <mafm@debian.org> Git-Dch: Ignore
* mmap: Define _DEFAULT_SOURCE instead of _BSD_SOURCEJulian Andres Klode2015-12-111-1/+1
| | | | | | Fixes a warning reported by gcc. Gbp-Dch: ignore
* doc: VerifyFile checks all hashes instead of best onlyDavid Kalnischkies2015-11-291-1/+1
| | | | | | | | The implementation changed in 495b7a615a2d8f485beadf88c6ed298f5bbe50c2 Git-Dch: Ignore Reported-By: Julian Andres Klode <jak@debian.org>
* Revert "Revert "appease adequate with some weak symbols for -private""Julian Andres Klode2015-11-281-0/+2
| | | | This reverts commit 7ac9386cb6e272625490fcf3e8183b45e28bbc43.
* Revert "appease adequate with some weak symbols for -private"Julian Andres Klode2015-11-281-2/+0
| | | | | | This reverts commit 28f24d3dad1844af316337d565ba2ebc11c8ce97. This fails on Ubuntu as they build with -Bsymbolic-functions.
* disable privilege-drop verification by default as fakeroot trips over itDavid Kalnischkies2015-11-281-42/+60
| | | | | | | | | | | | | Dropping privileges is an involved process for code and system alike so ideally we want to verify that all the work wasn't in vain. Stuff designed to sidestep the usual privilege checks like fakeroot (and its many alternatives) have their problem with this through, partly through missing wrapping (#806521), partly as e.g. regaining root from an unprivileged user is in their design. This commit therefore disables most of these checks by default so that apt runs fine again in a fakeroot environment. Closes: 806475