Mercurial > dovecot > core-2.2
diff src/indexer/indexer-client.c @ 14681:ca37d1577291
Added o_stream_nsend*() and related functions to make delayed error handling safer.
Once o_stream_nsend*() is called, o_stream_nfinish() must be called before
stream is destroyed to finish checking if there were any errors. If
something failed and the stream is just wanted to be closed,
o_stream_ignore_last_errors() can be called.
For streams where errors don't really make any difference (network sockets)
you can call o_stream_set_no_error_handling() immediately after creating the
stream.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 25 Jun 2012 00:01:59 +0300 |
parents | ba770cba5598 |
children | d3db2ba15d00 |
line wrap: on
line diff
--- a/src/indexer/indexer-client.c Sun Jun 24 21:43:48 2012 +0300 +++ b/src/indexer/indexer-client.c Mon Jun 25 00:01:59 2012 +0300 @@ -94,7 +94,7 @@ indexer_queue_append(client->queue, append, args[1], args[2], max_recent_msgs, ctx); - o_stream_send_str(client->output, t_strdup_printf("%u\tOK\n", tag)); + o_stream_nsend_str(client->output, t_strdup_printf("%u\tOK\n", tag)); return 0; } @@ -123,7 +123,7 @@ } indexer_queue_append_optimize(client->queue, args[1], args[2], ctx); - o_stream_send_str(client->output, t_strdup_printf("%u\tOK\n", tag)); + o_stream_nsend_str(client->output, t_strdup_printf("%u\tOK\n", tag)); return 0; } @@ -192,7 +192,7 @@ struct indexer_client_request *ctx = context; T_BEGIN { - o_stream_send_str(ctx->client->output, + o_stream_nsend_str(ctx->client->output, t_strdup_printf("%u\t%d\n", ctx->tag, percentage)); } T_END; if (percentage < 0 || percentage == 100) { @@ -212,6 +212,7 @@ client->fd = fd; client->input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE); client->output = o_stream_create_fd(fd, (size_t)-1, FALSE); + o_stream_set_no_error_handling(client->output, TRUE); client->io = io_add(fd, IO_READ, indexer_client_input, client); DLLIST_PREPEND(&clients, client);