637 Commits

Author SHA1 Message Date
Matthieu Gautier
35b83144c6 Do not compress only if the content is small.
We do not need the test "contentLength < COMPRESSOR_BUFFER_SIZE" to know
if we compress the content or not.

This is a non sens, we WANT to compress the content if it is big.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
063e9ba80d Use compressBound function to reserve the right amount of space.
compressBound function give the upper bound of space needed to
reserve to the compression buffer. Use it instead of using a define.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
e27ce444c6 Correctly check that compress gone well before using the result buffer.
We need to check the return code of compress.
Compress may fail for different reason, one being that the compr_buffer
is not large enough.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
3592cd84c6 Do not modify the compr buffer pointer.
The compr pointer points to the allocated memory. We must not modify
it value.
If we advance the pointer by two bytes each time we compress an answer
we will end to write in some random memory and segfault.

Now, we use a std::vector to correctly handle allocation
(and deallocation!) of the memory.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
a27010c247 Correctly change the compression buffer we send.
For ie browser, we need to remove the two first bytes.
If we make our buffer start two bytes after, we also need to reduce the
size of the buffer by two bytes. Else we will read and send two extra
junk bytes.

Fix #15
2017-03-20 10:08:14 +01:00
Matthieu Gautier
0c01ec5bb5 Cleanup a bit kiwix-serve.cpp
- Remove spaces at end of lines
- Remove unused variables.
2017-03-20 10:08:14 +01:00
Matthieu Gautier
a3a0127edb Do not try to discover ctpp2 ourselves.
Kiwixlib now exports ctpp2 link/cflags in its pkg-config file.
So we don't have to check to ctpp2 here.
2017-02-22 12:10:47 +01:00
Matthieu Gautier
ad7d30cc4f Do not link with iconv when cross-compilating to windows.
Ideally we should check if iconv is present to know if ctpp2 has been
build with iconv.
This may be a bit too complex for our present case. As we know our
cross-compilation environment. It is better to remove the use of iconv
everywhere for now.
2017-02-07 12:25:43 +01:00
Emmanuel Engelhart
134f079c3c Improved README r0.1 2017-02-06 20:52:14 +01:00
Matthieu Gautier
4aba306d68 Add missing linking flag for uuid and rt.
Those libraries are used by xapian, so it should be declare there.
But for now, add the link in our compile script as we still want to compile.
2017-02-06 19:03:22 +01:00
Matthieu Gautier
dc6c9d618f Correctly ask link flags to pkg-config.
If we are compiling a static binaries, all dependencies (including indirect
dependencies) must be present on the command line.
To have them, we have to add '--static' option to the pkg-config line.
Meson does this for us, but we must ask it to do it with the 'static'
argument.
2017-01-31 14:45:44 +01:00
Matthieu Gautier
0f6ca21188 Add static linkage argument in meson.build.
Those options were added by the kiwix-build.py script.
But it's better to add them in the meson.build script to allow people
not using kiwix-build to compile static binaries either.
2017-01-31 14:43:25 +01:00
Matthieu Gautier
db7e1e5c8f Do not try to link with ctpp2-st.
ctpp2-st is not a standard name, all other projects use the same base name
for dynamic and static libs.

Debian already patch the lib name in the ctpp2 package.
As we also patch it in kiwix-build, we can ignore ctpp2-st and always
try to link on ctpp2.

This is even necessary as ctpp2-st is not existing at all is those
usecases, so we cannot try to link with ctpp2-st when compiling statically.

We could fix, the ctpp2 lib search to search ctpp2 and ctpp2-st when
compiling statically but it seems to be a lot of work for nothing
as ctpp2-st is not used at all in our usecases.
2017-01-30 18:02:26 +01:00
Matthieu Gautier
e8dc6b0f45 Correctly compare version of meson 2017-01-24 15:41:42 +01:00
Matthieu Gautier
5fe4e9a4ab Delete the macosx directory.
This should have never been there but keep in the kiwix repository.

Fix #7.
2017-01-17 17:42:44 +01:00
Matthieu Gautier
83768b176c Use old find_library to found ctpp2 lib if meson version < 0.31.0.
We need to support as far as possible the meson version installed on
ubuntu 16.04 (LTS).

