On Mon, 2011-10-31 at 13:25 -0200, Alex Baule wrote:
struct ostream * o_stream_create_X_list(struct ostream *output, struct istream *input, const char *type) { struct emexis_ostream *X_stream; struct ostream *new_output; int fd;
fd = open("/tmp/email",O_WRONLY);
new_output = o_stream_create_fd_file(fd, 0, TRUE); o_stream_cork(new_output);
emexis_stream = i_new(struct emexis_ostream, 1); emexis_stream->ostream.sendv = o_stream_X_sendv; emexis_stream->ostream.flush = o_stream_X_flush; emexis_stream->ostream.iostream.close = o_stream_X_close; emexis_stream->output = new_output; emexis_stream->input = input;
o_stream_ref(new_output);
return o_stream_create(&X_stream->ostream); }
This part of the code looks ok.
With this new o_stream, i got this error.
Oct 27 15:14:24 brc dovecot: imap(alex@exemplo.com.br): Error: o_stream_send_istream(/storage/gss/emexis/messages/ exemplo.com.br/alex/Maildir/.Emexis.Ext-Blacklist/tmp/1319735664.M568409P30815.brc) failed: Bad file descriptor
I guess this should call your o_stream_X_sendv(). What do you do in that? I guess you're calling o_stream_sendv() for the new_output stream? Check if it returns -1, if it does then you're somehow breaking the new_output. Maybe you're closing it too early? Try what happens if you create it with:
new_output = o_stream_create_fd_file(fd, 0, FALSE);
Then it doesn't automatically close the fd, and it's at least clearer if the problem is because the stream is closed too early or if some completely wrong fd is attempted to be used.
There is something wrong Timo ? Like missing something or i need to rewrite another funcion ?
Nope. I think this is completely internal to your code.