print "Sending $len bytes...\n";
syswrite $sock, "weights $cfg{'statfile'} $len" . $CRLF;
syswrite $sock, $input . $CRLF;
- if (defined (my $reply = <$sock>)) {
+ while (defined (my $reply = <$sock>)) {
+ last if $line =~ /^END/;
print $_;
}
}
$cfg{'command'} = $1;
$cfg{'control'} = 0;
}
-elsif ($cmd =~ /(STAT|LEARN|SHUTDOWN|RELOAD|UPTIME|COUNTERS|FUZZY_ADD|FUZZY_DEL)/i) {
+elsif ($cmd =~ /(STAT|LEARN|SHUTDOWN|RELOAD|UPTIME|COUNTERS|FUZZY_ADD|FUZZY_DEL|WEIGHTS)/i) {
$cfg{'command'} = $1;
$cfg{'control'} = 1;
}
w = memory_pool_alloc (task->task_pool, sizeof (struct classify_weight));
if (data.count != 0) {
res = data.sum / data.count;
- w->name = st->symbol;
- w->weight = res;
- resl = g_list_prepend (resl, w);
}
else {
res = 0;
- w->name = st->symbol;
- w->weight = res;
- resl = g_list_prepend (resl, w);
}
+ w->name = st->symbol;
+ w->weight = res;
+ resl = g_list_prepend (resl, w);
cur = g_list_next (cur);
}
}
free_task (task, FALSE);
- i = snprintf (out_buf, sizeof (out_buf), "learn ok, sum weight: %.2f" CRLF, sum);
- if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
- return FALSE;
- }
session->state = STATE_REPLY;
break;
rspamd_dispatcher_write (task->dispatcher, CRLF, sizeof (CRLF) - 1, FALSE, TRUE);
if (default_score >= default_required_score) {
- task->worker->srv->stat->messages_ham ++;
+ task->worker->srv->stat->messages_spam ++;
}
else {
task->worker->srv->stat->messages_ham ++;