Mercurial > dovecot > core-2.2
diff src/lib-master/master-login-auth.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 | fc8031c5e691 |
children | 1ce71b5bc94a |
line wrap: on
line diff
--- a/src/lib-master/master-login-auth.c Sun Jun 24 21:43:48 2012 +0300 +++ b/src/lib-master/master-login-auth.c Mon Jun 25 00:01:59 2012 +0300 @@ -388,6 +388,7 @@ auth->fd = fd; auth->input = i_stream_create_fd(fd, AUTH_MAX_INBUF_SIZE, FALSE); auth->output = o_stream_create_fd(fd, (size_t)-1, FALSE); + o_stream_set_no_error_handling(auth->output, TRUE); auth->io = io_add(fd, IO_READ, master_login_auth_input, auth); return 0; } @@ -436,7 +437,7 @@ req->client_pid, req->auth_id); binary_to_hex_append(str, req->cookie, sizeof(req->cookie)); str_append_c(str, '\n'); - o_stream_send(auth->output, str_data(str), str_len(str)); + o_stream_nsend(auth->output, str_data(str), str_len(str)); } void master_login_auth_request(struct master_login_auth *auth, @@ -456,7 +457,7 @@ context); return; } - o_stream_send_str(auth->output, + o_stream_nsend_str(auth->output, t_strdup_printf("VERSION\t%u\t%u\n", AUTH_MASTER_PROTOCOL_MAJOR_VERSION, AUTH_MASTER_PROTOCOL_MINOR_VERSION));