-typedef struct
-{
- CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
- /** Base class instance variables */
-#define _(type, name) type name;
- foreach_app_session_field
-#undef _
- /** rx thread index */
- u32 thread_index;
- /** rx buffer */
- u8 *rx_buf;
- /** vpp session index, handle */
- u32 vpp_session_index;
- u64 vpp_session_handle;
- /** Timeout timer handle */
- u32 timer_handle;
- /** Fully-resolved file path */
- u8 *path;
- /** File data, a vector */
- u8 *data;
- /** Current data send offset */
- u32 data_offset;
- /** File cache pool index */
- u32 cache_pool_index;
- /** state machine called from... */
- state_machine_called_from_t called_from;
-} http_session_t;
-
-/** \brief In-memory file data cache entry
- */
-typedef struct
-{
- /** Name of the file */
- u8 *filename;
- /** Contents of the file, as a u8 * vector */
- u8 *data;
- /** Last time the cache entry was used */
- f64 last_used;
- /** Cache LRU links */
- u32 next_index;
- u32 prev_index;
- /** Reference count, so we don't recycle while referenced */
- int inuse;
-} file_data_cache_t;
-
-/** \brief Main data structure
- */
-
-typedef struct
-{
- /** Per thread vector of session pools */
- http_session_t **sessions;
- /** Session pool reader writer lock */
- clib_rwlock_t sessions_lock;
- /** vpp session to http session index map */
- u32 **session_to_http_session;
-
- /** Enable debug messages */
- int debug_level;
-
- /** vpp message/event queue */
- svm_msg_q_t **vpp_queue;
-
- /** Unified file data cache pool */
- file_data_cache_t *cache_pool;
- /** Hash table which maps file name to file data */
- BVT (clib_bihash) name_to_data;
-
- /** Current cache size */
- u64 cache_size;
- /** Max cache size in bytes */
- u64 cache_limit;
- /** Number of cache evictions */
- u64 cache_evictions;
-
- /** Cache LRU listheads */
- u32 first_index;
- u32 last_index;
-
- /** root path to be served */
- u8 *www_root;
-
- /** Server's event queue */
- svm_queue_t *vl_input_queue;
-
- /** API client handle */
- u32 my_client_index;
-
- /** Application index */
- u32 app_index;
-
- /** Process node index for event scheduling */
- u32 node_index;
-
- /** Session cleanup timer wheel */
- tw_timer_wheel_2t_1w_2048sl_t tw;
- clib_spinlock_t tw_lock;
-
- /** Time base, so we can generate browser cache control http spew */
- clib_timebase_t timebase;
-
- /** Number of preallocated fifos, usually 0 */
- u32 prealloc_fifos;
- /** Private segment size, usually 0 */
- u32 private_segment_size;
- /** Size of the allocated rx, tx fifos, roughly 8K or so */
- u32 fifo_size;
- /** The bind URI, defaults to tcp://0.0.0.0/80 */
- u8 *uri;
- vlib_main_t *vlib_main;
-} http_static_server_main_t;
-
-http_static_server_main_t http_static_server_main;
-
-/** \brief Format the called-from enum
- */
-
-static u8 *
-format_state_machine_called_from (u8 * s, va_list * args)
-{
- state_machine_called_from_t cf =
- va_arg (*args, state_machine_called_from_t);
- char *which = "bogus!";
-
- switch (cf)
- {
- case CALLED_FROM_RX:
- which = "from rx";
- break;
- case CALLED_FROM_TX:
- which = "from tx";
- break;
- case CALLED_FROM_TIMER:
- which = "from timer";
- break;
-
- default:
- break;
- }
-
- s = format (s, "%s", which);
- return s;
-}
-
-
-/** \brief Acquire reader lock on the sessions pools
- */
-static void
-http_static_server_sessions_reader_lock (void)
-{
- clib_rwlock_reader_lock (&http_static_server_main.sessions_lock);
-}
-
-/** \brief Drop reader lock on the sessions pools
- */
-static void
-http_static_server_sessions_reader_unlock (void)
-{
- clib_rwlock_reader_unlock (&http_static_server_main.sessions_lock);
-}
-
-/** \brief Acquire writer lock on the sessions pools
- */
-static void
-http_static_server_sessions_writer_lock (void)
-{
- clib_rwlock_writer_lock (&http_static_server_main.sessions_lock);
-}
-
-/** \brief Drop writer lock on the sessions pools
- */
-static void
-http_static_server_sessions_writer_unlock (void)
-{
- clib_rwlock_writer_unlock (&http_static_server_main.sessions_lock);
-}