Skip to content

Commit

Permalink
Problem: If a document does not want to be converted, the server may …
Browse files Browse the repository at this point in the history
…crash. The Python process is terminated, but the soffice process runs with 100% CPU and causes a memory error. Fix: If the timeout time is exceeded, catch the error and kill the process group id of the soffice process. Returns a TimeoutExpired message to the Moodle plugin.
  • Loading branch information
Mirko Otto committed Apr 7, 2022
1 parent 340def5 commit 8e4e745
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions classes/converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ public function start_document_conversion(\core_files\conversion $conversion) {
if (!empty($json->error)) {
throw new coding_exception($json->error->code . ': ' . $json->error->message . '. Response was: '.$response);
}
if (isset($json['result']['doc-conv-failed'])) {
if ($json['result']['doc-conv-failed'] == 'TimeoutExpired') {
$conversion->set('status', conversion::STATUS_FAILED);
$conversion->update();
return $this;
}
}
if (!isset($json['result']['pdf']) OR is_null($json)) {
throw new coding_exception('Response was: '.$response);
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021100700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022032800; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2019052000; // Requires this Moodle version.
$plugin->component = 'fileconverter_flasksoffice'; // Full name of the plugin (used for diagnostics).

0 comments on commit 8e4e745

Please sign in to comment.