Type: refactor
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I015390b703ef502b8b41efa08bff45e65b5eed83
/** vpp session to http session index map */
u32 **session_to_http_session;
/** 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;
/** vpp message/event queue */
svm_msg_q_t **vpp_queue;
/** \brief Start a session cleanup timer
*/
/** \brief Start a session cleanup timer
*/
static void
http_static_server_session_timer_start (http_session_t * hs)
{
static void
http_static_server_session_timer_start (http_session_t * hs)
{
clib_spinlock_unlock (&http_static_server_main.tw_lock);
}
clib_spinlock_unlock (&http_static_server_main.tw_lock);
}
-/** \brief Clean up an http session
+/** \brief Detach cache entry from session
{
ep = pool_elt_at_index (hsm->cache_pool, hs->cache_pool_index);
ep->inuse--;
{
ep = pool_elt_at_index (hsm->cache_pool, hs->cache_pool_index);
ep->inuse--;
+ if (hsm->debug_level > 1)
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
ep->inuse);
}
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
ep->inuse);
}
+/** \brief clean up a session
+ */
+
static void
http_static_server_session_cleanup (http_session_t * hs)
{
static void
http_static_server_session_cleanup (http_session_t * hs)
{
static_send_data (http_session_t * hs, u8 * data, u32 length, u32 offset)
{
u32 bytes_to_send;
static_send_data (http_session_t * hs, u8 * data, u32 length, u32 offset)
{
u32 bytes_to_send;
+ http_static_server_main_t *hsm = &http_static_server_main;
bytes_to_send = length - offset;
bytes_to_send = length - offset;
/* Made any progress? */
if (actual_transfer <= 0)
{
/* Made any progress? */
if (actual_transfer <= 0)
{
+ if (hsm->debug_level > 0 && bytes_to_send > 0)
clib_warning ("WARNING: still %d bytes to send", bytes_to_send);
return offset;
}
clib_warning ("WARNING: still %d bytes to send", bytes_to_send);
return offset;
}
offset += actual_transfer;
bytes_to_send -= actual_transfer;
offset += actual_transfer;
bytes_to_send -= actual_transfer;
+ if (hsm->debug_level && bytes_to_send > 0)
clib_warning ("WARNING: still %d bytes to send", bytes_to_send);
if (svm_fifo_set_event (hs->tx_fifo))
clib_warning ("WARNING: still %d bytes to send", bytes_to_send);
if (svm_fifo_set_event (hs->tx_fifo))
state_closed (session_t * s, http_session_t * hs,
state_machine_called_from_t cf)
{
state_closed (session_t * s, http_session_t * hs,
state_machine_called_from_t cf)
{
- clib_warning ("http session %d, called from %U",
+ clib_warning ("WARNING: http session %d, called from %U",
hs->session_index, format_state_machine_called_from, cf);
return 0;
}
hs->session_index, format_state_machine_called_from, cf);
return 0;
}
request[i + 2] == 'T' && request[i + 3] == ' ')
goto find_end;
}
request[i + 2] == 'T' && request[i + 3] == ' ')
goto find_end;
}
+ if (hsm->debug_level > 1)
+ clib_warning ("Unknown http method");
+
send_error (hs, "405 Method Not Allowed");
close_session (hs);
return 0;
send_error (hs, "405 Method Not Allowed");
close_session (hs);
return 0;
else
path = format (0, "%s/%s%c", hsm->www_root, request, 0);
else
path = format (0, "%s/%s%c", hsm->www_root, request, 0);
+ if (hsm->debug_level > 0)
clib_warning ("GET '%s'", path);
/* Try to find the file. 2x special cases to find index.html */
clib_warning ("GET '%s'", path);
/* Try to find the file. 2x special cases to find index.html */
format_ip46_address, &endpoint.ip,
endpoint.is_ip4,
print_port ? port_str : (u8 *) "", path);
format_ip46_address, &endpoint.ip,
endpoint.is_ip4,
print_port ? port_str : (u8 *) "", path);
+ if (hsm->debug_level > 0)
clib_warning ("redirect: %s", redirect);
vec_free (port_str);
clib_warning ("redirect: %s", redirect);
vec_free (port_str);
kv.key = (u64) hs->path;
if (BV (clib_bihash_search) (&hsm->name_to_data, &kv, &kv) == 0)
{
kv.key = (u64) hs->path;
if (BV (clib_bihash_search) (&hsm->name_to_data, &kv, &kv) == 0)
{
+ if (hsm->debug_level > 1)
clib_warning ("lookup '%s' returned %lld", kv.key, kv.value);
/* found the data.. */
clib_warning ("lookup '%s' returned %lld", kv.key, kv.value);
/* found the data.. */
lru_update (hsm, dp, vlib_time_now (hsm->vlib_main));
hs->cache_pool_index = dp - hsm->cache_pool;
dp->inuse++;
lru_update (hsm, dp, vlib_time_now (hsm->vlib_main));
hs->cache_pool_index = dp - hsm->cache_pool;
dp->inuse++;
+ if (hsm->debug_level > 1)
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
dp->inuse);
}
else
{
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
dp->inuse);
}
else
{
+ if (hsm->debug_level > 1)
clib_warning ("lookup '%s' failed", kv.key, kv.value);
/* Need to recycle one (or more cache) entries? */
if (hsm->cache_size > hsm->cache_limit)
clib_warning ("lookup '%s' failed", kv.key, kv.value);
/* Need to recycle one (or more cache) entries? */
if (hsm->cache_size > hsm->cache_limit)
/* Which could be in use... */
if (dp->inuse)
{
/* Which could be in use... */
if (dp->inuse)
{
+ if (hsm->debug_level > 1)
clib_warning ("index %d in use refcnt %d",
dp - hsm->cache_pool, dp->inuse);
clib_warning ("index %d in use refcnt %d",
dp - hsm->cache_pool, dp->inuse);
{
clib_warning ("LRU delete '%s' FAILED!", dp->filename);
}
{
clib_warning ("LRU delete '%s' FAILED!", dp->filename);
}
+ else if (hsm->debug_level > 1)
clib_warning ("LRU delete '%s' ok", dp->filename);
lru_remove (hsm, dp);
clib_warning ("LRU delete '%s' ok", dp->filename);
lru_remove (hsm, dp);
hsm->cache_evictions++;
vec_free (dp->filename);
vec_free (dp->data);
hsm->cache_evictions++;
vec_free (dp->filename);
vec_free (dp->data);
+ if (hsm->debug_level > 1)
clib_warning ("pool put index %d", dp - hsm->cache_pool);
pool_put (hsm->cache_pool, dp);
if (hsm->cache_size < hsm->cache_limit)
clib_warning ("pool put index %d", dp - hsm->cache_pool);
pool_put (hsm->cache_pool, dp);
if (hsm->cache_size < hsm->cache_limit)
dp->data = hs->data;
hs->cache_pool_index = dp - hsm->cache_pool;
dp->inuse++;
dp->data = hs->data;
hs->cache_pool_index = dp - hsm->cache_pool;
dp->inuse++;
+ if (hsm->debug_level > 1)
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
dp->inuse);
lru_add (hsm, dp, vlib_time_now (hsm->vlib_main));
kv.key = (u64) vec_dup (hs->path);
kv.value = dp - hsm->cache_pool;
/* Add to the lookup table */
clib_warning ("index %d refcnt now %d", hs->cache_pool_index,
dp->inuse);
lru_add (hsm, dp, vlib_time_now (hsm->vlib_main));
kv.key = (u64) vec_dup (hs->path);
kv.value = dp - hsm->cache_pool;
/* Add to the lookup table */
+ if (hsm->debug_level > 1)
clib_warning ("add '%s' value %lld", kv.key, kv.value);
if (BV (clib_bihash_add_del) (&hsm->name_to_data, &kv,
clib_warning ("add '%s' value %lld", kv.key, kv.value);
if (BV (clib_bihash_add_del) (&hsm->name_to_data, &kv,
+ /* Execute state machine for this session */
do
{
fp = state_funcs[hs->session_state];
do
{
fp = state_funcs[hs->session_state];
+ /* Reset the session expiration timer */
+ http_static_server_session_timer_stop (hs);
+ http_static_server_session_timer_start (hs);
+
http_static_server_sessions_reader_unlock ();
return 0;
}
http_static_server_sessions_reader_unlock ();
return 0;
}
static void
http_static_server_session_cleanup_cb (void *hs_handlep)
{
static void
http_static_server_session_cleanup_cb (void *hs_handlep)
{
+ http_static_server_main_t *hsm = &http_static_server_main;
http_session_t *hs;
uword hs_handle;
hs_handle = pointer_to_uword (hs_handlep);
hs =
http_static_server_session_get (hs_handle >> 24, hs_handle & 0x00FFFFFF);
http_session_t *hs;
uword hs_handle;
hs_handle = pointer_to_uword (hs_handlep);
hs =
http_static_server_session_get (hs_handle >> 24, hs_handle & 0x00FFFFFF);
+
+ if (hsm->debug_level > 1)
+ clib_warning ("terminate thread %d index %d hs %llx",
+ hs_handle >> 24, hs_handle & 0x00FFFFFF, hs);
if (!hs)
return;
hs->timer_handle = ~0;
if (!hs)
return;
hs->timer_handle = ~0;
else if (unformat (line_input, "uri %s", &hsm->uri))
;
else if (unformat (line_input, "uri %s", &hsm->uri))
;
+ else if (unformat (line_input, "debug %d", &hsm->debug_level))
+ ;
+ else if (unformat (line_input, "debug"))
+ hsm->debug_level = 1;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
{
.path = "http static server",
.short_help = "http static server www-root <path> [prealloc-fifos <nn>]\n"
{
.path = "http static server",
.short_help = "http static server www-root <path> [prealloc-fifos <nn>]\n"
- "[private-segment-size <nnMG>] [fifo-size <nbytes>] [uri <uri>]\n",
+ "[private-segment-size <nnMG>] [fifo-size <nbytes>] [uri <uri>]\n"
+ "[debug [nn]]\n",
.function = http_static_server_create_command_fn,
};
/* *INDENT-ON* */
.function = http_static_server_create_command_fn,
};
/* *INDENT-ON* */
* @clistart
* show http static server
* @cliend
* @clistart
* show http static server
* @cliend
- * @cliexcmd{show http static server [verbose]}
+ * @cliexcmd{show http static server sessions cache [verbose [nn]]}
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (http_show_static_server_command, static) =
?*/
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (http_show_static_server_command, static) =