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

Fix storage_lookup_patches return code in case process already termin… #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rashchupkinr
Copy link
Collaborator

Sometimes during stress tests buildids can't be retrieved because process already terminated.
In this case "No patch(es) applicable to PID '%d' have been found\n" was printed, which is considered error by test scripts.

@rashchupkinr rashchupkinr force-pushed the master branch 2 times, most recently from 6e57238 to d90314e Compare February 7, 2018 13:25
If process terminated before storage_lookup_patches, then
no buildids can be found and function must return -1.

static void __valog(int level, const char *prefix, const char *fmt, va_list va)
{
FILE *f = level <= LOG_WARN ? stderr : stdout;
if (prefix)
fprintf(f, "%s", prefix);

if (log_file) {
va_list vaf;
Copy link
Contributor

Choose a reason for hiding this comment

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

please print prefix as well.

src/kpatch_log.c Outdated
@@ -8,13 +8,20 @@

int log_level = LOG_INFO;
int log_indent;
FILE *log_file;
Copy link
Contributor

Choose a reason for hiding this comment

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

please either init this to zero or better make it static.

@@ -566,6 +566,10 @@ cmd_update(int argc, char *argv[])

#ifdef STRESS_TEST

#define LOG_NAME_LEN 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

Better use PATH_MAX.

@@ -566,6 +566,10 @@ cmd_update(int argc, char *argv[])

#ifdef STRESS_TEST

#define LOG_NAME_LEN 1024
char test_log_base[LOG_NAME_LEN];
Copy link
Contributor

Choose a reason for hiding this comment

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

please init these to a empty string (or declare them as static).

return -1;
}
if (log_file_init(test_log_name)) {
kperr("Can't open log file \'%s\'\n", test_log_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

please use kplogerror here.

kperr("Can't parse pid from %s\n", argv[1]);
return -1;
} else
kpinfo("Fork for pid=%d\n", pid);
Copy link
Contributor

Choose a reason for hiding this comment

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

please write a better log message. Like 'spawning child to patch pid %d'.

int child = fork();
if (child == 0) {
int rv = server_stress_test(fd, argc, argv);
stress_test_log_init(pid);
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns value. Check it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Error messages are written inside stress_test_log_init.
Contrary to base process, children should continue work even if can't initialize log file.
Is it better for them to exit in case of logging error too?

kpfatal("Can't initialize log\n");
break;
}
strncpy(test_log_base, optarg, LOG_NAME_LEN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to just use strncpy and then check if last byte is zero? (this requires test_log_base to be declared static).

@rashchupkinr rashchupkinr force-pushed the master branch 14 times, most recently from a6b9e9d to fb0f8af Compare February 16, 2018 11:57
-change some printfs to logging
@rashchupkinr rashchupkinr force-pushed the master branch 4 times, most recently from 801f8eb to 786a494 Compare February 21, 2018 14:20
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

Successfully merging this pull request may close these issues.

2 participants