dovecot-2.2: lib: Moved rawlog dir stat()s to iostream_rawlog_cr...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 26 17:50:06 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/4bc7c1ad21a8
changeset: 17521:4bc7c1ad21a8
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 26 20:48:13 2014 +0300
description:
lib: Moved rawlog dir stat()s to iostream_rawlog_create() internally.
This is required to allow TCP rawlogs to actually work.
diffstat:
src/lib-http/http-client-connection.c | 5 +----
src/lib-imap-client/imapc-connection.c | 8 ++------
src/lib-storage/index/pop3c/pop3c-client.c | 9 ++-------
src/lib/iostream-rawlog.c | 6 ++++++
4 files changed, 11 insertions(+), 17 deletions(-)
diffs (121 lines):
diff -r f3134d3a7ff1 -r 4bc7c1ad21a8 src/lib-http/http-client-connection.c
--- a/src/lib-http/http-client-connection.c Thu Jun 26 20:46:21 2014 +0300
+++ b/src/lib-http/http-client-connection.c Thu Jun 26 20:48:13 2014 +0300
@@ -769,8 +769,6 @@
static void
http_client_connection_ready(struct http_client_connection *conn)
{
- struct stat st;
-
/* connected */
conn->connected = TRUE;
if (conn->to_connect != NULL &&
@@ -783,8 +781,7 @@
http_client_peer_connection_success(conn->peer);
/* start raw log */
- if (conn->client->set.rawlog_dir != NULL &&
- stat(conn->client->set.rawlog_dir, &st) == 0) {
+ if (conn->client->set.rawlog_dir != NULL) {
iostream_rawlog_create(conn->client->set.rawlog_dir,
&conn->conn.input, &conn->conn.output);
}
diff -r f3134d3a7ff1 -r 4bc7c1ad21a8 src/lib-imap-client/imapc-connection.c
--- a/src/lib-imap-client/imapc-connection.c Thu Jun 26 20:46:21 2014 +0300
+++ b/src/lib-imap-client/imapc-connection.c Thu Jun 26 20:48:13 2014 +0300
@@ -1185,7 +1185,6 @@
static int imapc_connection_ssl_init(struct imapc_connection *conn)
{
struct ssl_iostream_settings ssl_set;
- struct stat st;
const char *error;
if (conn->client->ssl_ctx == NULL) {
@@ -1230,8 +1229,7 @@
return -1;
}
- if (*conn->client->set.rawlog_dir != '\0' &&
- stat(conn->client->set.rawlog_dir, &st) == 0) {
+ if (*conn->client->set.rawlog_dir != '\0') {
iostream_rawlog_create(conn->client->set.rawlog_dir,
&conn->input, &conn->output);
}
@@ -1315,7 +1313,6 @@
static void imapc_connection_connect_next_ip(struct imapc_connection *conn)
{
const struct ip_addr *ip;
- struct stat st;
int fd;
i_assert(conn->client->set.max_idle_time > 0);
@@ -1333,8 +1330,7 @@
o_stream_set_no_error_handling(conn->output, TRUE);
if (*conn->client->set.rawlog_dir != '\0' &&
- conn->client->set.ssl_mode != IMAPC_CLIENT_SSL_MODE_IMMEDIATE &&
- stat(conn->client->set.rawlog_dir, &st) == 0) {
+ conn->client->set.ssl_mode != IMAPC_CLIENT_SSL_MODE_IMMEDIATE) {
iostream_rawlog_create(conn->client->set.rawlog_dir,
&conn->input, &conn->output);
}
diff -r f3134d3a7ff1 -r 4bc7c1ad21a8 src/lib-storage/index/pop3c/pop3c-client.c
--- a/src/lib-storage/index/pop3c/pop3c-client.c Thu Jun 26 20:46:21 2014 +0300
+++ b/src/lib-storage/index/pop3c/pop3c-client.c Thu Jun 26 20:48:13 2014 +0300
@@ -441,7 +441,6 @@
static int pop3c_client_ssl_init(struct pop3c_client *client)
{
struct ssl_iostream_settings ssl_set;
- struct stat st;
const char *error;
if (client->ssl_ctx == NULL) {
@@ -485,8 +484,7 @@
return -1;
}
- if (*client->set.rawlog_dir != '\0' &&
- stat(client->set.rawlog_dir, &st) == 0) {
+ if (*client->set.rawlog_dir != '\0') {
iostream_rawlog_create(client->set.rawlog_dir,
&client->input, &client->output);
}
@@ -517,8 +515,6 @@
static void pop3c_client_connect_ip(struct pop3c_client *client)
{
- struct stat st;
-
client->fd = net_connect_ip(&client->ip, client->set.port, NULL);
if (client->fd == -1) {
pop3c_client_disconnect(client);
@@ -532,8 +528,7 @@
o_stream_set_no_error_handling(client->output, TRUE);
if (*client->set.rawlog_dir != '\0' &&
- client->set.ssl_mode != POP3C_CLIENT_SSL_MODE_IMMEDIATE &&
- stat(client->set.rawlog_dir, &st) == 0) {
+ client->set.ssl_mode != POP3C_CLIENT_SSL_MODE_IMMEDIATE) {
iostream_rawlog_create(client->set.rawlog_dir,
&client->input, &client->output);
}
diff -r f3134d3a7ff1 -r 4bc7c1ad21a8 src/lib/iostream-rawlog.c
--- a/src/lib/iostream-rawlog.c Thu Jun 26 20:46:21 2014 +0300
+++ b/src/lib/iostream-rawlog.c Thu Jun 26 20:48:13 2014 +0300
@@ -214,10 +214,16 @@
{
static unsigned int counter = 0;
const char *timestamp, *prefix;
+ struct stat st;
int ret;
if ((ret = iostream_rawlog_try_create_tcp(dir, input, output)) != 0)
return ret < 0 ? -1 : 0;
+ if (stat(dir, &st) < 0) {
+ if (errno != ENOENT && errno != EACCES)
+ i_error("rawlog: stat(%s) failed: %m", dir);
+ return -1;
+ }
timestamp = t_strflocaltime("%Y%m%d-%H%M%S", ioloop_time);
More information about the dovecot-cvs
mailing list