In meson 0.31.0, the find_library has moved as a method of the compiler.
2017-01-17 17:32:14 +01:00
Matthieu Gautier
2ca63541f2 On Windows, ctpp2 use the iconv libraries.
If we are cross-compiling to windows, we need to also link with the
iconv library.

We do not check for the iconv library existance here. We assume that
if the ctpp2 library is present all its own dependencies are present also.
2017-01-17 10:51:07 +01:00
Matthieu Gautier
5cfbda1219 Force the template specialization for the min function.
'max' is a size_t and 'blob()->size()-pos' is a uint64_t.
Depending of the compiler (version, options, ...) this is a error as
we don't know which template specialization we have to use.
2017-01-17 10:29:04 +01:00
Matthieu Gautier
9aa7e371f7 Fix header include for cross-compilation to Windows.
- On unix, filenames are case sensitive and all include files are lowercase
- When crosscompiling to Windows, we use mingw32 and not msc.
  So we should not try to include "stdint4win.h"
- Windows includes #define interface to struct.
  As we use interface as variable name, we need to undef interface
2017-01-17 10:26:04 +01:00
Matthieu Gautier
1d2a9879cc Merge pull request #9 from legoktm/zlib
meson: Add missing zlib dependency
2017-01-13 11:40:10 +01:00
Matthieu Gautier
25dc9b1d55 Remove kiwix-builder.py script as it as been move in kiwix-build repo.
Also update README.md.
2017-01-10 10:50:58 +01:00
Kunal Mehta
87cb692c6a meson: Add missing zlib dependency 2017-01-06 04:25:30 -08:00
Matthieu Gautier
384d113b6f Compile and install other tools than kiwix-serve. 2017-01-03 11:57:12 +01:00
Matthieu Gautier
9465b764fa Fix resources compilation.
Add missing files and always build them.
2017-01-03 11:57:12 +01:00
Matthieu Gautier
ea915b6410 Meson compile command (ninja) also need a proper environment.
The ninja command may relaunch meson if meson files have changed.
As we need a proper environment (PKG_CONFIG_PATH, PATH) to let meson
configure properly, we also need to pass the environment to ninja.
2017-01-03 11:50:18 +01:00
Matthieu Gautier
9fdbb8b574 Let's meson found the compile_resource.py script.
Add the INSTALL_DIR/bin dir to the path and allow meson to found installed
binaries.
2016-12-23 13:09:24 +01:00
Matthieu Gautier
2b12f2b830 Set the patch paths relative to the script, not the cwd.
This way, we can run the script from everywhere.
2016-12-23 13:08:09 +01:00
Matthieu Gautier
9f36014449 Use the new script compile_resource from kiwix-lib to compile resources.
Now, resources are automatically recompiled at build.
2016-12-23 12:47:15 +01:00
Matthieu Gautier
94058ce811 Add README and other files 2016-12-22 14:30:58 +01:00
Matthieu Gautier
f580a06163 Meson version of kiwix-lib and kiwix-tools are on master now. 2016-12-22 13:49:56 +01:00
Matthieu Gautier
b363dc387b Add installation of missing hpp when compiling/installing pugixml. 2016-12-22 13:49:56 +01:00
Matthieu Gautier
834f52a9ec Temporary change the git_remote for zimlib.
zimlib doesn't use github but gerrit to handle changes.
As this patches to review, there is no meson branche for now.

Use a personal fork for now. As soon as the meson scripts have been
integrated in openzim repository, we should revert this commit.
2016-12-22 13:49:56 +01:00
Matthieu Gautier
6007ca6eff Install in and use the correct libdir; and other compatibility fixes.
Ubuntu on 64 bits install lib in lib/x86_64-linux-gnu and meson correctly
detect this.
Thus it install libs (zimlib, kiwix) in this directory. However we
look for pkgconfig files in $INTALL_DIR/lib64. And so, the lib is not
found.

We could force meson to install in $INSTALL_DIR/lib64 all the time but
it is just better to follow the correct convention on Ubuntu.

Reuse the algorithm used in meson to correctly detect the libprefix,
use it and force all build script (autotools, cmake, meson) to install there.

