- Timestamp:
- Sep 21, 2024, 6:03:27 PM (8 weeks ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/http.c
r104 r118 19 19 #include <winsock2.h> 20 20 #else 21 #ifdef USE_POLL 22 #include <poll.h> 23 #else 21 24 #include <sys/select.h> 25 #endif 22 26 #endif 23 27 … … 46 50 char cbuf[2]; 47 51 int phase = 0; 52 53 #ifdef USE_POLL 54 struct pollfd pollfds[1]; 55 pollfds[0].fd = sock; 56 pollfds[0].events = POLLIN | POLLPRI; 57 #else 48 58 fd_set fds; 59 #endif 49 60 50 61 bool bad = false; … … 64 75 65 76 while(1) { 77 #ifndef USE_POLL 66 78 FD_ZERO(&fds); 67 79 FD_SET(sock, &fds); … … 69 81 tv.tv_sec = 5; 70 82 tv.tv_usec = 0; 83 #endif 71 84 #ifndef NO_SSL 72 85 if(ssl == NULL || !SSL_has_pending(ssl)) { 73 86 #endif 87 #ifdef USE_POLL 88 int n = poll(pollfds, 1, 5000); 89 #else 74 90 #ifdef __HAIKU__ 75 91 int n = select(32, &fds, NULL, NULL, &tv); 76 92 #else 77 93 int n = select(FD_SETSIZE, &fds, NULL, NULL, &tv); 94 #endif 78 95 #endif 79 96 if(n <= 0) { -
trunk/Server/server.c
r117 r118 39 39 #include "strptime.h" 40 40 #else 41 #ifdef USE_POLL 42 #include <poll.h> 43 #else 41 44 #include <sys/select.h> 45 #endif 42 46 #include <sys/socket.h> 43 47 #include <arpa/inet.h> … … 54 58 extern char tw_server[]; 55 59 56 fd_set fdset;57 60 int sockcount = 0; 58 61 … … 802 805 803 806 void tw_server_loop(void) { 804 struct timeval tv;805 807 int i; 806 808 #if defined(__MINGW32__) || defined(__HAIKU__) … … 810 812 } 811 813 #endif 814 #ifdef USE_POLL 815 struct pollfd pollfds[sockcount]; 816 for(i = 0; i < sockcount; i++) { 817 pollfds[i].fd = sockets[i]; 818 pollfds[i].events = POLLIN | POLLPRI; 819 } 820 #else 821 fd_set fdset; 822 struct timeval tv; 823 #endif 812 824 while(1) { 813 FD_ZERO(&fdset); 814 for(i = 0; i < sockcount; i++) { 815 FD_SET(sockets[i], &fdset); 816 } 817 tv.tv_sec = 1; 818 tv.tv_usec = 0; 825 #ifdef USE_POLL 826 int ret = poll(pollfds, sockcount, 1000); 827 #else 828 FD_ZERO(&fdset); 829 for(i = 0; i < sockcount; i++) { 830 FD_SET(sockets[i], &fdset); 831 } 832 tv.tv_sec = 1; 833 tv.tv_usec = 0; 819 834 #ifdef __HAIKU__ 820 int ret = select(32, &fdset, NULL, NULL, &tv);835 int ret = select(32, &fdset, NULL, NULL, &tv); 821 836 #else 822 837 int ret = select(FD_SETSIZE, &fdset, NULL, NULL, &tv); 838 #endif 823 839 #endif 824 840 if(ret == -1) { … … 837 853 int i; 838 854 for(i = 0; i < sockcount; i++) { 839 if(FD_ISSET(sockets[i], &fdset)) { 855 bool cond; 856 #ifdef USE_POLL 857 cond = pollfds[i].revents & POLLIN; 858 #else 859 cond = FD_ISSET(sockets[i], &fdset); 860 #endif 861 if(cond) { 840 862 SOCKADDR claddr; 841 863 int clen = sizeof(claddr); -
trunk/Server/tw_version.h
r70 r118 4 4 #define __TW_VERSION_H__ 5 5 6 #define TW_VERSION "1.0 1\0"6 #define TW_VERSION "1.02\0" 7 7 8 8 const char* tw_get_version(void); -
trunk/config.h.tmpl
r79 r118 5 5 6 6 #undef NO_SSL 7 #define USE_POLL 7 8 8 9 /* DO NOT EDIT BELOW THIS LINE */ … … 12 13 #endif 13 14 15 #if defined(__MINGW32__) && defined(USE_POLL) 16 #undef USE_POLL 17 /* Force select(2) for Windows */ 18 #endif 19 14 20 #endif 15 21
Note:
See TracChangeset
for help on using the changeset viewer.