Ejemplo n.º 1
0
#include "list.h"

#define CLIENT_STACK_SIZE 65536

SSTRL(CRLFCRLF, "\r\n\r\n");
SSTRL(CRLF, "\r\n");
const char CR = '\r';
SSTRL(CONTENT_LENGTH, "\r\nContent-Length: ");
SSTRL(TRANSFER_ENCODING, "\r\nTransfer-Encoding: ");

SSTRL(CONNECTION, "\r\nConnection: ");
SSTRL(CONNECTION_CLOSE, "close");

static struct list* client_chains = NULL;
static struct list* client_heads = NULL;
static struct list free_list = LIST_INITIALIZER(free_list);
uint32_t next_avail_head = 0;
static struct ribs_context *idle_ctx;
static struct hashtable ht_persistent_clients = HASHTABLE_INITIALIZER;

void http_client_free(struct http_client_pool *client_pool, struct http_client_context *cctx) {
    if (cctx->persistent) {
        int fd = RIBS_RESERVED_TO_CONTEXT(cctx)->fd;
        epoll_worker_set_fd_ctx(fd, idle_ctx);
        uint32_t ofs = hashtable_lookup(&ht_persistent_clients, &cctx->key, sizeof(struct http_client_key));
        struct list *head;
        if (0 == ofs) {
            if (list_empty(&free_list)) {
                close(fd);
                return;
            }
Ejemplo n.º 2
0
struct poll_waiter {
    /* Set when the waiter is created. */
    struct list node;           /* Element in global waiters list. */
    int fd;                     /* File descriptor. */
    short int events;           /* Events to wait for (POLLIN, POLLOUT). */
    poll_fd_func *function;     /* Callback function, if any, or null. */
    void *aux;                  /* Argument to callback function. */
    struct backtrace *backtrace; /* Optionally, event that created waiter. */

    /* Set only when poll_block() is called. */
    struct pollfd *pollfd;      /* Pointer to element of the pollfds array
                                   (null if added from a callback). */
};

/* All active poll waiters. */
static struct list waiters = LIST_INITIALIZER(&waiters);

/* Number of elements in the waiters list. */
static size_t n_waiters;

/* Max time to wait in next call to poll_block(), in milliseconds, or -1 to
 * wait forever. */
static int timeout = -1;

/* Backtrace of 'timeout''s registration, if debugging is enabled. */
static struct backtrace timeout_backtrace;

/* Callback currently running, to allow verifying that poll_cancel() is not
 * being called on a running callback. */
#ifndef NDEBUG
static struct poll_waiter *running_cb;
Ejemplo n.º 3
0
        },
        .tx_free_thresh = 0,
        .tx_rs_thresh = 0,
};

enum { MAX_RX_QUEUE_LEN = 64 };
enum { MAX_TX_QUEUE_LEN = 64 };
enum { DRAIN_TSC = 200000ULL };

static int rte_eal_init_ret = ENODEV;

static struct ovs_mutex dpdk_mutex = OVS_MUTEX_INITIALIZER;

/* Contains all 'struct dpdk_dev's. */
static struct list dpdk_list OVS_GUARDED_BY(dpdk_mutex)
    = LIST_INITIALIZER(&dpdk_list);

static struct list dpdk_mp_list OVS_GUARDED_BY(dpdk_mutex)
    = LIST_INITIALIZER(&dpdk_mp_list);

static pthread_t watchdog_thread;

struct dpdk_mp {
    struct rte_mempool *mp;
    int mtu;
    int socket_id;
    int refcount;
    struct list list_node OVS_GUARDED_BY(dpdk_mutex);
};

struct dpdk_tx_queue {
Ejemplo n.º 4
0
    uint32_t port_no;  /* lag port ifindex, started from LAG_PORT_NUM_START. */
    uint32_t pvid;
    unsigned long *trunks;  /* Bitmap of trunked VLANs. */
    bool state;  /* True if lag is up. */
    uint32_t mtu;
    ctype_xxxx_cosq_schedule_mode_t mode;  /* Qos data. */
    int32_t weights[XXXX_QOS_QUEUES];      /* Qos data. */

    struct ovs_mutex mutex;       /* Protects members below. */
    struct netdev_xxxx_lag *dev;  /* NULL if port is not created. */
};

// All lags of both chipset and openflow support. lags is all lag, all_lags is
// all lags we have added.
static struct xxxx_lag lags[MAX_LAG_NUM];
static struct list all_lags = LIST_INITIALIZER(&all_lags);

// This is for select group lag.
struct select_group_lag {
    uint32_t lag_id;
    bool used;
    uint16_t *members;
    uint32_t members_count;
    uint32_t select_group_id;
};
#define MAX_SELECT_GROUP_LAG (MAX_LAG_NUM - MAX_USER_CONFIG_LAG)
static struct select_group_lag select_group_lags[MAX_LAG_NUM]; //MAX_SELECT_GROUP_LAG
static int xxxx_set_lag_balancing_strategy(uint32_t lag_no,
            ctype_lag_psc_t hash_mapping);

int
Ejemplo n.º 5
0
struct process {
    struct list node;
    char *name;
    pid_t pid;

    /* Modified by signal handler. */
    volatile bool exited;
    volatile int status;
};

/* Pipe used to signal child termination. */
static int fds[2];

/* All processes. */
static struct list all_processes = LIST_INITIALIZER(&all_processes);

static bool sigchld_is_blocked(void);
static void block_sigchld(sigset_t *);
static void unblock_sigchld(const sigset_t *);
static void sigchld_handler(int signr OVS_UNUSED);
static bool is_member(int x, const int *array, size_t);

/* Initializes the process subsystem (if it is not already initialized).  Calls
 * exit() if initialization fails.
 *
 * Calling this function is optional; it will be called automatically by
 * process_start() if necessary.  Calling it explicitly allows the client to
 * prevent the process from exiting at an unexpected time. */
void
process_init(void)
Ejemplo n.º 6
0
#error 8254 timer requires TIMER_FREQ >= 19
#endif
#if TIMER_FREQ > 1000
#error TIMER_FREQ <= 1000 recommended
#endif

/* Number of timer ticks since OS booted. */
static int64_t ticks;

/* Number of loops per timer tick.
   Initialized by timer_calibrate(). */
static unsigned loops_per_tick;

/*  Initialize a wait_list for waiting threads 
*/
static struct list wait_list = LIST_INITIALIZER (wait_list);

static intr_handler_func timer_interrupt;
static bool too_many_loops (unsigned loops);
static void busy_wait (int64_t loops);
static void real_time_sleep (int64_t num, int32_t denom);
static void real_time_delay (int64_t num, int32_t denom);

/* Sets up the timer to interrupt TIMER_FREQ times per second,
   and registers the corresponding interrupt. */
void
timer_init (void) 
{
  pit_configure_channel (0, 2, TIMER_FREQ);
  intr_register_ext (0x20, timer_interrupt, "8254 Timer");
}