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

made shutdown timer customizable #577

Merged
merged 3 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,19 @@ SENTRY_API void sentry_options_set_database_pathw(
SENTRY_API void sentry_options_set_system_crash_reporter_enabled(
sentry_options_t *opts, int enabled);

/**
* Sets the maximum time (in milliseconds) to wait for the asynchronous tasks to
* end on shutdown, before attempting a forced termination.
*/
SENTRY_API void sentry_options_set_shutdown_timeout(
andrei-mu marked this conversation as resolved.
Show resolved Hide resolved
sentry_options_t *opts, uint64_t shutdown_timeout);

/**
* Gets the maximum time (in milliseconds) to wait for the asynchronous tasks to
* end on shutdown, before attempting a forced termination.
*/
SENTRY_API uint64_t sentry_options_get_shutdown_timeout(sentry_options_t *opts);

/* -- Global APIs -- */

/**
Expand Down
3 changes: 1 addition & 2 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ sentry_close(void)
}

if (options->transport) {
// TODO: make this configurable
if (sentry__transport_shutdown(
options->transport, SENTRY_DEFAULT_SHUTDOWN_TIMEOUT)
options->transport, options->shutdown_timeout)
!= 0) {
SENTRY_WARN("transport did not shut down cleanly");
}
Expand Down
14 changes: 14 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ sentry_options_new(void)
opts->transport = sentry__transport_new_default();
opts->sample_rate = 1.0;
opts->refcount = 1;
opts->shutdown_timeout = SENTRY_DEFAULT_SHUTDOWN_TIMEOUT;
return opts;
}

Expand Down Expand Up @@ -297,6 +298,19 @@ sentry_options_set_system_crash_reporter_enabled(
opts->system_crash_reporter_enabled = !!enabled;
}

void
sentry_options_set_shutdown_timeout(
sentry_options_t *opts, uint64_t shutdown_timeout)
{
opts->shutdown_timeout = shutdown_timeout;
}

uint64_t
sentry_options_get_shutdown_timeout(sentry_options_t *opts)
{
return opts->shutdown_timeout;
}

static void
add_attachment(sentry_options_t *opts, sentry_path_t *path)
{
Expand Down
1 change: 1 addition & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef struct sentry_options_s {

long user_consent;
long refcount;
uint64_t shutdown_timeout;
} sentry_options_t;

/**
Expand Down