X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp_command.c;h=5b84951de532a0f898e8b54850228a38b36bf6b1;hb=2a5ea4b8e8163f827c269241d21d1850164bac8e;hp=5e804ce8279ff32f4387403cc2ba0ecce7c29483;hpb=13316443850a6b60216219c3cab5915d9a28751a;p=pazpar2-moved-to-github.git diff --git a/src/http_command.c b/src/http_command.c index 5e804ce..5b84951 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -41,6 +41,30 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "settings.h" #include "client.h" +#ifdef __LINUX__ +#include +void print_meminfo(WRBUF wrbuf) { + struct mallinfo minfo; + minfo = mallinfo(); + wrbuf_printf(wrbuf, " \n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " %d\n" + " \n", + minfo.arena, minfo.uordblks, minfo.fordblks,minfo.ordblks, minfo.keepcost, minfo.hblks, minfo.hblkhd, minfo.arena + minfo.hblkhd, minfo.uordblks + minfo.hblkhd); + +} +#else +#define print_meminfo(x) +#endif + + // Update this when the protocol changes #define PAZPAR2_PROTOCOL_VERSION "1" @@ -246,7 +270,7 @@ unsigned int make_sessionid(void) unsigned int res; seq++; - if (global_parameters.debug_mode) + if (global_parameters.predictable_sessions) res = seq; else { @@ -339,7 +363,12 @@ static int process_settings(struct session *se, struct http_request *rq, static void cmd_exit(struct http_channel *c) { + char buf[1024]; + struct http_response *rs = c->response; yaz_log(YLOG_WARN, "exit"); + sprintf(buf, HTTP_COMMAND_RESPONSE_PREFIX "OK"); + rs->payload = nmem_strdup(c->nmem, buf); + http_send_response(c); http_close_server(c->server); } @@ -623,8 +652,6 @@ int resultsets_count(void); static void cmd_server_status(struct http_channel *c) { struct http_response *rs = c->response; - http_sessions_t http_sessions = c->http_sessions; - struct http_session *p; int sessions = sessions_count(); int clients = clients_count(); int resultsets = resultsets_count(); @@ -632,8 +659,14 @@ static void cmd_server_status(struct http_channel *c) wrbuf_puts(c->wrbuf, HTTP_COMMAND_RESPONSE_PREFIX "\n"); wrbuf_printf(c->wrbuf, " %u\n", sessions); wrbuf_printf(c->wrbuf, " %u\n", clients); + /* Only works if yaz has been compiled with enabling of this */ wrbuf_printf(c->wrbuf, " %u\n",resultsets); - /* + print_meminfo(c->wrbuf); + +/* TODO add all sessions status */ +/* http_sessions_t http_sessions = c->http_sessions; */ +/* struct http_session *p; */ +/* yaz_mutex_enter(http_sessions->mutex); for (p = http_sessions->session_list; p; p = p->next) { p->activity_counter++; @@ -650,10 +683,10 @@ static void cmd_server_status(struct http_channel *c) wrbuf_puts(c->wrbuf, "\n"); rs->payload = nmem_strdup(c->nmem, wrbuf_cstr(c->wrbuf)); http_send_response(c); + xmalloc_trav(0); } - static void cmd_bytarget(struct http_channel *c) { struct http_response *rs = c->response; @@ -694,11 +727,10 @@ static void cmd_bytarget(struct http_channel *c) if (settings && *settings == '1') { wrbuf_puts(c->wrbuf, "\n"); - wrbuf_puts(c->wrbuf, wrbuf_cstr(ht[i].settings_xml)); + wrbuf_puts(c->wrbuf, ht[i].settings_xml); wrbuf_puts(c->wrbuf, "\n"); } wrbuf_puts(c->wrbuf, ""); - wrbuf_destroy(ht[i].settings_xml); } wrbuf_puts(c->wrbuf, "");