Skip to content
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
27 changes: 20 additions & 7 deletions clamonacc/clamonacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ static struct onas_context *g_ctx = NULL;

static void onas_clamonacc_exit(int sig)
{
logg(LOGG_DEBUG, "Clamonacc: onas_clamonacc_exit(), signal %d\n", sig);
mprintf(LOGG_DEBUG, "Clamonacc: onas_clamonacc_exit(), signal %d\n", sig);
if (sig == 11) {
logg(LOGG_ERROR, "Clamonacc: clamonacc has experienced a fatal error, if you continue to see this error, please run clamonacc with --verbose and report the issue and crash report to the developers\n");
mprintf(LOGG_ERROR, "Clamonacc: clamonacc has experienced a fatal error, if you continue to see this error, please run clamonacc with --verbose and report the issue and crash report to the developers\n");
}

if (g_ctx) {
Expand All @@ -79,47 +79,60 @@ static void onas_clamonacc_exit(int sig)
g_ctx->fan_fd = 0;
}

logg(LOGG_DEBUG, "Clamonacc: attempting to stop ddd thread ... \n");
mprintf(LOGG_DEBUG, "Clamonacc: attempting to stop ddd thread ... \n");
if (ddd_pid > 0) {
pthread_cancel(ddd_pid);
pthread_join(ddd_pid, NULL);
}
ddd_pid = 0;

logg(LOGG_DEBUG, "Clamonacc: attempting to stop event consumer thread ...\n");
mprintf(LOGG_DEBUG, "Clamonacc: attempting to stop event consumer thread ...\n");
if (scan_queue_pid > 0) {
pthread_cancel(scan_queue_pid);
pthread_join(scan_queue_pid, NULL);
}
scan_queue_pid = 0;

logg(LOGG_INFO, "Clamonacc: stopped\n");
mprintf(LOGG_INFO, "Clamonacc: stopped\n");
onas_cleanup(g_ctx);
pthread_exit(NULL);
}

int main(int argc, char **argv)
{
const struct optstruct *opts;
const struct optstruct *opt;
const struct optstruct *clamdopts;
struct onas_context *ctx;
int ret = 0;

/* Initialize context */
ctx = onas_init_context();
if (ctx == NULL) {
logg(LOGG_ERROR, "Clamonacc: can't initialize context\n");
mprintf(LOGG_ERROR, "Clamonacc: can't initialize context\n");
return 2;
}

/* Parse out all our command line options */
opts = optparse(NULL, argc, argv, 1, OPT_CLAMONACC, OPT_CLAMSCAN, NULL);
if (opts == NULL) {
logg(LOGG_ERROR, "Clamonacc: can't parse command line options\n");
mprintf(LOGG_ERROR, "Clamonacc: can't parse command line options\n");
return 2;
}
ctx->opts = opts;

/* initialize logger */

if ((opt = optget(opts, "log"))->enabled) {
logg_file = opt->strarg;
if (logg(LOGG_INFO, "--------------------------------------\n")) {
mprintf(LOGG_ERROR, "ClamClient: problem with internal logger\n");
return CL_EARG;
}
} else {
logg_file = NULL;
}

if (optget(opts, "verbose")->enabled) {
mprintf_verbose = 1;
logg_verbose = 1;
Expand Down
12 changes: 0 additions & 12 deletions clamonacc/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,6 @@ cl_error_t onas_setup_client(struct onas_context **ctx)
(*ctx)->printinfected = 1;
}

/* initialize logger */

if ((opt = optget(opts, "log"))->enabled) {
logg_file = opt->strarg;
if (logg(LOGG_INFO, "--------------------------------------\n")) {
logg(LOGG_ERROR, "ClamClient: problem with internal logger\n");
return CL_EARG;
}
} else {
logg_file = NULL;
}

if (actsetup(opts)) {
return CL_EARG;
}
Expand Down