summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/python-daemon-2.0.5/daemon/__init__.py
blob: 4731a6ef3d08aca360bdb3f087683b78645403a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-

# daemon/__init__.py
# Part of ‘python-daemon’, an implementation of PEP 3143.
#
# Copyright © 2009–2015 Ben Finney <ben+python@benfinney.id.au>
# Copyright © 2006 Robert Niederreiter
#
# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the Apache License, version 2.0 as published by the
# Apache Software Foundation.
# No warranty expressed or implied. See the file ‘LICENSE.ASF-2’ for details.

""" Library to implement a well-behaved Unix daemon process.

    This library implements the well-behaved daemon specification of
    :pep:`3143`, “Standard daemon process library”.

    A well-behaved Unix daemon process is tricky to get right, but the
    required steps are much the same for every daemon program. A
    `DaemonContext` instance holds the behaviour and configured
    process environment for the program; use the instance as a context
    manager to enter a daemon state.

    Simple example of usage::

        import daemon

        from spam import do_main_program

        with daemon.DaemonContext():
            do_main_program()

    Customisation of the steps to become a daemon is available by
    setting options on the `DaemonContext` instance; see the
    documentation for that class for each option.

    """

from __future__ import (absolute_import, unicode_literals)

from .daemon import DaemonContext


# Local variables:
# coding: utf-8
# mode: python
# End:
# vim: fileencoding=utf-8 filetype=python :
ns and * limitations under the License. */ #include <vlib/vlib.h> #include <vnet/vnet.h> #include <vppinfra/error.h> #include <vnet/classify/vnet_classify.h> /** @file trace_classify.h * Use the vpp classifier to decide whether to trace packets */ /** @brief vnet_is_packet_traced * @param vlib_buffer_t *b - packet to classify * @param int func - 0 => use classifier w/ supplied table index * @param u32 classify_table_index - classifier table index * @return 0 => no trace, 1 => trace, -1 => error */ static inline int vnet_is_packet_traced_inline (vlib_buffer_t * b, u32 classify_table_index, int func) { vnet_classify_main_t *vcm = &vnet_classify_main; vnet_classify_table_t *t; vnet_classify_entry_t *e; u64 hash; /*$$$ add custom classifiers here, if any */ if (func != 0) return -1; /* This will happen... */ if (pool_is_free_index (vcm->tables, classify_table_index)) return -1; /* Get the table */ t = pool_elt_at_index (vcm->tables, classify_table_index); /* Hash the packet */ hash = vnet_classify_hash_packet (t, vlib_buffer_get_current (b)); /* See if there's a matching entry */ e = vnet_classify_find_entry (t, vlib_buffer_get_current (b), hash, 0 /* time = 0, disables hit-counter */ ); /* Hit means trace the packet... */ if (e) { /* Manual hit accounting */ e->hits++; return 1; } /* * Look for a hit in a less-specific table. * Performance hint: for this use-case, don't go there. */ while (1) { /* Most likely, we're done right now */ if (PREDICT_TRUE (t->next_table_index == ~0)) return 0; t = pool_elt_at_index (vcm->tables, t->next_table_index); /* Compute hash for this table */ hash = vnet_classify_hash_packet (t, vlib_buffer_get_current (b)); /* See if there's a matching entry */ e = vnet_classify_find_entry (t, vlib_buffer_get_current (b), hash, 0 /* time = 0, disables hit-counter */ ); if (e) { /* Manual hit accounting */ e->hits++; return 1; } } /* NOTREACHED */ } /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */