62 Commits

Author SHA1 Message Date
Unbit be01eacb6e added bigranges sharedarea tests 2015-05-13 15:42:41 +02:00
Roberto De Ioris f514134293 fixed #914 2015-05-12 06:27:42 +02:00
Roberto De Ioris 84374ba4f9 implementation of #904 2015-05-06 09:11:35 +02:00
James Raspass 0389748d4a plugins/psgi - use PL_sv_{yes,no} in env
Use PL_sv_yes & PL_sv_no instead of newSViv(1) & newSViv(0) for bools
as they're interpreter globals that don't need to be created everytime.

Added a test and refactored the tests that were added with a1e30157,
all .t files in t/perl are now ran under all major perl versions with
and without threading when t/perl/run is invoked.

On my box, psgi_plugin.o went from 62,296 bytes to 62,208 bytes. Not a
huge saving I'll grant you, but every little helps :-)
2015-04-17 08:50:05 +01:00
unbit 334baa8050 Merge pull request #886 from funkybob/feature/cleanup
Tidy with flake8
2015-04-13 06:42:03 +02:00
James Raspass a1e3015783 plugins/psgi - remove the need for Scalar::Util
Commit ff9bab4b fixed support for sending IO like handles or GLOBs
via sendfile by first calling fileno on them. This was checked
by calling Scalar::Util::reftype on the reference first, as per
https://metacpan.org/pod/PSGI#Body . This may be sane in pure
perl, but there are better methods in XS/C than string evalling
some Perl, which will eventually also call some XS/C.

This commit introduces more robust checking of whether we have a
"real" filehandle, and also introduces a test that chucks a bunch
of different scalars and references at uWSGI to make sure it doesn't
choke. I wasn't sure how to hook this test up to travis, or wether
that's even desireable, so just left the test in what I believe to
be the right directories.

Because this commit massively simplifies the code, it also had an
effect on object size, on my machine (x64, GCC 4.9), psgi_plugin.o
went from 63360 bytes to 62296 bytes.

The indentation level of the ->getline for loop has been left at
its original level, which is now incorrect, to make the diff
easier to read. A whitespace cleanup commit could follow.

In related news, does anyone know the purpose of the three other
use lines in psgi_loader.c, two of them were added back in 2011
by cf08972e, but I can't work out what their inclusion has to do
with memleak hunting.

Basically I would love to remove these lines as I don't believe
they're needed for uWSGI to function, and if apps running under
uWSGI need them, they should load them themselves.

Also related, would more PSGI refactorings be welcome? I get the
impression that Perl is a bit of a second class citizen in uWSGI
these days, and as both an avid user of uWSGI+PSGI and a hobby XS
developer, I'd love to clean up more of the PSGI plugin.
2015-04-11 23:16:27 +01:00
Curtis 057cfe761f Tidy with flake8 2015-04-11 22:50:11 +10:00
Unbit b60d9822e6 fixed #846 2015-02-19 06:54:01 +01:00
Unbit 14702977a4 added active-workers signal target, aimed at improving #58 2014-11-16 18:48:12 +01:00
Ævar Arnfjörð Bjarmason 1dcdb72054 psgi: Move the destruction of the perl interpreter to the atexit hook + more bugfixes
My previous commit ensured that we called the DESTROY hook but we
wouldn't properly call the atexit hook. Now when you start uWSGI as
instructed in that commit you'll get this:

 * localhost:1234?0:

   $$: Calling DESTROY

 * localhost:1234?1:

   *** psgix.harakiri.commit requested ***
   ...The work of process 523 is done. Seeya!
   523: Calling the atexit hook
   523: Calling DESTROY

 * Ctrl+C (or stop):

   ^CSIGINT/SIGQUIT received...killing workers...
   696: Calling the atexit hook

Before this change we wouldn't call the atexit hook when
psgix.harakiri.commit was requested by calling localhost:1234?1.

To make this work I removed the "if busy do not run atexit hooks"
condition added in 1.4-rc2-246-g499202e. Of course uWSGI is going to
think the worker is "busy", it's busy being destroyed, that doesn't mean
we should skip running the atexit hooks.

We'll still skip them under the "if hijacked do not run atexit hooks"
condition added in that commit, and the "managing atexit in async mode
is a real pain" condition added in 1.0.1-289-gd7e8523. Maybe those are
further bugs that need to be solved, but I don't know how to test those
modes.

