Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: third_party/libevent/epoll.c

Issue 112089: Linux: fix libevent bug. (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698