Changeset 1224
- Timestamp:
- 03/07/08 01:41:17 (7 months ago)
- Files:
-
- 1.8.3/branches/devel/CHANGES.183 (modified) (1 diff)
- 1.8.3/branches/devel/hdrs/lookup.h (modified) (2 diffs)
- 1.8.3/branches/devel/src/bsd.c (modified) (6 diffs)
- 1.8.3/branches/devel/src/info_master.c (modified) (11 diffs)
- 1.8.3/branches/devel/src/info_slave.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/CHANGES.183
r1219 r1224 49 49 * Fixes from 1.8.2p9 50 50 * Compilation fixes on various platforms. [SW] 51 * A repeatingly crashing info_slave won't block login attempts. 51 52 52 53 Version 1.8.3 patchlevel 6 Jan 01, 2008 1.8.3/branches/devel/hdrs/lookup.h
r905 r1224 46 46 extern int info_slave; 47 47 extern time_t info_queue_time; 48 extern bool info_slave_halted; 48 49 49 50 enum is_state { INFO_SLAVE_DOWN, INFO_SLAVE_READY, INFO_SLAVE_PENDING }; … … 52 53 53 54 void init_info_slave(void); 54 void make_info_slave(void);55 55 void query_info_slave(int fd); 56 56 void update_pending_info_slaves(void); 1.8.3/branches/devel/src/bsd.c
r1213 r1224 311 311 static void shovechars(Port_t port, Port_t sslport); 312 312 static int test_connection(int newsock); 313 #ifndef INFO_SLAVE 314 static DESC *new_connection(int oldsock, int *result, int use_ssl); 315 #endif 313 static DESC *new_connection(int oldsock, int *result, bool use_ssl); 316 314 317 315 static void clearstrings(DESC *d); … … 860 858 861 859 static void 860 setup_desc(int sock, bool use_ssl) 861 { 862 DESC *newd; 863 int result; 864 865 if (!(newd = new_connection(sock, &result, use_ssl))) { 866 if (test_connection(result) < 0) 867 return; 868 } else { 869 ndescriptors++; 870 if (newd->descriptor >= maxd) 871 maxd = newd->descriptor + 1; 872 } 873 } 874 875 static void 862 876 shovechars(Port_t port, Port_t sslport __attribute__ ((__unused__))) 863 877 { … … 872 886 int queue_timeout; 873 887 DESC *d, *dnext; 874 #ifndef INFO_SLAVE875 DESC *newd;876 int result;877 #endif878 888 int avail_descriptors; 879 889 #ifdef INFO_SLAVE … … 1060 1070 1061 1071 if (FD_ISSET(sock, &input_set)) { 1062 addr_len = sizeof(addr); 1063 newsock = accept(sock, (struct sockaddr *) &addr, &addr_len); 1064 if (newsock < 0) { 1065 if (test_connection(newsock) < 0) 1066 continue; /* this should _not_ be return. */ 1067 } 1068 ndescriptors++; 1069 query_info_slave(newsock); 1070 if (newsock >= maxd) 1071 maxd = newsock + 1; 1072 if (!info_slave_halted) { 1073 addr_len = sizeof(addr); 1074 newsock = accept(sock, (struct sockaddr *) &addr, &addr_len); 1075 if (newsock < 0) { 1076 if (test_connection(newsock) < 0) 1077 continue; /* this should _not_ be return. */ 1078 } 1079 ndescriptors++; 1080 query_info_slave(newsock); 1081 if (newsock >= maxd) 1082 maxd = newsock + 1; 1083 } else 1084 setup_desc(sock, false); 1072 1085 } 1073 1086 #ifdef HAS_OPENSSL 1074 1087 if (sslsock && FD_ISSET(sslsock, &input_set)) { 1075 addr_len = sizeof(addr); 1076 newsock = accept(sslsock, (struct sockaddr *) &addr, &addr_len); 1077 if (newsock < 0) { 1078 if (test_connection(newsock) < 0) 1079 continue; /* this should _not_ be return. */ 1080 } 1081 ndescriptors++; 1082 query_info_slave(newsock); 1083 if (newsock >= maxd) 1084 maxd = newsock + 1; 1088 if (!info_slave_halted) { 1089 addr_len = sizeof(addr); 1090 newsock = accept(sslsock, (struct sockaddr *) &addr, &addr_len); 1091 if (newsock < 0) { 1092 if (test_connection(newsock) < 0) 1093 continue; /* this should _not_ be return. */ 1094 } 1095 ndescriptors++; 1096 query_info_slave(newsock); 1097 if (newsock >= maxd) 1098 maxd = newsock + 1; 1099 } else 1100 setup_desc(sslsock, true); 1085 1101 } 1086 1102 #endif 1087 1103 #else /* INFO_SLAVE */ 1088 if (FD_ISSET(sock, &input_set)) { 1089 if (!(newd = new_connection(sock, &result, 0))) { 1090 if (test_connection(result) < 0) 1091 continue; /* this should _not_ be return. */ 1092 } else { 1093 ndescriptors++; 1094 if (newd->descriptor >= maxd) 1095 maxd = newd->descriptor + 1; 1096 } 1097 } 1104 if (FD_ISSET(sock, &input_set)) 1105 setup_desc(sock, false); 1098 1106 #ifdef HAS_OPENSSL 1099 if (sslsock && FD_ISSET(sslsock, &input_set)) { 1100 if (!(newd = new_connection(sslsock, &result, 1))) { 1101 if (test_connection(result) < 0) 1102 continue; /* this should _not_ be return. */ 1103 } else { 1104 ndescriptors++; 1105 if (newd->descriptor >= maxd) 1106 maxd = newd->descriptor + 1; 1107 } 1108 } 1107 if (sslsock && FD_ISSET(sslsock, &input_set)) 1108 setup_desc(sslsock, true); 1109 1109 #endif 1110 1110 #endif … … 1148 1148 } 1149 1149 1150 1151 #ifndef INFO_SLAVE1152 1150 static DESC * 1153 new_connection(int oldsock, int *result, intuse_ssl)1151 new_connection(int oldsock, int *result, bool use_ssl) 1154 1152 { 1155 1153 int newsock; … … 1208 1206 return initializesock(newsock, tbuf1, tbuf2, use_ssl); 1209 1207 } 1210 #endif1211 1208 1212 1209 static void 1.8.3/branches/devel/src/info_master.c
r1223 r1224 53 53 #endif 54 54 55 static bool make_info_slave(void); 56 55 57 static fd_set info_pending; /**< Keep track of fds pending a slave lookup */ 56 58 static int pending_max = 0; … … 60 62 time_t info_queue_time; /**< Time of last write to slave */ 61 63 64 static int startup_attempts = 0; /**< How many times has info_slave been started? */ 65 static time_t startup_window; 66 #define MAX_ATTEMPTS 5 /**< Error out after this many startup attempts in 60 seconds */ 67 68 bool info_slave_halted = false; 62 69 63 70 /* From bsd.c */ … … 72 79 int newsock; 73 80 74 now = time(NULL);81 time(&now); 75 82 76 83 if (info_slave_state == INFO_SLAVE_PENDING && now > info_queue_time + 30) { … … 90 97 } 91 98 92 void 99 bool 93 100 make_info_slave(void) 94 101 { … … 102 109 info_slave_state = INFO_SLAVE_DOWN; 103 110 } 111 112 if (startup_attempts == 0) 113 time(&startup_window); 114 115 startup_attempts += 1; 116 117 if (startup_attempts > MAX_ATTEMPTS) { 118 time_t now; 119 120 time(&now); 121 if (difftime(now, startup_window) <= 60.0) { 122 /* Too many failed attempts to start info_slave in 1 minute */ 123 do_rawlog(LT_ERR, T("Disabling info_slave due to too many errors.")); 124 info_slave_halted = true; 125 return false; 126 } else { 127 /* Reset counter */ 128 startup_window = now; 129 startup_attempts = 0; 130 } 131 } 132 133 104 134 #ifndef AF_LOCAL 105 135 /* Use Posix.1g names. */ … … 110 140 if (socketpair(AF_LOCAL, SOCK_DGRAM, 0, socks) < 0) { 111 141 penn_perror("creating slave datagram socketpair"); 112 return ;142 return false; 113 143 } 114 144 if (socks[0] >= maxd) … … 125 155 closesocket(socks[1]); 126 156 #endif 127 return ;157 return false; 128 158 } else if (child > 0) { 129 159 info_slave_state = INFO_SLAVE_READY; … … 180 210 if (FD_ISSET(n, &info_pending)) 181 211 query_info_slave(n); 212 213 return true; 182 214 } 183 215 … … 197 229 198 230 if (info_slave_state == INFO_SLAVE_DOWN) { 199 make_info_slave(); 200 return; 201 } 231 if (!make_info_slave()) { 232 FD_CLR(fd, &info_pending); 233 closesocket(fd); /* Just drop the connection if the slave gets halted. 234 A subsequent reconnect will work. */ 235 } 236 return; 237 } 238 202 239 203 240 memset(&req, 0, sizeof req); … … 336 373 WAIT_TYPE my_stat; 337 374 pid_t pid; 338 struct timeval pad;339 375 340 376 if (info_slave_state != INFO_SLAVE_DOWN) { … … 348 384 /* Have to wait long enough for the info_slave to actually 349 385 die. This will hopefully be enough time. */ 350 pad.tv_sec = 0; 351 pad.tv_usec = 100; 352 select(0, NULL, NULL, NULL, &pad); 386 usleep(100); 353 387 354 388 pid = mush_wait(info_slave_pid, &my_stat, WNOHANG); 1.8.3/branches/devel/src/info_slave.c
r1223 r1224 204 204 if (getnameinfo(&req.remote.addr, req.rlen, resp.hostname, 205 205 sizeof resp.hostname, NULL, 0, NI_NUMERICSERV) != 0) 206 strcpy(resp.hostname, "An error occured");206 strcpy(resp.hostname, resp.ipaddr); 207 207 } else 208 208 strcpy(resp.hostname, resp.ipaddr);