Now we'll also call PERL_SET_CONTEXT() and PERL_SYS_TERM() appropriately
during destruction. Note that the latter should only be called once even
if you have multiple interpreters.
2014-11-11 13:09:05 +00:00
Ævar Arnfjörð Bjarmason 7ef33950c5 psgi: Ensure that we call any DESTROY hooks on psgix.harakiri.commit
Before this we'd just exit(0) and let the OS clean up after us, but
e.g. with post-buffering=1 we'll end up with a temporary file in /tmp
that we won't clean up when we exit unless DESTROY is called.

This resulted in us leaking files in /tmp if we ever had a request where
the last request before a harakiri was a POST request with a body we'd
buffer to /tmp.

We'd have similar leaks in any user-defined code that required DESTROY
to run.

Aside from this I'm still not very comfortable with what this whole code
here in psgi_plugin.c and psgi_loader.c is doing when managing the
interpreter(s). It:

 * Doesn't consistently call PERL_SET_CONTEXT() as described in "perldoc
   perlembed".

 * Nothing calls PERL_SYS_TERM() either.

 * Should we be calling uwsgi_perl_free_stashes() here too?

To test this:

    UWSGI_PROFILE=psgi python uwsgiconfig.py --build
    ./uwsgi --master --http-socket localhost:1234 --psgi t/perl/test_harakiri.psgi

Then elsewhere:

    curl 'localhost:1234?0'
    curl 'localhost:1234?1'

Both of those should emit "Calling DESTROY".
2014-11-10 18:57:52 +00:00
Yury Khalyavin fe68884ea4 Fix invalid 'args' and 'kwargs' decoding in python3
When we set pass_arguments=True, we should unpickle
'args' and 'kwargs' first.

Without it '_decode_from_spooler' will fail on 'decoding' their
packed by pickle data, because pickled data has 'bytes' type.
2014-10-30 18:00:56 +03:00
Aldur a89e8d2b53 add manage_script_name tests 2014-10-24 14:17:10 +02:00
Unbit 794ae0018d truly fixed #726 2014-09-23 12:14:23 +02:00
Unbit 9aab77bcc3 attempt to merge #726 2014-09-23 12:07:15 +02:00
Aldur ee01a0f763 add spooler_decorator tests 2014-09-23 11:44:56 +02:00
Aldur d8fb5a9a3b reorganize spooler_priority tests 2014-09-23 11:44:09 +02:00
Aldur 2e565a502e Improve spooled test 2014-09-16 16:25:35 +02:00
Unbit 80f2e5d20f try to address kevent issue with spooler 2014-09-16 15:32:21 +02:00
Aldur 1da300a71b add test regarding spooler and related task priority 2014-09-16 15:03:48 +02:00
Unbit 6b9ce2d755 added test for lru cache purge and fix for lru removal 2014-05-27 11:38:57 +02:00
Ævar Arnfjörð Bjarmason 0f742a72bf t/perl/hello_benchmark.pl: silly benchmark for CPU count + thunder lock
This is to test how the number of processes and using thunder-lock or
not affects response times.
2014-05-01 01:19:35 +02:00
Ævar Arnfjörð Bjarmason fd96a02576 t/perl/test_sleepy.psgi: perl test file that sleeps a bit
This is to test non-CPU bound servers that are waiting on
something (e.g. a database), expecting that we can have a lot more than
num CPU cores of these and not see performance degration.
2014-05-01 01:19:30 +02:00
Ævar Arnfjörð Bjarmason 9ea8f4f07c t/perl/test_hello.psgi: perl test file that does nothing but hello, world
To test a bare-minimal Perl program that does almost nothing at all.
2014-04-30 17:59:41 +00:00
Bruno Deferrari f8a271a027 Add a basic test app for the lua plugin 2014-04-24 21:27:16 -03:00
unbit 930f71c562 Merge pull request #571 from avar/avar/fix-2.0.1-perl-refactoring-regression
perl: fix one-off error in 2.0-103-gf041d10 causing warnings in e.g. Pla...
2014-03-16 05:53:54 +01:00
Ævar Arnfjörð Bjarmason 13d8505738 perl: fix one-off error in 2.0-103-gf041d10 causing warnings in e.g. Plack::Request
This newly added support for read() offsets started causing "Use of
uninitialized value in subroutine entry" warnings.

This is all because there was a test for the number of items on the
stack, which ignored that the first argument is always the object, so 3
arguments to read() actually yields 4 arguments on the stack, not 3.

