msg/async/EventKqueue: assert on OOM

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2018-04-18 14:20:05 +08:00
parent c643ffd703
commit d64f0ec7b8

View File

@ -198,15 +198,14 @@ int KqueueDriver::resize_events(int newsize)
{
ldout(cct,30) << __func__ << " kqfd = " << kqfd << "newsize = " << newsize
<< dendl;
if(newsize > sav_max) {
void *_realloc = NULL;
if ((_realloc = realloc(sav_events, sizeof(struct SaveEvent)*newsize)) == NULL) {
if (newsize > sav_max) {
sav_events = realloc(sav_events, sizeof(struct SaveEvent)*newsize);
if (!sav_events) {
lderr(cct) << __func__ << " unable to realloc memory: "
<< cpp_strerror(errno) << dendl;
free(sav_events);
assert(sav_events);
return -ENOMEM;
}
sav_events = (struct SaveEvent*)_realloc;
memset(&sav_events[size], 0, sizeof(struct SaveEvent)*(newsize-sav_max));
sav_max = newsize;
}