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

only one logfile (static KineticLoggerHandle) #54

Open
rcrane opened this issue Dec 1, 2016 · 0 comments
Open

only one logfile (static KineticLoggerHandle) #54

rcrane opened this issue Dec 1, 2016 · 0 comments

Comments

@rcrane
Copy link
Contributor

rcrane commented Dec 1, 2016

The file kinetic_logger.c defines a single static file handle to write log information into:
Line 34: static FILE* KineticLoggerHandle = NULL;

Through the config parameter for "KineticClient_Init()" (kinetic_client.c) it is suggested that each KineticClient can have its own log file. However, each call to KineticClient_Init() creates a new file and stores the reference in the global static KineticLoggerHandle. This leads to all KineticClients writing to the log file that was created with the last call to KineticClient_Init(). Also, if the last call to KineticClient_Init() configures no logging (KineticClientConfig.logFile = NULL), logging is disabled for all clients.

In summary, you can have multiple clients in parallel, but you cannot have multiple log files.

In very rare occasions, a segmentation fault can occur (in a multithreaded setup) at kinetic_logger.c, line 113: If threat A calls KineticClient_Init() with KineticClientConfig.logFile = NULL while thread B is descheduled at kinetic_logger.c line 110, the KineticLoggerHandle is set to NULL. Thread B will later execute kinetic_logger.c, line 113 causing fprintf to segfault.

Sugestions:
a) KineticLogger_Init() could check if KineticLoggerHandle is already set and print a notification.
b) Put the log file handle (KineticLoggerHandle) into struct _KineticSession or struct _KineticClient.

rcrane added a commit to rcrane/kinetic-c that referenced this issue Dec 1, 2016
workaround notification if creating multiple log outputs
see Kinetic#54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant