Skip to content

Folder->idle CPU 100% #89

@WaldemarOrobanche

Description

@WaldemarOrobanche

Describe the bug
The while(true) contains the condition that sometimes doesn't match and runs without timeout that will gonna to take all CPU resources. The same could happen at the catch block, because callback could throw any type of exception.

php-imap/src/Folder.php

Lines 369 to 391 in 5437529

while (true) {
try {
$line = $connection->nextLine();
if (($pos = strpos($line, "EXISTS")) !== false) {
$msgn = (int) substr($line, 2, $pos -2);
$connection->done();
$this->client->openFolder($this->path, true);
$message = $this->query()->getMessageByMsgn($msgn);
$message->setSequence($sequence);
$callback($message);
$event = $this->getEvent("message", "new");
$event::dispatch($message);
$connection->idle();
}
}catch (Exceptions\RuntimeException $e) {
if(strpos($e->getMessage(), "connection closed") === false) {
throw $e;
}
}
}

Expected behavior
Normal usage of CPU

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions