Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2000-2003 Niels Provos <provos@citi.umich.edu> | 2 * Copyright 2000-2003 Niels Provos <provos@citi.umich.edu> |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 static int | 164 static int |
| 165 epoll_recalc(struct event_base *base, void *arg, int max) | 165 epoll_recalc(struct event_base *base, void *arg, int max) |
| 166 { | 166 { |
| 167 struct epollop *epollop = arg; | 167 struct epollop *epollop = arg; |
| 168 | 168 |
| 169 if (max >= epollop->nfds) { | 169 if (max >= epollop->nfds) { |
| 170 struct evepoll *fds; | 170 struct evepoll *fds; |
| 171 int nfds; | 171 int nfds; |
| 172 | 172 |
| 173 nfds = epollop->nfds; | 173 nfds = epollop->nfds; |
| 174 » » while (nfds < max) | 174 » » while (nfds <= max) |
|
agl
2009/06/02 23:18:14
|max| is an index into fds which needs to be valid
| |
| 175 nfds <<= 1; | 175 nfds <<= 1; |
| 176 | 176 |
| 177 fds = realloc(epollop->fds, nfds * sizeof(struct evepoll)); | 177 fds = realloc(epollop->fds, nfds * sizeof(struct evepoll)); |
| 178 if (fds == NULL) { | 178 if (fds == NULL) { |
| 179 event_warn("realloc"); | 179 event_warn("realloc"); |
| 180 return (-1); | 180 return (-1); |
| 181 } | 181 } |
| 182 epollop->fds = fds; | 182 epollop->fds = fds; |
| 183 memset(fds + epollop->nfds, 0, | 183 memset(fds + epollop->nfds, 0, |
| 184 (nfds - epollop->nfds) * sizeof(struct evepoll)); | 184 (nfds - epollop->nfds) * sizeof(struct evepoll)); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 if (epollop->fds) | 364 if (epollop->fds) |
| 365 free(epollop->fds); | 365 free(epollop->fds); |
| 366 if (epollop->events) | 366 if (epollop->events) |
| 367 free(epollop->events); | 367 free(epollop->events); |
| 368 if (epollop->epfd >= 0) | 368 if (epollop->epfd >= 0) |
| 369 close(epollop->epfd); | 369 close(epollop->epfd); |
| 370 | 370 |
| 371 memset(epollop, 0, sizeof(struct epollop)); | 371 memset(epollop, 0, sizeof(struct epollop)); |
| 372 free(epollop); | 372 free(epollop); |
| 373 } | 373 } |
| OLD | NEW |