return;
}
/* Move remaining string to begin of buffer (draining) */
+ /* Reinit pointers as buffer may be changed */
+ len = &d->in_buf->data->len;
+ pos = &d->in_buf->pos;
memmove (d->in_buf->data->begin, c + 1, *len - r - 1);
b = d->in_buf->data->begin;
c = b;
return;
}
/* Move remaining string to begin of buffer (draining) */
+ len = &d->in_buf->data->len;
+ pos = &d->in_buf->pos;
memmove (d->in_buf->data->begin, c, *len - r);
b = d->in_buf->data->begin;
c = b;
return FALSE;
}
- if (rev == 0) {
- return write_whole_statfile (session, symbol, ccf);
- }
-
while (binlog_sync (binlog, rev, &time, &data)) {
r = snprintf (out_buf, sizeof (out_buf), "%lu %lu %lu" CRLF, (long unsigned)rev, (long unsigned)time, (long unsigned)data->len);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, TRUE, FALSE);
parse_revision_line (struct rspamd_sync_ctx *ctx, f_str_t *in)
{
int i, state = 0;
- char *p, *c, t;
+ char *p, *c, numbuf[sizeof("18446744073709551615")];
uint64_t *val;
/* First of all try to find END line */
return TRUE;
}
- msg_info ("got string: %V", in);
/* Now try to extract 3 numbers from string: revision, time and length */
p = in->begin;
val = &ctx->new_rev;
for (i = 0; i < in->len; i ++, p ++) {
if (g_ascii_isspace (*p) || i == in->len - 1) {
if (state == 1) {
- t = *p;
- *p = '\0';
+ if (i == in->len - 1) {
+ /* One more character */
+ p ++;
+ }
+ g_strlcpy (numbuf, c, MIN (p - c + 1, sizeof (numbuf)));
errno = 0;
- *val = strtoull (c, NULL, 10);
- *p = t;
+ *val = strtoull (numbuf, NULL, 10);
if (errno != 0) {
msg_info ("parse_revision_line: cannot parse number %s", strerror (errno));
return FALSE;
}
else {
/* Quit this session */
- msg_info ("sync_read: no sync needed for: %s", ctx->st->symbol);
+ msg_info ("sync_read: sync ended for: %s", ctx->st->symbol);
close (ctx->sock);
rspamd_remove_dispatcher (ctx->dispatcher);
ctx->is_busy = FALSE;
}
statfile_set_revision (ctx->real_statfile, ctx->new_rev, ctx->new_time);
/* Now try to read other revision or END line */
- rspamd_set_dispatcher_policy (ctx->dispatcher, BUFFER_LINE, 0);
ctx->state = SYNC_STATE_READ_LINE;
+ rspamd_set_dispatcher_policy (ctx->dispatcher, BUFFER_LINE, 0);
break;
case SYNC_STATE_QUIT:
close (ctx->sock);