Guide Home
POD Home

Sloop::Constants

DESCRIPTION

This module contains various groups of constants used throughout the Sloop core, but only one of them is useful with the API, :Debug.

 use Sloop::Constants qw(:Debug);

Imports all the constants explained below. They may also be imported individually. These can be OR'd together with the 'debug' parameter to any Sloop::Base derived object, but since this is passed on to created Sloop::Client objects by the server, the best place to set it is via the Sloop::Server constructor. This may be overruled if you define a client_constructor (see Sloop::Server SYNOPSIS). Having different values set on the server and attached clients will result in different outcomes. If you wish to track a particular client you can try setting it on that object, but then not everything indicated here may apply.

They may also be applied via a command line option (-g) to the server process, see the 'options' parameter to Sloop::Server.

They cause the Sloop::Logger object associated with the Base derived object to report various details via the LOG_DEBUG stream. The constants are:

DBG_CONNECTION

When applied to Sloop::Server, this will:

 require Devel::Peek;
 require Test::Memory::Cycle;

If attached to an individual client, or clients as a group via client_constructor, you must use/require these yourself.

This enables a report of the reference count on Sloop::Connection derived objects when their file descriptor has been removed from the server queue. Unless you are aware of a reason otherwise, it should be reported as 1, indicating the object will be properly destroyed -- otherwise it may be leaked. This same check also reports the result of Test::Memory::Cycle::weakened_memory_cycle_ok as a "Circular reference check". This may sometimes be preceded by "Unhandled type: GLOB" which appears to be an issue in Test::Memory::Cycle and not Sloop.

Elsewhere, it will report:

- When a Sloop::Base derived object is created; this will also report the number of currently existing such objects, and the highest number of simultaneously existing objects noted up until now.

- When a file descriptor is added in Sloop::Server::addFD(). At the same time this will check if the same descriptor is already in the server queue, which should never, never happen; if it does while this switch is enabled, the server will croak(). Do NOT use this just for safety, however.

- Pipelined requests.

- When a connection times out (see Sloop::Connection 'timeout').

- When a connection is disconnected from the other end.

DBG_DESTROY

This will report when a Sloop::Base derived object is destroyed by indicating the remaining number of such objects, and the highest number of simultaneously existing objects yet observed.

DBG_INPUT

The will report the number of bytes read in for each low level system call via a Sloop::Connection derived object created by the server. For, e.g., Sloop::Other connections, you will need to set this yourself in the constructor.

DBG_OUTPUT

The will report the number of bytes written out for each low level system call via a Sloop::Connection derived object created by the server. For, e.g., Sloop::Other connections, you will need to set this yourself in the constructor.

DBG_POLL

At the end of each system level epoll(), this will report whether the call timed out, and if not, which connections came back as NEW (just connected), IN (input pending), OUT (output pending), or DONE (disconnected).

It will also report when the server checks connection timeouts (even if there aren't any).

DBG_REQUEST

This will print HTTP request headers as exactly as they are received, before any parsing is done.

DBG_REPLY

This will print HTTP response headers generated by the server before they are sent. It will also report "Reply completed" when the complete reply has actually been transmitted.

DBG_EVERYTHING

This combines all of the above.