[Dovecot] replace istream and unref the old one...
I Build a plugin, that do some stuffs with a email.
To get the input istream, i use the "get_stream" function, like zlib does.
I create a concat_stream, with the full_input[3];
struct istream *full_input[3];
//this like zlib input = imail->data.stream;
//first input, using the input full_input[0] = i_stream_create_header_filter(input, HEADER_FILTER_EXCLUDE | HEADER_FILTER_NO_CR, exclude_headers, 1, filter_callback, imail); // second input from another file. full_input[1] = i_stream_create_fd(fd1, 0, TRUE); // finish the input full_input[2] = NULL; // recreating the stream imail->data.stream = i_stream_create_concat(full_input); //unref the old one. i_stream_unref(&input);
return index_mail_init_stream(imail, hdr_size, body_size, stream_r);
I do like zlib, but i got this errors in LOG. I Think it's because something in the unref, but o don't know what.
Sep 20 10:48:04 brc dovecot: imap(alex@exemplo.com.br): Panic: file index-mail.c: line 1150 (index_mail_close): assertion failed: (!mail->data.destroying_stream) Sep 20 10:48:04 brc dovecot: imap(alex@exemplo.com.br): Error: Raw backtrace: /opt/addons/lib/dovecot/libdovecot.so.0 [0xb76201ee] -> /opt/addons/lib/dovecot/libdovecot.so.0 [0xb7620245] -> /opt/addons/lib/dovecot/libdovecot.so.0 [0xb761f8a6] -> /opt/addons/lib/dovecot/libdovecot-storage.so.0 [0xb76b568f] -> /opt/addons/lib/dovecot/libdovecot-storage.so.0(index_mail_free+0x25) [0xb76b7425] -> /opt/addons/lib/dovecot/libdovecot-storage.so.0(mail_free+0x12) [0xb76704b2] -> dovecot/imap(imap_fetch_deinit+0x89) [0x80583e9] -> dovecot/imap [0x805034d] -> dovecot/imap(cmd_fetch+0x45a) [0x805086a] -> dovecot/imap(cmd_uid+0x7f) [0x805514f] -> dovecot/imap [0x8055e8c] -> dovecot/imap [0x8055f3b] -> dovecot/imap(client_handle_input+0x3f) [0x805608f] -> dovecot/imap(client_input+0x5f) [0x8056a4f] -> /opt/addons/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x130) [0xb762cab0] -> /opt/addons/lib/dovecot/libdovecot.so.0(io_loop_run+0x38) [0xb762b658] -> /opt/addons/lib/dovecot/libdovecot.so.0(master_service_run+0x2a) Sep 20 10:48:04 brc dovecot: master: Error: service(imap): child 11719 killed with signal 6 (core dumps disabled)
Some One can help me ??
On Mon, 2010-09-20 at 10:58 -0300, Alex Baule wrote:
//first input, using the input full_input[0] = i_stream_create_header_filter(input, HEADER_FILTER_EXCLUDE | HEADER_FILTER_NO_CR, exclude_headers, 1, filter_callback, imail); // second input from another file. full_input[1] = i_stream_create_fd(fd1, 0, TRUE); // finish the input full_input[2] = NULL; // recreating the stream imail->data.stream = i_stream_create_concat(full_input); //unref the old one. i_stream_unref(&input);
i_stream_create_concat() also references the full_input[] streams, so you need to unreference them because you no longer need them:
i_stream_unref(&full_input[0]); i_stream_unref(&full_input[1]);
Sep 20 10:48:04 brc dovecot: imap(alex@exemplo.com.br): Panic: file index-mail.c: line 1150 (index_mail_close): assertion failed: (! mail->data.destroying_stream)
This anyway means that there is still a reference to the stream and it's getting leaked.
participants (2)
-
Alex Baule
-
Timo Sirainen