diff --git a/source3/modules/vfs_virusfilter_utils.c b/source3/modules/vfs_virusfilter_utils.c index c7f8089ffc7..a76017abf73 100644 --- a/source3/modules/vfs_virusfilter_utils.c +++ b/source3/modules/vfs_virusfilter_utils.c @@ -553,6 +553,7 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, /* Search for an existing complete line. */ ok = return_existing_line(ctx, io_h, read_line); if (ok) { + DBG_ERR("return_existing_line success with readline=\"%s\"\n"); goto finish; } @@ -569,20 +570,28 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, /* Error return - must be talloc'ed. */ perror = talloc_zero(frame, uint64_t); if (perror == NULL) { + ok = false; + DBG_ERR("talloc_zero failed\n"); goto finish; } - for (;;) { + for (int i=0;;i++) { ssize_t pending = 0; size_t read_size = 0; struct iovec iov; struct tevent_req *req = NULL; + DBG_ERR("virusfilter_io_readl loop with index i=%d.\n", + i); + /* * How much can we read ? */ pending = tstream_pending_bytes(io_h->stream); + DBG_ERR("tstream_pending_bytes pending=%zu.\n", + pending); if (pending < 0) { + ok = false; DBG_ERR("tstream_pending_bytes failed (%s).\n", strerror(errno)); goto finish; @@ -596,7 +605,11 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, read_size = MAX(read_size, (sizeof(io_h->r_buffer) - io_h->r_len)); + DBG_ERR("virusfilter_io_readl read_size=%zu.\n", + read_size); + if (read_size == 0) { + ok = false; /* Buffer is full with no EOL. Error out. */ DBG_ERR("Line buffer full.\n"); goto finish; @@ -612,6 +625,7 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, &iov, 1); if (req == NULL) { + ok = false; DBG_ERR("out of memory.\n"); goto finish; } @@ -628,7 +642,9 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, } /* Loop waiting for req to finish. */ + DBG_DEBUG("Enter tevent_req_poll\n"); ok = tevent_req_poll(req, ev); + DBG_DEBUG("Leave tevent_req_poll ok=%d\n", ok); if (!ok) { DBG_ERR("tevent_req_poll failed\n"); goto finish; @@ -642,6 +658,7 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, * EPIPE may be success so, don't exit. */ if (*perror != 0 && *perror != EPIPE) { + ok = false; DBG_DEBUG("Error %s\n", strerror((int)*perror)); errno = (int)*perror; goto finish; @@ -661,11 +678,13 @@ bool virusfilter_io_readl(TALLOC_CTX *ctx, if (ok) { goto finish; } + DBG_DEBUG("return_existing_line %s\n", read_line); /* No eol - keep reading. */ } finish: + DBG_DEBUG("virusfilter_io_readl ok=%d\n", ok); TALLOC_FREE(frame); return ok; }