Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown Inotify Monitor Gracefully #2628

Merged
merged 8 commits into from
Feb 13, 2024

Conversation

JC-comp
Copy link
Contributor

@JC-comp JC-comp commented Feb 6, 2024

This pull request adds functionality to gracefully shut down the inotify monitor when the user sends a SIGINT signal (Ctrl+C). When the monitor receives the SIGINT signal, it closes the inotify file descriptor and exits the program gracefully.

Changes

  • Add interrupt mechanism to monitor worker
  • Add shutdown process for Monitor
  • Improve communication between monitor worker

@abraunegg
Copy link
Owner

@JC-comp
This PR does not compile cleanly:

ldc2  -w -g -O -J. -d-debug -gc -L-lcurl -L-lsqlite3  -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
onedrive.o:cgi.d:function _D7monitor23MonitorBackgroundWorker11__fieldDtorMFNeZv: error: undefined reference to '_D3std7process4Pipe11__fieldDtorMOFNeZv'
collect2: error: ld returned 1 exit status

@JC-comp
Copy link
Contributor Author

JC-comp commented Feb 11, 2024

@abraunegg
I am unable to reproduce this issue on my end. Could you please test it in a new environment or provide detailed setup instructions for your environment?

$ git clone https://github.com/abraunegg/onedrive
$ git fetch origin pull/2628/head:pr2628
$ git switch pr2628
$ source ~/dlang/ldc-1.36.0/activate
$ ./configure
$ make
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo v2.5.0-alpha-5 > version ; \
fi
ldc2 -w -g -O -J. -L-lcurl -L-lsqlite3  -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
$ 

Update
I'm unsure of the root cause of the issue or if any elements are missing. However, I can confirm successful compilation with ldc version 1.30.0 in my environment.

@abraunegg
Copy link
Owner

abraunegg commented Feb 11, 2024

@JC-comp
Unfortunately using a more modern LDC compiler is not going to be possible ... why?

The issue stems from Debian and Ubuntu LTS versions - such as Ubuntu 20.04. It's ldc package is only v1.20.1 , thus, this is the minimum version that all compilation needs to be tested against. Why?

Because the distribution version of 'ldc' is used to compile the packages presented at OpenSuSE Build Service

This means, the minimum version of LDC that can be tested against against all of these, which right now is Ubuntu 20.04 which is LDC v1.20.1.

Currently I test against an even lower version (v1.18.0) because of even older architectures for Raspberry Pi operating systems.

So in your testing and building, you must test each PR separately, by itself, compiling against the minimum LDC version, using a script similar to the following (assuming you already know how to install 'ldc' manually, and can install v1.20.1):

#!/bin/bash
  
PR=2628

rm -rf ./onedrive-pr${PR}
git clone https://github.com/abraunegg/onedrive.git onedrive-pr${PR}
cd onedrive-pr${PR}
git fetch origin pull/${PR}/head:pr${PR}
git checkout pr${PR}

# MIN LDC Version to compile
# MIN Version for ARM / Compiling with LDC
#source ~/dlang/ldc-1.18.0/activate
source ~/dlang/ldc-1.20.1/activate


./configure --enable-debug --enable-notifications; make clean; make;
deactivate
./onedrive --version

When using this script, against your PR, it generates the following error:

ldc2  -w -g -O -J. -d-debug -gc -L-lcurl -L-lsqlite3  -L-ldl src/main.d src/config.d src/log.d src/util.d src/qxor.d src/curlEngine.d src/onedrive.d src/sync.d src/itemdb.d src/sqlite.d src/clientSideFiltering.d src/monitor.d src/arsd/cgi.d -ofonedrive
onedrive.o:cgi.d:function _D7monitor23MonitorBackgroundWorker11__fieldDtorMFNeZv: error: undefined reference to '_D3std7process4Pipe11__fieldDtorMOFNeZv'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

You must make your code compatible with LDC v1.20.1 at a minimum.

@abraunegg
Copy link
Owner

@JC-comp
This PR now has conflicts that need to be resolved

@JC-comp
Copy link
Contributor Author

JC-comp commented Feb 13, 2024

Update

  • Ensure backward compatibility with ldc v1.20.1 and test the compilation
  • Resolve conflicts
  • Fix shutdown process

* Monitor is not used (and should not even be initialised if not used) in standalone mode (--sync)
* Put log level back for exit
* Better messaging
* Add verbose to log line
@abraunegg
Copy link
Owner

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Repository owner locked and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Segmentation fault occurs during cleanup triggered by termination signal.
2 participants