Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Fix segfault crash after stopMonitoring on Linux (#162)
Browse files Browse the repository at this point in the history
Fix #57

Co-authored-by: Matt Bernhard <[email protected]> (@umbernhard)
Co-authored-by: Dimitri Witkowski <[email protected]> (@antelle)
Co-authored-by: Julian Waller <[email protected]> (@Julusian)
Co-authored-by: Eric Eastwood <[email protected]> (@MadLittleMods)
  • Loading branch information
Matt Bernhard authored Mar 2, 2022
1 parent 6e1aefd commit e0840b7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/detection_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ void Stop() {
}

isRunning = false;

uv_mutex_destroy(&notify_mutex);
uv_signal_stop(&int_signal);
uv_signal_stop(&term_signal);
uv_close((uv_handle_t *) &async_handler, NULL);
uv_cond_destroy(&notifyDeviceHandled);

udev_monitor_unref(mon);
udev_unref(udev);
}

void InitDetection() {
Expand Down Expand Up @@ -241,6 +232,15 @@ static void cbWork(uv_work_t *req) {
udev_device_unref(dev);
}
}

// After the loop stops running, clean up all of our references and close gracefully
udev_monitor_unref(mon);
udev_unref(udev);
uv_mutex_destroy(&notify_mutex);
uv_signal_stop(&int_signal);
uv_signal_stop(&term_signal);
uv_close((uv_handle_t *) &async_handler, NULL);
uv_cond_destroy(&notifyDeviceHandled);
}

static void cbAfter(uv_work_t *req, int status) {
Expand Down

0 comments on commit e0840b7

Please sign in to comment.