Changeset 18097 for trunk/FACT++
- Timestamp:
- 01/29/15 09:05:02 (10 years ago)
- Location:
- trunk/FACT++/dim
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/dim/README_v20.txt
r18058 r18097 1 1 2 DIM version 20r1 1Release Notes2 DIM version 20r13 Release Notes 3 3 4 4 Notes 1 and 2 for Unix Users only … … 17 17 Dns </dev/null >& dns.log & 18 18 19 NOTE 3: The Version Number service provided by servers is now set to 2011. 19 NOTE 3: The Version Number service provided by servers is now set to 2013. 20 21 22/01/2014 22 Changes for version 2013: 23 - Tried to improve in the DNS the handling of many connections at startup 24 (and many applications "simultaneous" restart) 25 26 27 03/12/2014 28 Changes for version 2012: 29 - In Linux the number of connections is now completely dynamic. 30 (replaced select by poll) 31 - Changed the default SEND and RECV buffer sizes per connection from 16Kb to 64Kb 32 (except for the DNS connections: 32 Kb, to limit the memory increase) 33 - Changed the DNS Keepalive timeout from 15 to 20 seconds (to use a little less CPU) 34 20 35 21 36 24/10/2014 -
trunk/FACT++/dim/dim/dim.h
r18058 r18097 14 14 #include "dim_common.h" 15 15 16 #define DIM_VERSION_NUMBER 201 116 #define DIM_VERSION_NUMBER 2013 17 17 18 18 … … 163 163 #define MAX_CONNS 1024 164 164 #define ID_BLOCK 512 165 #define TCP_RCV_BUF_SIZE 16384/*32768*//*65536*/166 #define TCP_SND_BUF_SIZE 16384/*32768*//*65536*/165 #define TCP_RCV_BUF_SIZE /*16384*//*32768*/65536 166 #define TCP_SND_BUF_SIZE /*16384*//*32768*/65536 167 167 #endif 168 168 #define DID_DNS_TMOUT_MIN 5 -
trunk/FACT++/dim/src/dns.c
r18058 r18097 395 395 { 396 396 dim_print_date_time(); 397 printf(" Service %s already declared by conn %d - %s@%s:%d (PID %d), Redeclared by conn %d - %s@%s:%d (PID %d)(same server) - Closing old conn%d\n",397 printf(" Service %s already declared by conn %d - %s@%s:%d (PID %d), Redeclared by conn %d - %s@%s:%d (PID %d)(same server) - Closing both conns %d %d\n", 398 398 servp->serv_name, servp->conn_id, 399 399 Dns_conns[servp->conn_id].task_name, … … 406 406 Dns_conns[conn_id].port, 407 407 Dns_conns[conn_id].pid, 408 servp->conn_id );408 servp->conn_id, conn_id); 409 409 fflush(stdout); 410 410 release_conn(servp->conn_id); 411 release_conn(conn_id); 412 /* 411 413 update_did = 0; 412 /* 414 */ 413 415 return(0); 414 */ 416 415 417 } 416 418 else … … 1079 1081 void service_remove(); 1080 1082 1081 if( Dns_conns[conn_id].src_type == SRC_DIS ) 1083 servp = (DNS_SERVICE *)Dns_conns[conn_id].service_head; 1084 nodep = (NODE *)Dns_conns[conn_id].node_head; 1085 if(( Dns_conns[conn_id].src_type == SRC_DIS ) || (servp)) 1082 1086 { 1083 1087 if( Debug ) … … 1143 1147 dna_close(conn_id); 1144 1148 } 1145 else if( Dns_conns[conn_id].src_type == SRC_DIC)1149 else if((Dns_conns[conn_id].src_type == SRC_DIC) || (nodep)) 1146 1150 { 1147 1151 if(Debug) … … 1435 1439 dim_set_write_timeout(10); 1436 1440 dim_set_listen_backlog(1024); 1441 dim_set_keepalive_timeout(90); 1442 dim_set_write_buffer_size(32768); 1443 dim_set_read_buffer_size(32768); 1437 1444 dim_init(); 1438 1445 conn_arr_create( SRC_DNS ); -
trunk/FACT++/dim/src/tcpip.c
r18058 r18097 14 14 */ 15 15 16 /* Modifies the number of open connections to 8192 for Windows and Linux */17 /* Can not be moved from here ! */18 #include <dim_tcpip.h>19 20 16 #ifdef WIN32 17 #define FD_SETSIZE 16384 18 #define poll(pfd,nfds,timeout) WSAPoll(pfd,nfds,timeout) 21 19 #define ioctl ioctlsocket 22 20 … … 70 68 #endif 71 69 70 #ifdef __linux__ 71 #include <poll.h> 72 #define MY_FD_ZERO(set) 73 #define MY_FD_SET(fd, set) poll_add(fd) 74 #define MY_FD_CLR(fd, set) 75 #define MY_FD_ISSET(fd, set) poll_test(fd) 76 #else 77 #define MY_FD_ZERO(set) FD_ZERO(set) 78 #define MY_FD_SET(fd, set) FD_SET(fd, set) 79 #define MY_FD_CLR(fd, set) FD_CLR(fd, set) 80 #define MY_FD_ISSET(fd, set) FD_ISSET(fd, set) 81 #endif 82 72 83 #include <stdio.h> 73 84 #include <time.h> … … 123 134 { 124 135 ret = get_keepalive_tmout(); 136 Keepalive_timeout_set = ret; 125 137 } 126 138 return(ret); … … 470 482 */ 471 483 484 #ifdef __linux__ 485 static struct pollfd *Pollfds = 0; 486 static int Pollfd_size = 0; 487 488 static int poll_create() 489 { 490 int i; 491 if(Pollfd_size == 0) 492 { 493 Pollfd_size = Curr_N_Conns; 494 Pollfds = malloc(Pollfd_size * sizeof(struct pollfd)); 495 Pollfds[0].fd = -1; 496 for(i = 0; i < Pollfd_size; i++) 497 { 498 Pollfds[i].events = POLLIN; 499 } 500 } 501 else if(Pollfd_size < Curr_N_Conns) 502 { 503 free(Pollfds); 504 Pollfd_size = Curr_N_Conns; 505 Pollfds = malloc(Pollfd_size * sizeof(struct pollfd)); 506 Pollfds[0].fd = -1; 507 for(i = 0; i < Pollfd_size; i++) 508 { 509 Pollfds[i].events = POLLIN; 510 } 511 } 512 return 1; 513 } 514 515 static int poll_add(int fd) 516 { 517 Pollfds[0].fd = fd; 518 return 1; 519 } 520 521 static int poll_test(int fd) 522 { 523 if(Pollfds[0].fd == fd) 524 { 525 if( (Pollfds[0].revents & POLLIN) || (Pollfds[0].revents & POLLHUP) ) 526 { 527 Pollfds[0].revents = 0; 528 return 1; 529 } 530 } 531 return 0; 532 } 533 #endif 534 472 535 static int list_to_fds( fd_set *fds ) 473 536 { … … 475 538 int found = 0; 476 539 540 DISABLE_AST 541 #ifdef __linux__ 542 if(fds) {} 543 poll_create(); 544 #else 477 545 FD_ZERO( fds ) ; 546 #endif 478 547 for( i = 1; i < Curr_N_Conns; i++ ) 479 548 { 549 #ifdef __linux__ 550 Pollfds[i].fd = -1; 551 #endif 480 552 if( Dna_conns[i].busy ) 481 553 { … … 483 555 { 484 556 found = 1; 557 #ifdef __linux__ 558 Pollfds[i].fd = Net_conns[i].channel; 559 #else 485 560 FD_SET( Net_conns[i].channel, fds ); 561 #endif 486 562 487 563 } 488 564 } 489 565 } 566 ENABLE_AST 490 567 return(found); 491 568 } … … 495 572 int i; 496 573 574 #ifdef __linux__ 575 int index = *conn_id; 576 if(fds) {} 577 index++; 578 for( i = index; i < Pollfd_size; i++ ) 579 { 580 if( Dna_conns[i].busy && ( 581 (Pollfds[i].revents & POLLIN) || (Pollfds[i].revents & POLLHUP) ) ) 582 { 583 Pollfds[i].revents = 0; 584 if(Net_conns[i].channel) 585 { 586 *conn_id = i; 587 return 1; 588 } 589 } 590 } 591 return 0; 592 #else 497 593 for( i = 1; i < Curr_N_Conns; i++ ) 498 594 { … … 508 604 } 509 605 return 0; 606 #endif 510 607 } 511 608 … … 724 821 timeout.tv_usec = 0; 725 822 list_to_fds( &rfds ); 823 #ifdef __linux__ 824 selret = poll(Pollfds, Pollfd_size, 0); 825 #else 726 826 selret = select(FD_SETSIZE, &rfds, NULL, NULL, &timeout); 827 #endif 727 828 if(selret > 0) 728 829 { 830 conn_id = 0; 729 831 while( (ret = fds_get_entry( &rfds, &conn_id )) > 0 ) 730 832 { … … 749 851 do_accept( conn_id ); 750 852 } 751 FD_CLR( (unsigned)Net_conns[conn_id].channel, &rfds );853 MY_FD_CLR( (unsigned)Net_conns[conn_id].channel, &rfds ); 752 854 } 753 855 } … … 760 862 * call the right routine to handle the situation. 761 863 */ 762 fd_set rfds, efds, *pfds; 864 fd_set rfds, *pfds; 865 #ifndef __linux__ 866 fd_set efds; 867 #endif 763 868 int conn_id, ret, count; 764 869 #ifndef WIN32 … … 772 877 773 878 list_to_fds( &rfds ); 774 FD_ZERO(&efds);879 MY_FD_ZERO(&efds); 775 880 #ifdef WIN32 776 881 pfds = &efds; … … 778 883 pfds = &rfds; 779 884 #endif 780 FD_SET( DIM_IO_path[0], pfds ); 885 MY_FD_SET( DIM_IO_path[0], pfds ); 886 #ifdef __linux__ 887 ret = poll(Pollfds, Pollfd_size, -1); 888 #else 781 889 ret = select(FD_SETSIZE, &rfds, NULL, &efds, NULL); 890 #endif 891 if(ret <= 0) 892 { 893 printf("poll returned %d, errno %d\n", ret, errno); 894 } 782 895 if(ret > 0) 783 896 { 784 if( FD_ISSET(DIM_IO_path[0], pfds) )897 if(MY_FD_ISSET(DIM_IO_path[0], pfds) ) 785 898 { 786 899 #ifndef WIN32 … … 788 901 DIM_IO_Done = 0; 789 902 #endif 790 FD_CLR( (unsigned)DIM_IO_path[0], pfds );903 MY_FD_CLR( (unsigned)DIM_IO_path[0], pfds ); 791 904 } 792 905 /* … … 794 907 DISABLE_AST 795 908 */ 909 conn_id = 0; 796 910 while( (ret = fds_get_entry( &rfds, &conn_id )) > 0 ) 797 911 { … … 820 934 ENABLE_AST 821 935 } 822 FD_CLR( (unsigned)Net_conns[conn_id].channel, &rfds );936 MY_FD_CLR( (unsigned)Net_conns[conn_id].channel, &rfds ); 823 937 } 824 938 /* … … 1284 1398 Net_conns[conn_id].read_rout( conn_id, -1, 0 ); 1285 1399 */ 1400 dna_report_error(conn_id, 0, 1401 "Writing (blocking) to", DIM_ERROR, DIMTCPWRRTY); 1286 1402 return(0); 1287 1403 } … … 1322 1438 */ 1323 1439 int wrote, ret, selret; 1324 1440 int tcpip_would_block(); 1441 #ifdef __linux__ 1442 struct pollfd pollitem; 1443 #else 1325 1444 struct timeval timeout; 1326 1445 fd_set wfds; 1327 int tcpip_would_block(); 1446 #endif 1328 1447 1329 1448 set_non_blocking(Net_conns[conn_id].channel); … … 1352 1471 if(tcpip_would_block(ret)) 1353 1472 { 1473 #ifdef __linux__ 1474 pollitem.fd = Net_conns[conn_id].channel; 1475 pollitem.events = POLLOUT; 1476 pollitem.revents = 0; 1477 selret = poll(&pollitem, 1, Write_timeout*1000); 1478 #else 1354 1479 timeout.tv_sec = Write_timeout; 1355 1480 timeout.tv_usec = 0; … … 1357 1482 FD_SET( Net_conns[conn_id].channel, &wfds); 1358 1483 selret = select(FD_SETSIZE, NULL, &wfds, NULL, &timeout); 1484 #endif 1359 1485 if(selret > 0) 1360 1486 { … … 1362 1488 if( wrote == -1 ) 1363 1489 { 1364 /* 1365 dna_report_error(conn_id, 0, 1366 "Writing to", DIM_ERROR, DIMTCPWRRTY); 1367 */ 1490 dna_report_error(conn_id, 0, 1491 "Writing to", DIM_ERROR, DIMTCPWRRTY); 1368 1492 return(0); 1369 1493 } … … 1372 1496 else 1373 1497 { 1374 /* 1375 dna_report_error(conn_id, 0, 1376 "Writing (non-blocking) to", DIM_ERROR, DIMTCPWRRTY); 1377 */ 1498 dna_report_error(conn_id, 0, 1499 "Writing (non-blocking) to", DIM_ERROR, DIMTCPWRRTY); 1378 1500 return(0); 1379 1501 }
Note:
See TracChangeset
for help on using the changeset viewer.