As a result we'd be calling SvIV() on a stack item that wasn't actually
passed in.
2014-03-15 21:05:18 +00:00
Ævar Arnfjörð Bjarmason 93fe463ca8 perl: add sanity checks to t/perl/test_input_with_offset.pl 2014-03-15 20:41:54 +00:00
Ævar Arnfjörð Bjarmason 4ded485a8e perl: add a trivial streaming test program
This came out of working on this debugging session:
https://github.com/unbit/uwsgi/issues/567
2014-03-15 14:10:20 +00:00
Ævar Arnfjörð Bjarmason 97809192c8 perl: fix a regression with caller() not indicating the starting *.psgi program
In 2.0.1-41-g3480c30 I introduced a regression with how the top-level
stackframe would appear within Perl programs. Before we'd show the
filename of the *.psgi file, but after we just showed "-e".

We can retain the bugfix I added in 2.0.1-41-g3480c30 while having a
sensible stacktrace by overriding the file via the #line directive.
2014-03-15 13:10:30 +00:00
Ævar Arnfjörð Bjarmason 3480c30674 perl: Don't run BEGIN blocks twice in the provided *.psgi
The psgi loaded was calling perl_parse() with the script ostensibly to
set up xsinit.

However it would also call perl_parse() with the path to our *.psgi
file, whith the result that any BEGIN block in the *.psgi file would be
run twice, but anything outside BEGIN blocks would only run once.

This means that any code within explicit BEGIN blocks will run twice,
and any "use" statement in the *.psgi file will run its import() routine
twice, but due to the module being in %INC already we won't actually
compile things twice.

The previous behavior dates all the way back to the initial introduction
of the PSGI plugin in 299fd9c.

Then when support for local::lib was added in 7cbe751 we initially did a
perl_eval_pv() of a "use" statement like I'm doing here again now, but
later on in 1561dd3 changed it to call perl_parse with the commit
message "another PSGI loading fix".

Since there's no info on what that fixed or what was broken before I
have no idea if I'm introducing a regression here, but I don't see why
this way of loding local::lib shouldn't work, and it correctly munges
@INC for me when I try it.

We may still have this bug in the remaining perl_parse() calls that
remain for supporting "preinit" and "mule".

I haven't tested those modes (I don't use them), but when we load the
Perl apps we should only perl_parse() once with -e1, and then
perl_eval_pv() to actually load the application. We should not call
perl_parse() on code that we're just about to perl_eval_pv(), or we'll
run into this bug.

To test this just run:

    ./uwsgi --http 127.0.0.1:8080 --psgi ./t/perl/test.psgi

It'll no longer PANIC on the BEGIN block being run twice now, at least
in that simplistic non-"preinit" non-"mule" mode.
2014-02-25 18:07:42 +00:00
Unbit b3020e60f9 fixed long standing bug with caches 2014-02-20 14:19:40 +01:00
Unbit b559354845 more tests for bitmap cache 2014-02-13 06:16:02 +01:00
Unbit 46a2fefb04 added overlap check for cache 2014-02-13 06:06:29 +01:00
Unbit c6c9baa7b5 initial test suite for bitmap cache mode 2014-02-12 18:54:39 +01:00
Unbit 5cd9e64073 positive tests for psgi input 2014-02-05 13:40:52 +01:00
Unbit d878b65401 added first round of tests for psgi input with offset 2014-02-05 12:37:46 +01:00
Unbit 248a22b064 added another optimization for writev and a test for it 2013-12-02 07:01:44 +01:00
Unbit 9da53f5fd4 improved gccgo signal handling and added --timer and --rbtimer commodity options 2013-11-10 06:42:46 +01:00
Unbit 037a1f7f77 fixed #404 2013-11-05 09:43:11 +01:00
Unbit d484acefa4 use buffer protocol in WSGI response 2013-09-30 09:25:25 +02:00
Unbit c5b4564001 added 2 example of continulets 2013-06-06 18:16:01 +02:00
Unbit 275a7fe63f added --go-args 2013-05-11 08:26:02 +02:00
Unbit 946af8b9ee added errorlimiter.ini example config 2013-05-10 15:15:51 +02:00
Unbit 9ec20f2d8f allows cache math from the routing subsystem 2013-05-08 11:00:23 +02:00
Unbit efd14e1c7a added cookie-based authentication test 2013-05-02 09:34:31 +02:00
Unbit 804c369f0d toward programmable webdav, carddav support ensured 2013-04-29 14:42:04 +02:00
Unbit d38e5dec7b added uwsgi::register_rpc to perl 2013-04-22 08:05:20 +02:00
Unbit 3f8e6a8cc8 completed xslt plugin 2013-03-19 17:53:12 +01:00
Unbit fb8c4439c7 the whole ring test suite passes 2013-03-12 11:15:45 +01:00