Skip to content
Open
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
4 changes: 2 additions & 2 deletions source/bulkdata/datamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ T2ERROR datamodel_init(void)

void datamodel_unInit(void)
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);

pthread_mutex_lock(&rpMutex);
stopProcessing = true;
Expand All @@ -409,5 +409,5 @@ void datamodel_unInit(void)
pthread_mutex_destroy(&tmpRpMutex);
pthread_cond_destroy(&tmpRpCond);

T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
}
10 changes: 5 additions & 5 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ T2ERROR disableProfile(const char *profileName, bool *isDeleteRequired)

T2ERROR deleteAllProfiles(bool delFromDisk)
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);

int count = 0;
int profileIndex = 0;
Expand Down Expand Up @@ -1351,13 +1351,13 @@ T2ERROR deleteAllProfiles(bool delFromDisk)
}

pthread_mutex_lock(&plMutex);
T2Debug("Deleting all profiles from the profileList\n");
T2Info("Deleting all profiles from the profileList\n");
Vector_Destroy(profileList, freeProfile);
profileList = NULL;
Vector_Create(&profileList);
pthread_mutex_unlock(&plMutex);

T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);

return T2ERROR_SUCCESS;
}
Expand Down Expand Up @@ -1704,7 +1704,7 @@ hash_map_t *getProfileHashMap()

T2ERROR uninitProfileList()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);

if(!initialized)
{
Expand All @@ -1728,7 +1728,7 @@ T2ERROR uninitProfileList()
pthread_mutex_destroy(&reportLock);
pthread_mutex_destroy(&plMutex);

T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return T2ERROR_SUCCESS;
}

Expand Down
6 changes: 3 additions & 3 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ T2ERROR ProfileXConf_init(bool checkPreviousSeek)

T2ERROR ProfileXConf_uninit()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);
if(!initialized || !singleProfile)
{
T2Info("profile list is not initialized yet, ignoring\n");
Expand All @@ -692,7 +692,7 @@ T2ERROR ProfileXConf_uninit()
pthread_mutex_unlock(&singleProfile->reportInProgressMutex);
if(reportInProgress)
{
T2Debug("Waiting for final report before uninit\n");
T2Info("Waiting for final report before uninit\n");
pthread_mutex_lock(&plMutex);
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
Expand All @@ -709,7 +709,7 @@ T2ERROR ProfileXConf_uninit()
/* Destroy condition variable at module uninit, after all threads are stopped */
pthread_cond_destroy(&reuseThread);
pthread_mutex_destroy(&plMutex);
T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return T2ERROR_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions source/bulkdata/t2markers.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ T2ERROR clearT2MarkerComponentMap()

T2ERROR destroyT2MarkerComponentMap()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);
pthread_mutex_lock(&t2MarkersMutex);
hash_map_destroy(markerCompMap, freeT2Marker);
markerCompMap = NULL;
pthread_mutex_unlock(&t2MarkersMutex);
pthread_mutex_destroy(&t2MarkersMutex);
T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
return T2ERROR_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions source/scheduler/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void uninitScheduler()
size_t index = 0;
SchedulerProfile *tProfile = NULL;

T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);

if (!sc_initialized)
{
Expand Down Expand Up @@ -523,7 +523,7 @@ void uninitScheduler()
}
//timeoutNotificationCb = NULL; Not Needed as we are in the shutdown sequence

T2Debug("%s --out\n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
}

T2ERROR registerProfileWithScheduler(const char* profileName, unsigned int timeInterval, unsigned int activationTimeout, bool deleteonTimeout, bool repeat, bool reportOnUpdate, unsigned int firstReportingInterval, char *timeRef)
Expand Down
19 changes: 19 additions & 0 deletions source/telemetry2_0.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <pthread.h>
#include <signal.h>
#include <curl/curl.h>
#include <time.h>
#ifdef __GNUC__
#ifndef _BUILD_ANDROID
#ifdef __GLIBC__
Expand Down Expand Up @@ -109,6 +110,10 @@ T2ERROR initTelemetry()