In the same way, ninja may be called ninja-build depending of the distribution.
Or depending of how meson is installed, we may have to launch meson or meson.py.
So we detect the command to launch to try to be as most as possible portable.
2016-12-22 13:49:56 +01:00
Matthieu Gautier
ab70e1375e Add a script to build all projects and dependencies for kiwix-tools.
This script download and compile all depedencies and subproject for
kiwix-tools.

Ideally it should be as simple as run the script with the install dir as
argument.

This script compile a dynamic or a static build of kiwix-tools (kiwix-serve)

This as been tested on Fedora.
2016-12-22 13:49:56 +01:00
Matthieu Gautier
8871e6c2e3 first version of meson 2016-12-22 13:49:56 +01:00
mhutti1
d326603662 Merge branch 'master' of https://github.com/kiwix/kiwix imported_from_kiwix 2016-10-15 15:33:46 +01:00
Kelson
a53dea6d1e Merge pull request #340 from kiwix/perf_kiwix_serve
Perf kiwix serve
2016-10-10 07:42:02 +01:00
kelson42
37bef7cb63 Script to benchmark kiwix-serve 2016-10-09 21:51:29 +02:00
Matthieu Gautier
dffff7ba57 Do not make unnecessary copy when serving binary content.
Binary content do not need to be modified, so we don't need to copy it.
We can directly serve it from the internal zim (cluster) buffer.

The handle_content function now getArticleObjectByDecodedUrl instead of
getContentByDecodedUrl.

This is to get the mimetype of the article and copy the content only when
needed (getContentByDecodedUrl always copy the content).
Thus, handle_content is a bit more complex as it need to do some
manipulation previously made in getContentByDecodedUrl.

The main change is that if the content is binary, we serve the content
with a callback response who will get the content chunks directly from
the blob buffer.
2016-10-07 18:23:47 +02:00
Matthieu Gautier
d14460a666 Split accessHandlerCallback into several functions.
Instead of having a big callback function doing almost everything to
handle a request, we split the code into several functions.

There are two new helper functions :
 - build_response that create a response object with correct headers set.
 - compress_content who compress the content if necessary.

All the different cases are handle by different functions :
 - handle_suggest
 - handle_skin
 - handle_search
 - handle_random
 - handle_content
 - handle_default

accesHandlerCallback now handle common stuff, delegate to the handle_*
functions everything else.

There is no special optimization made here. Only splitting code.
2016-10-07 18:23:47 +02:00
mhutti1
1a5f21f1b6 Merge branch 'master' of https://github.com/kiwix/kiwix 2016-10-07 16:44:39 +01:00
Kelson
8a08fb147e Merge pull request #339 from kiwix/handle_zim_without_index
Handle zim without index
2016-10-04 08:46:19 +02:00
Kelson
defa768b25 Merge pull request #338 from kiwix/kiwix_server_no_arg
Do not loop infinitely if there is no argument passed to kiwix-serve.
2016-10-04 08:45:12 +02:00
Matthieu Gautier
8a9673191e Do not loop infinitely if there is no argument passed to kiwix-serve.
If there is no argument, optind==argc==1. We must not try to look into argv[1]
but we need to break the loop anyway.
2016-10-03 13:32:59 +02:00
kelson42
cd623ce358 Fix crash with ZIM files without FT indexes 2016-10-02 18:29:49 +02:00
kelson42
2458c22e09 Fix kiwix-mange problem with relative paths 2016-09-04 21:43:26 +02:00
Kelson
96f0fff54d Implement ZIM reader getTags() and getName() 2016-09-04 20:41:10 +02:00
Kelson
4b6ad3508a Merge pull request #275 from kiwix/several_zim_argument
Be able to run kiwix-serve with several zim as arguments.
2016-08-12 21:30:32 +02:00
Matthieu Gautier
44255453db Be able to run kiwix-serve with several zim as arguments. 2016-08-12 17:23:29 +02:00
Kelson
493c8cb95e Merge pull request #274 from kiwix/embedded_zim_support
Add support of embedded ft-index in zim for kiwix-serve and kiwix-search.
2016-08-12 12:35:37 +02:00