Changeset 886
- Timestamp:
- 08/09/07 11:21:47 (1 year ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/Makefile.am (modified) (2 diffs)
- cherokee/trunk/cherokee/avl.h (modified) (1 diff)
- cherokee/trunk/cherokee/connection_info.c (modified) (3 diffs)
- cherokee/trunk/cherokee/handler_server_info.c (modified) (9 diffs)
- cherokee/trunk/cherokee/handler_server_info.h (modified) (1 diff)
- cherokee/trunk/cherokee/server.c (modified) (2 diffs)
- cherokee/trunk/cherokee/socket.c (modified) (8 diffs)
- cherokee/trunk/cherokee/virtual_server.c (modified) (2 diffs)
- cherokee/trunk/cherokee/virtual_server.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r885 r886 1 2007-08-08 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/connection_info.c (cherokee_connection_info_list_thread): 4 Now, it includes polling connections as well. 5 6 * cherokee/connection_info.c (cherokee_connection_info_fill_up): 7 Bug fixed. It was failing to generate the IP property; the buffer 8 had length after the IP was added. 9 10 * cherokee/handler_server_info.c, cherokee/handler_server_info.h: 11 Added an additional configuration parameter "connection_details" 12 that, when activated, display data about all the connections that 13 the server is currently handling. 14 15 * cherokee/server.c (cherokee_server_del_connection): Integrated 16 with thread->ownership. Now it's safe (but slower) to use this 17 method. 18 19 * cherokee/socket.c (cherokee_socket_init_tls): Fail if the 20 internal initialization function fails. So far, it wasn't checking 21 the returning value. 22 23 * cherokee/virtual_server.h, cherokee/virtual_server.c, 24 cherokee/socket.c: Switched to use the new cherokee_avl_r_t. It 25 was using a avl_t plus a mutex; now it's slightly cleaner (and 26 should be faster as well). 27 28 * cherokee/avl_r.h, cherokee/avl_r.c: Added new class: Thread-safe 29 AVL. It uses cherokee_avl_t underneath. 30 1 31 2007-08-07 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 32 cherokee/trunk/cherokee/Makefile.am
r884 r886 713 713 avl.h \ 714 714 avl.c \ 715 avl_r.h \ 716 avl_r.c \ 715 717 http.h \ 716 718 http.c \ … … 905 907 version.h \ 906 908 avl.h \ 909 avl_r.h \ 907 910 buffer.h\ 908 911 fdpoll.h \ cherokee/trunk/cherokee/avl.h
r852 r886 70 70 CHEROKEE_END_DECLS 71 71 72 #endif /* CHEROKEE_ TABLE_H */72 #endif /* CHEROKEE_AVL_H */ cherokee/trunk/cherokee/connection_info.c
r834 r886 143 143 /* From 144 144 */ 145 if (conn->socket.socket > 0) {145 if (conn->socket.socket >= 0) { 146 146 cherokee_buffer_ensure_size (&info->ip, CHE_INET_ADDRSTRLEN + 1); 147 memset (info->ip.buf, 0, info->ip.size); 147 148 cherokee_socket_ntop (&conn->socket, info->ip.buf, info->ip.size - 1); 149 info->ip.len = strlen(info->ip.buf); 148 150 } 149 151 … … 152 154 if (! cherokee_buffer_is_empty (&conn->request_original)) { 153 155 cherokee_buffer_add_buffer (&info->request, &conn->request_original); 156 157 } else if (! cherokee_buffer_is_empty (&conn->request)) { 158 cherokee_buffer_add_buffer (&info->request, &conn->request); 154 159 } 155 else if (! cherokee_buffer_is_empty (&conn->request)) {156 cherokee_buffer_add_buffer (&info->request, &conn->request);157 }158 160 159 161 /* Transference … … 255 257 cherokee_list_add (LIST(n), list); 256 258 } 259 260 list_for_each (i, &thread->polling_list) { 261 CHEROKEE_NEW(n,connection_info); 262 263 cherokee_connection_info_fill_up (n, CONN(i)); 264 cherokee_list_add (LIST(n), list); 265 } 266 257 267 ret = ret_ok; 258 268 if (cherokee_list_empty (list)) cherokee/trunk/cherokee/handler_server_info.c
r880 r886 36 36 #include "server-protected.h" 37 37 #include "plugin_loader.h" 38 #include "connection_info.h" 39 38 40 39 41 #define PAGE_HEADER \ … … 76 78 77 79 #define LICENSE \ 78 "<p>Copyright (C) 2001 , 2002, 2003, 2004, 2005 " AUTHOR "</p>"CRLF\80 "<p>Copyright (C) 2001 - 2007 " AUTHOR "</p>" CRLF\ 79 81 "<p>This program is free software; you can redistribute it and/or" CRLF\ 80 82 "modify it under the terms of version 2 of the GNU General Public" CRLF\ … … 122 124 cherokee_module_props_init_base (MODULE_PROPS(n), 123 125 MODULE_PROPS_FREE(props_free)); 124 n->just_about = false; 126 n->just_about = false; 127 n->connection_details = false; 128 125 129 *_props = MODULE_PROPS(n); 126 130 } … … 133 137 if (equal_buf_str (&subconf->key, "just_about")) { 134 138 props->just_about = atoi(subconf->val.buf); 139 } else if (equal_buf_str (&subconf->key, "connection_details")) { 140 props->connection_details = atoi(subconf->val.buf); 135 141 } else { 136 142 PRINT_MSG ("ERROR: Handler file: Unknown key: '%s'\n", subconf->key.buf); … … 156 162 { 157 163 cherokee_buffer_add_va (buf, "<tr><td class=\"e\">%s</td><td class=\"v\">%s</td></tr>"CRLF, name, value); 164 } 165 166 static void 167 table_add_row_buf (cherokee_buffer_t *buf, const char *name, cherokee_buffer_t *value) 168 { 169 char *cvalue = (value->len > 0) ? value->buf : ""; 170 table_add_row_str (buf, name, cvalue); 158 171 } 159 172 … … 255 268 { 256 269 cuint_t conns_num = 0; 257 cuint_t active = 0;258 cuint_t reusable = 0;270 cuint_t active = 0; 271 cuint_t reusable = 0; 259 272 260 273 cherokee_server_get_conns_num (srv, &conns_num); … … 341 354 return; 342 355 343 table_add_row_str (buf, "Default icon", (srv->icons->default_icon.len > 0) ? srv->icons->default_icon.buf : ""); 344 table_add_row_str (buf, "Directory icon", (srv->icons->directory_icon.len > 0) ? srv->icons->directory_icon.buf : ""); 345 table_add_row_str (buf, "Parent directory icon", (srv->icons->parentdir_icon.len > 0) ? srv->icons->parentdir_icon.buf : ""); 346 } 356 table_add_row_buf (buf, "Default icon", &srv->icons->default_icon); 357 table_add_row_buf (buf, "Directory icon", &srv->icons->directory_icon); 358 table_add_row_buf (buf, "Parent directory icon", &srv->icons->parentdir_icon); 359 } 360 361 362 static void 363 build_connection_details_content (cherokee_buffer_t *buf, cherokee_list_t *infos) 364 { 365 char tmp[8]; 366 cherokee_list_t *i, *j; 367 368 list_for_each_safe (i, j, infos) { 369 cherokee_connection_info_t *info = CONN_INFO(i); 370 371 table_add_row_buf (buf, "ID", &info->id); 372 table_add_row_buf (buf, "Remote IP", &info->ip); 373 table_add_row_buf (buf, "Phase", &info->phase); 374 table_add_row_buf (buf, "Request", &info->request); 375 table_add_row_buf (buf, "Handler", &info->handler); 376 377 cherokee_strfsize (atoi(info->rx.buf), tmp); 378 table_add_row_str (buf, "Info sent", tmp); 379 380 cherokee_strfsize (atoi(info->tx.buf), tmp); 381 table_add_row_str (buf, "Info received", tmp); 382 383 if (! cherokee_buffer_is_empty (&info->total_size)) { 384 cherokee_strfsize (atoi(info->total_size.buf), tmp); 385 table_add_row_str (buf, "Total Size", tmp); 386 } 387 388 if (! cherokee_buffer_is_empty (&info->percent)) { 389 cherokee_buffer_add_str (&info->percent, "%"); 390 table_add_row_buf (buf, "Percentage", &info->percent); 391 } 392 393 if (! cherokee_buffer_is_empty (&info->icon)) 394 table_add_row_buf (buf, "Icon", &info->icon); 395 396 table_add_row_str (buf, "", ""); 397 cherokee_connection_info_free (info); 398 } 399 } 400 347 401 348 402 static void 349 403 server_info_build_page (cherokee_handler_server_info_t *hdl) 350 404 { 405 ret_t ret; 351 406 cherokee_server_t *srv; 352 407 cherokee_buffer_t *buf; … … 387 442 cherokee_buffer_clean (&table); 388 443 build_modules_table_content (&table, srv); 389 server_info_add_table (buf, " Modules", "modules", &table);444 server_info_add_table (buf, "Loaded Modules", "modules", &table); 390 445 391 446 /* Icons … … 394 449 build_icons_table_content (&table, srv); 395 450 server_info_add_table (buf, "Icons", "icons", &table); 396 397 cherokee_buffer_mrproper (&table); 398 } 451 } 452 453 /* Print all the current connections details 454 */ 455 if (HDL_SRV_INFO_PROPS(hdl)->connection_details) { 456 cherokee_list_t infos; 457 458 INIT_LIST_HEAD (&infos); 459 460 ret = cherokee_connection_info_list_server (&infos, HANDLER_SRV(hdl), HANDLER(hdl)); 461 if (ret == ret_ok) { 462 cherokee_buffer_clean (&table); 463 build_connection_details_content (&table, &infos); 464 server_info_add_table (buf, "Current connections details", "connection_details", &table); 465 } 466 } 467 399 468 400 469 /* Add the page ending 401 470 */ 471 cherokee_buffer_mrproper (&table); 402 472 cherokee_buffer_add_str (buf, PAGE_FOOT); 403 473 cherokee/trunk/cherokee/handler_server_info.h
r597 r886 38 38 cherokee_module_props_t base; 39 39 cherokee_boolean_t just_about; 40 cherokee_boolean_t connection_details; 40 41 } cherokee_handler_server_info_props_t; 41 42 cherokee/trunk/cherokee/server.c
r883 r886 1924 1924 1925 1925 list_for_each (t, &srv->thread_list) { 1926 cherokee_thread_t *thread = THREAD(t); 1927 1928 CHEROKEE_MUTEX_LOCK (&thread->ownership); 1929 1926 1930 list_for_each (c, &THREAD(t)->active_list) { 1927 1931 cherokee_connection_t *conn = CONN(c); … … 1932 1936 { 1933 1937 conn->phase = phase_shutdown; 1938 CHEROKEE_MUTEX_UNLOCK (&thread->ownership); 1934 1939 return ret_ok; 1935 1940 } 1936 1941 } 1937 1942 } 1943 CHEROKEE_MUTEX_UNLOCK (&thread->ownership); 1938 1944 } 1939 1945 cherokee/trunk/cherokee/socket.c
r883 r886 205 205 { 206 206 ret_t ret; 207 cherokee_avl_ t*cache;207 cherokee_avl_r_t *cache; 208 208 cherokee_virtual_server_t *vserver; 209 209 gnutls_datum session; … … 233 233 /* Get (and remove) the object from the session cache 234 234 */ 235 CHEROKEE_MUTEX_LOCK (&vserver->session_cache_mutex); 236 ret = cherokee_avl_get (cache, &strkey, (void **)&session); 237 CHEROKEE_MUTEX_UNLOCK (&vserver->session_cache_mutex); 238 235 ret = cherokee_avl_r_get (cache, &strkey, (void **)&session); 239 236 if (ret == ret_ok) { 240 237 TRACE (ENTRIES",ssl", "fd=%d key=%s - found=%p\n", socket->socket, strkey.buf, session); … … 254 251 { 255 252 ret_t ret; 256 cherokee_avl_ t*cache;253 cherokee_avl_r_t *cache; 257 254 cherokee_virtual_server_t *vserver; 258 255 cherokee_buffer_t faked; … … 282 279 /* Remove the entry 283 280 */ 284 CHEROKEE_MUTEX_LOCK (&vserver->session_cache_mutex); 285 ret = cherokee_avl_del (cache, &strkey, (void **)&n); 286 CHEROKEE_MUTEX_UNLOCK (&vserver->session_cache_mutex); 287 281 ret = cherokee_avl_r_del (cache, &strkey, (void **)&n); 288 282 if ((ret == ret_ok) && (n != NULL)) { 289 283 TRACE (ENTRIES",ssl", "fd=%d key=%s - found=%p ret=%d\n", socket->socket, strkey.buf, n, ret); … … 303 297 { 304 298 ret_t ret; 305 cherokee_avl_ t*cache;299 cherokee_avl_r_t *cache; 306 300 cherokee_virtual_server_t *vserver; 307 301 cherokee_buffer_t faked; 308 cherokee_buffer_t strkey = CHEROKEE_BUF_INIT;302 cherokee_buffer_t strkey = CHEROKEE_BUF_INIT; 309 303 cherokee_socket_t *socket = SOCKET(ptr); 310 304 … … 330 324 /* Add the copy to the table 331 325 */ 332 CHEROKEE_MUTEX_LOCK (&vserver->session_cache_mutex); 333 ret = cherokee_avl_add (cache, &strkey, &data); 334 CHEROKEE_MUTEX_UNLOCK (&vserver->session_cache_mutex); 326 ret = cherokee_avl_r_add (cache, &strkey, &data); 335 327 336 328 TRACE (ENTRIES",ssl", "fd=%d key=%s - added=%p ret=%d\n", socket->socket, strkey.buf, &data, ret); … … 391 383 gnutls_dh_set_prime_bits (socket->session, 1024); 392 384 393 /* Set the session DB manage functions385 /* Set the session DB management functions 394 386 */ 395 387 gnutls_db_set_retrieve_function (socket->session, db_retrieve); … … 440 432 { 441 433 #ifdef HAVE_TLS 442 int re; 434 int re; 435 ret_t ret; 443 436 444 437 socket->is_tls = TLS; 445 438 446 439 if (socket->initialized == false) { 447 initialize_tls_session (socket, vserver); 440 ret = initialize_tls_session (socket, vserver); 441 if (ret != ret_ok) return ret; 442 448 443 socket->initialized = true; 449 444 } cherokee/trunk/cherokee/virtual_server.c
r881 r886 78 78 79 79 #ifdef HAVE_TLS 80 ret = cherokee_avl_ init (&n->session_cache);80 ret = cherokee_avl_r_init (&n->session_cache); 81 81 if (unlikely(ret < ret_ok)) 82 82 return ret; 83 84 CHEROKEE_MUTEX_INIT(&n->session_cache_mutex, NULL);85 83 86 84 # ifdef HAVE_GNUTLS … … 132 130 133 131 #ifdef HAVE_TLS 134 cherokee_avl_mrproper (&vserver->session_cache, NULL); //FIXIT 135 CHEROKEE_MUTEX_DESTROY (&vserver->session_cache_mutex); 132 cherokee_avl_r_mrproper (&vserver->session_cache, NULL); //FIXIT 136 133 137 134 # ifdef HAVE_GNUTLS cherokee/trunk/cherokee/virtual_server.h
r881 r886 39 39 40 40 #include "avl.h" 41 #include "avl_r.h" 41 42 #include "list.h" 42 43 #include "handler.h" … … 81 82 82 83 #ifdef HAVE_TLS 83 cherokee_avl_t session_cache; 84 CHEROKEE_MUTEX_T (session_cache_mutex); 84 cherokee_avl_r_t session_cache; 85 85 86 86 # ifdef HAVE_GNUTLS