[Dovecot] Plugin Handle input messages

Timo Sirainen tss at iki.fi
Tue Aug 3 23:13:17 EEST 2010


On Thu, 2010-07-22 at 16:49 -0300, Alex Baule wrote:
>     /* This is when a try to change the INPUT stream to include my header
> line */
>     new_input =* i_stream_create_emx*(input);
>     if (zbox->super.save_begin(ctx, new_input) < 0)
>         return -1;
>     i_stream_unref(&new_input);

You also need to call i_stream_unref() is save_begin() fails.

>      /* This part is to handle the saved email like zlib do, and works ! */
>     zuser->writer =  emexis_uis_init(zuser->mountPoint, zuser->save_mail,
> zuser->kSize, zuser->kValue, zuser->userAuth);
>     output = o_stream_create_emexis(ctx->output, &zuser->writer, input);

I think you should use new_input here too.

> my read is like this:
> 
> 
>     do {
>         ret = read(emx_stream->fd ,stream->w_buffer + stream->pos, size);
>         fprintf(emx_stream->debug,"RET FROM READ = %d -- ERRNO = %d -- STR =
> |%s|\n", ret, errno, strerror(errno));
>     } while (ret < 0 && errno == EINTR && stream->istream.blocking);

You shouldn't be using fd directly in your istream wrapper. Use
i_stream_*() functions to read from the given input stream, similar to
how other wrapper istreams do it.

>     if (ret < 0) {
>         if (errno == EAGAIN) {
>             i_assert(!stream->istream.blocking);
>             ret = 0;

You should probably do "return 0" here.

>     emx_stream->seek_offset += ret;
>     stream->pos += ret;
> 
>     i_assert(ret > 0); // The error is here.

Looks like it happens because of EAGAIN.



More information about the dovecot mailing list