static void terminate()
{
T2Info("%s ++in\n", __FUNCTION__);
struct timespec t2, t_start;
clock_gettime(CLOCK_MONOTONIC, &t_start);
Comment thread
yogeswaransky marked this conversation as resolved.
Comment thread
yogeswaransky marked this conversation as resolved.
Comment thread
yogeswaransky marked this conversation as resolved.
Comment thread
yogeswaransky marked this conversation as resolved.

Comment thread
yogeswaransky marked this conversation as resolved.
if(remove("/tmp/.t2ReadyToReceiveEvents") != 0)
{
printf("removing the file /tmp/.t2ReadyToReceiveEvents failed!\n");
Expand All @@ -131,6 +136,10 @@ static void terminate()
ReportProfiles_uninit();
http_pool_cleanup();
}
clock_gettime(CLOCK_MONOTONIC, &t2);
Comment thread
yogeswaransky marked this conversation as resolved.
T2Info("=== [SHUTDOWN] telemetry2_0 shutdown complete, total=%lldms ===\n",
(long long)(t2.tv_sec - t_start.tv_sec) * 1000 + (t2.tv_nsec - t_start.tv_nsec) / 1000000LL);
Comment thread
yogeswaransky marked this conversation as resolved.
Comment on lines +139 to +141
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminate() calls clock_gettime() again for the end timestamp without checking for errors. If clock_gettime fails here, the computed shutdown duration can be garbage/negative. Please check the return value and only emit the total=...ms log when both timestamps are valid.

Copilot uses AI. Check for mistakes.
T2Info("%s --out\n", __FUNCTION__);

Comment thread
yogeswaransky marked this conversation as resolved.
}
static void _print_stack_backtrace(void)
Expand Down Expand Up @@ -165,6 +174,7 @@ static void _print_stack_backtrace(void)

void sig_handler(int sig, siginfo_t* info, void* uc)
{
T2Info("%s ++in\n", __FUNCTION__);
Comment thread
yogeswaransky marked this conversation as resolved.
Comment on lines 175 to +177
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added T2Info("%s --out") at the end of sig_handler() won’t execute for the shutdown/crash paths because those branches call exit(0) before reaching the end. If the intent is to bracket the handler, move the --out log before each exit() (or only log --out on the non-exiting paths) to avoid misleading logs.

Copilot uses AI. Check for mistakes.
if(DAEMONPID == getpid())
Comment on lines 175 to 178
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sig_handler() is a real signal handler (registered via sigaction with SA_SIGINFO), but the newly added T2Info() entry/exit logging is not async-signal-safe. This can deadlock/crash if the signal interrupts logging or holds internal locks (especially during shutdown). Prefer making the handler minimal (set a volatile sig_atomic_t flag / write to a self-pipe) and perform logging + terminate() from the main loop/thread context.

Copilot uses AI. Check for mistakes.
{
int fd;
Expand Down Expand Up @@ -217,6 +227,14 @@ void sig_handler(int sig, siginfo_t* info, void* uc)
}
else if ( sig == SIGTERM || sig == SIGKILL )
{
if ( sig == SIGTERM )
{
T2Info(("SIGTERM received!\n"));
Comment on lines 228 to +232
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGKILL cannot be caught or handled (it will never reach this handler). Treating it like a catchable termination signal and logging "SIGKILL received" is misleading; remove SIGKILL from this condition/logging and handle only signals that can be delivered to sigaction (e.g., SIGTERM).

Copilot uses AI. Check for mistakes.
}
else
{
T2Info(("SIGKILL received!\n"));
}
Comment on lines 228 to +237
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sig_handler() logs and branches on SIGKILL, but SIGKILL cannot be caught/handled and is never registered via sigaction() (only SIGTERM is). This makes the SIGKILL received log path effectively dead and may mislead anyone debugging shutdown. Consider removing SIGKILL from the condition/logs (or replace with a catchable signal such as SIGQUIT if that’s the intent).

Copilot uses AI. Check for mistakes.
terminate();
exit(0);
}
Expand All @@ -241,6 +259,7 @@ void sig_handler(int sig, siginfo_t* info, void* uc)
exit(0);
}
}
T2Info("%s --out\n", __FUNCTION__);
Comment thread
yogeswaransky marked this conversation as resolved.
}

static void t2DaemonMainModeInit( )
Expand Down
4 changes: 2 additions & 2 deletions source/xconf-client/xconfclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ static void* getUpdatedConfigurationThread(void *data)

void uninitXConfClient()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Info("%s ++in\n", __FUNCTION__);
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uninitXConfClient() now logs function entry at T2Info, but the matching exit log remains T2Debug later in the function. This makes shutdown tracing harder because the entry/exit pair won’t appear at the same log level. Consider using the same level for both (either keep both T2Debug or promote both to T2Info).

Suggested change
T2Info("%s ++in\n", __FUNCTION__);
T2Debug("%s ++in\n", __FUNCTION__);

Copilot uses AI. Check for mistakes.
pthread_mutex_lock(&xcThreadMutex);
if(!stopFetchRemoteConfiguration)
{
Expand All @@ -1090,7 +1090,7 @@ void uninitXConfClient()
else
{
pthread_mutex_unlock(&xcThreadMutex);
T2Debug("XConfClientThread is stopped already\n");
T2Info("XConfClientThread is stopped already\n");
}
pthread_mutex_lock(&xcThreadMutex);
if(isXconfInit)
Expand Down
Loading