diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-02 16:43:01 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-02 16:43:01 +0300 |
commit | 3d6020ef1ed601e1f2db2a90f7b64d1a634db171 (patch) | |
tree | aeb199db662a4a0ceece072dab997b037181704e | |
parent | 03490c09f41a52e59d5375c6b83872b725c96943 (diff) | |
download | rspamd-3d6020ef1ed601e1f2db2a90f7b64d1a634db171.tar.gz rspamd-3d6020ef1ed601e1f2db2a90f7b64d1a634db171.zip |
* Remove %m from logging it seems to be unsupported by FreeBSD printf version
-rw-r--r-- | src/cfg_file.y | 2 | ||||
-rw-r--r-- | src/cfg_utils.c | 6 | ||||
-rw-r--r-- | src/controller.c | 8 | ||||
-rw-r--r-- | src/lmtp.c | 6 | ||||
-rw-r--r-- | src/lmtp_proto.c | 8 | ||||
-rw-r--r-- | src/main.c | 10 | ||||
-rw-r--r-- | src/memcached.c | 18 | ||||
-rw-r--r-- | src/message.c | 2 | ||||
-rw-r--r-- | src/plugins/surbl.c | 6 | ||||
-rw-r--r-- | src/statfile.c | 12 | ||||
-rw-r--r-- | src/util.c | 2 | ||||
-rw-r--r-- | src/worker.c | 6 |
12 files changed, 42 insertions, 44 deletions
diff --git a/src/cfg_file.y b/src/cfg_file.y index 6667d01a1..7eee8516c 100644 --- a/src/cfg_file.y +++ b/src/cfg_file.y @@ -386,7 +386,7 @@ requirecmd: struct stat st; struct perl_module *cur; if (stat ($3, &st) == -1) { - yyerror ("yyparse: cannot stat file %s, %m", $3); + yyerror ("yyparse: cannot stat file %s, %s", $3, strerror (errno)); YYERROR; } cur = memory_pool_alloc (cfg->cfg_pool, sizeof (struct perl_module)); diff --git a/src/cfg_utils.c b/src/cfg_utils.c index e90fe11cb..7efb9390d 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -133,7 +133,7 @@ parse_bind_line (struct config_file *cf, char *str, enum rspamd_cred_type type) if (stat (copy, &st) == -1) { if (errno == ENOENT) { if ((fd = open (cur_tok, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) { - yyerror ("parse_bind_line: cannot open path %s for making socket, %m", cur_tok); + yyerror ("parse_bind_line: cannot open path %s for making socket, %s", cur_tok, strerror (errno)); return 0; } else { @@ -142,13 +142,13 @@ parse_bind_line (struct config_file *cf, char *str, enum rspamd_cred_type type) } } else { - yyerror ("parse_bind_line: cannot stat path %s for making socket, %m", cur_tok); + yyerror ("parse_bind_line: cannot stat path %s for making socket, %s", cur_tok, strerror (errno)); return 0; } } else { if (unlink (cur_tok) == -1) { - yyerror ("parse_bind_line: cannot remove path %s for making socket, %m", cur_tok); + yyerror ("parse_bind_line: cannot remove path %s for making socket, %s", cur_tok, strerror (errno)); return 0; } } diff --git a/src/controller.c b/src/controller.c index 503433d9b..b02782caf 100644 --- a/src/controller.c +++ b/src/controller.c @@ -486,7 +486,7 @@ accept_socket (int fd, short what, void *arg) new_session = g_malloc (sizeof (struct controller_session)); if (new_session == NULL) { - msg_err ("accept_socket: cannot allocate memory for task, %m"); + msg_err ("accept_socket: cannot allocate memory for task, %s", strerror (errno)); return; } bzero (new_session, sizeof (struct controller_session)); @@ -528,14 +528,14 @@ start_controller (struct rspamd_worker *worker) if (worker->srv->cfg->control_family == AF_INET) { if ((listen_sock = make_socket (&worker->srv->cfg->control_addr, worker->srv->cfg->control_port)) == -1) { - msg_err ("start_controller: cannot create tcp listen socket. %m"); + msg_err ("start_controller: cannot create tcp listen socket. %s", strerror (errno)); exit(-errno); } } else { un_addr = (struct sockaddr_un *) alloca (sizeof (struct sockaddr_un)); if (!un_addr || (listen_sock = make_unix_socket (worker->srv->cfg->control_host, un_addr)) == -1) { - msg_err ("start_controller: cannot create unix listen socket. %m"); + msg_err ("start_controller: cannot create unix listen socket. %s", strerror (errno)); exit(-errno); } } @@ -543,7 +543,7 @@ start_controller (struct rspamd_worker *worker) start_time = time (NULL); if (listen (listen_sock, -1) == -1) { - msg_err ("start_controller: cannot listen on socket. %m"); + msg_err ("start_controller: cannot listen on socket. %s", strerror (errno)); exit(-errno); } diff --git a/src/lmtp.c b/src/lmtp.c index fb7c8a8b0..9503255a4 100644 --- a/src/lmtp.c +++ b/src/lmtp.c @@ -283,20 +283,20 @@ start_lmtp_worker (struct rspamd_worker *worker) /* Create listen socket */ if (worker->srv->cfg->lmtp_family == AF_INET) { if ((listen_sock = make_socket (&worker->srv->cfg->lmtp_addr, worker->srv->cfg->lmtp_port)) == -1) { - msg_err ("start_lmtp: cannot create tcp listen socket. %m"); + msg_err ("start_lmtp: cannot create tcp listen socket. %s", strerror (errno)); exit(-errno); } } else { un_addr = (struct sockaddr_un *) alloca (sizeof (struct sockaddr_un)); if (!un_addr || (listen_sock = make_unix_socket (worker->srv->cfg->lmtp_host, un_addr)) == -1) { - msg_err ("start_lmtp: cannot create unix listen socket. %m"); + msg_err ("start_lmtp: cannot create unix listen socket. %s", strerror (errno)); exit(-errno); } } if (listen (listen_sock, -1) == -1) { - msg_err ("start_lmtp: cannot listen on socket. %m"); + msg_err ("start_lmtp: cannot listen on socket. %s", strerror (errno)); exit(-errno); } /* Accept event */ diff --git a/src/lmtp_proto.c b/src/lmtp_proto.c index 06bba02fe..42bf3560a 100644 --- a/src/lmtp_proto.c +++ b/src/lmtp_proto.c @@ -432,7 +432,7 @@ lmtp_deliver_mta (struct worker_task *task) sock = make_socket (&task->cfg->deliver_addr, task->cfg->deliver_port); } if (sock == -1) { - msg_warn ("lmtp_deliver_mta: cannot create socket for %s, %m", task->cfg->deliver_host); + msg_warn ("lmtp_deliver_mta: cannot create socket for %s, %s", task->cfg->deliver_host, strerror (errno)); } /* Socket options */ @@ -554,7 +554,7 @@ lmtp_deliver_lda (struct worker_task *task) if (pipe (p) == -1) { g_strfreev (argv); - msg_info ("lmtp_deliver_lda: cannot open pipe: %m"); + msg_info ("lmtp_deliver_lda: cannot open pipe: %s", strerror (errno)); return -1; } @@ -562,13 +562,13 @@ lmtp_deliver_lda (struct worker_task *task) #ifdef HAVE_VFORK if ((cpid = vfork ()) == -1) { g_strfreev (argv); - msg_info ("lmtp_deliver_lda: cannot fork: %m"); + msg_info ("lmtp_deliver_lda: cannot fork: %s", strerror (errno)); return -1; } #else if ((cpid = fork ()) == -1) { g_strfreev (argv); - msg_info ("lmtp_deliver_lda: cannot fork: %m"); + msg_info ("lmtp_deliver_lda: cannot fork: %s", strerror (errno)); return -1; } #endif diff --git a/src/main.c b/src/main.c index 9c2da60b7..da142d6a7 100644 --- a/src/main.c +++ b/src/main.c @@ -194,7 +194,7 @@ fork_worker (struct rspamd_main *rspamd, int listen_sock, int reconfig, enum pro } break; case -1: - msg_err ("fork_worker: cannot fork main process. %m"); + msg_err ("fork_worker: cannot fork main process. %s", strerror (errno)); pidfile_remove (rspamd->pfh); exit (-errno); break; @@ -343,7 +343,7 @@ main (int argc, char **argv, char **env) PERL_SYS_INIT3 (&argc, &argv, &env); perl_interpreter = perl_alloc (); if (perl_interpreter == NULL) { - msg_err ("main: cannot allocate perl interpreter, %m"); + msg_err ("main: cannot allocate perl interpreter, %s", strerror (errno)); exit (-errno); } @@ -355,20 +355,20 @@ main (int argc, char **argv, char **env) if (rspamd->cfg->bind_family == AF_INET) { if ((listen_sock = make_socket (&rspamd->cfg->bind_addr, rspamd->cfg->bind_port)) == -1) { - msg_err ("main: cannot create tcp listen socket. %m"); + msg_err ("main: cannot create tcp listen socket. %s", strerror (errno)); exit(-errno); } } else { un_addr = (struct sockaddr_un *) g_malloc (sizeof (struct sockaddr_un)); if (!un_addr || (listen_sock = make_unix_socket (rspamd->cfg->bind_host, un_addr)) == -1) { - msg_err ("main: cannot create unix listen socket. %m"); + msg_err ("main: cannot create unix listen socket. %s", strerror (errno)); exit(-errno); } } if (listen (listen_sock, -1) == -1) { - msg_err ("main: cannot listen on socket. %m"); + msg_err ("main: cannot listen on socket. %s", strerror (errno)); exit(-errno); } diff --git a/src/memcached.c b/src/memcached.c index d2636f5e6..2d369c87c 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -130,7 +130,7 @@ write_handler (int fd, short what, memcached_ctx_t *ctx) iov[3].iov_base = CRLF; iov[3].iov_len = sizeof (CRLF) - 1; if (writev (ctx->sock, iov, 4) == -1) { - memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + memc_log (ctx, __LINE__, "memc_write: writev failed: %s", strerror (errno)); } } else { @@ -222,12 +222,12 @@ read_handler (int fd, short what, memcached_ctx_t *ctx) iov[1].iov_base = read_buf; iov[1].iov_len = r; if (writev (ctx->sock, iov, 2) == -1) { - memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + memc_log (ctx, __LINE__, "memc_write: writev failed: %s", strerror (errno)); } } else { if (write (ctx->sock, read_buf, r) == -1) { - memc_log (ctx, __LINE__, "memc_write: write failed: %m"); + memc_log (ctx, __LINE__, "memc_write: write failed: %s", strerror (errno)); } } event_del (&ctx->mem_ev); @@ -311,7 +311,7 @@ read_handler (int fd, short what, memcached_ctx_t *ctx) ctx->param->bufpos += r; } else { - memc_log (ctx, __LINE__, "memc_read: read(v) failed: %d, %m", r); + memc_log (ctx, __LINE__, "memc_read: read(v) failed: %d, %s", r, strerror (errno)); event_del (&ctx->mem_ev); ctx->callback (ctx, SERVER_ERROR, ctx->callback_data); return; @@ -356,12 +356,12 @@ delete_handler (int fd, short what, memcached_ctx_t *ctx) iov[1].iov_len = r; ctx->param->bufpos = writev (ctx->sock, iov, 2); if (ctx->param->bufpos == -1) { - memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + memc_log (ctx, __LINE__, "memc_write: writev failed: %s", strerror (errno)); } } else { if (write (ctx->sock, read_buf, r) == -1) { - memc_log (ctx, __LINE__, "memc_write: write failed: %m"); + memc_log (ctx, __LINE__, "memc_write: write failed: %s", strerror (errno)); } } event_del (&ctx->mem_ev); @@ -475,7 +475,7 @@ memc_make_udp_sock (memcached_ctx_t *ctx) ctx->sock = socket (PF_INET, SOCK_DGRAM, 0); if (ctx->sock == -1) { - memc_log (ctx, __LINE__, "memc_make_udp_sock: socket() failed: %m"); + memc_log (ctx, __LINE__, "memc_make_udp_sock: socket() failed: %s", strerror (errno)); return -1; } @@ -510,7 +510,7 @@ memc_make_tcp_sock (memcached_ctx_t *ctx) ctx->sock = socket (PF_INET, SOCK_STREAM, 0); if (ctx->sock == -1) { - memc_log (ctx, __LINE__, "memc_make_tcp_sock: socket() failed: %m"); + memc_log (ctx, __LINE__, "memc_make_tcp_sock: socket() failed: %s", strerror (errno)); return -1; } @@ -522,7 +522,7 @@ memc_make_tcp_sock (memcached_ctx_t *ctx) if (errno != EINPROGRESS) { close (ctx->sock); ctx->sock = -1; - memc_log (ctx, __LINE__, "memc_make_tcp_sock: connect() failed: %m"); + memc_log (ctx, __LINE__, "memc_make_tcp_sock: connect() failed: %s", strerror (errno)); return -1; } } diff --git a/src/message.c b/src/message.c index bce54c992..c2651bdc8 100644 --- a/src/message.c +++ b/src/message.c @@ -312,7 +312,7 @@ mime_foreach_callback (GMimeObject *part, gpointer user_data) } } else { - msg_warn ("mime_foreach_callback: write to stream failed: %d, %m", errno); + msg_warn ("mime_foreach_callback: write to stream failed: %d, %s", errno, strerror (errno)); } } else { diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 1940a5f57..d563e9cde 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -471,7 +471,7 @@ redirector_callback (int fd, short what, void *arg) event_add (¶m->ev, &timeout); r = snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url)); if (write (param->sock, url_buf, r) == -1) { - msg_err ("redirector_callback: write failed %m"); + msg_err ("redirector_callback: write failed %s", strerror (errno)); event_del (¶m->ev); param->task->save.saved --; if (param->task->save.saved == 0) { @@ -555,7 +555,7 @@ register_redirector_call (struct uri *url, struct worker_task *task) s = socket (PF_INET, SOCK_STREAM, 0); if (s == -1) { - msg_info ("register_redirector_call: socket() failed: %m"); + msg_info ("register_redirector_call: socket() failed: %s", strerror (errno)); return; } @@ -566,7 +566,7 @@ register_redirector_call (struct uri *url, struct worker_task *task) if ((r = connect (s, (struct sockaddr*)&sc, sizeof (struct sockaddr_in))) == -1) { if (errno != EINPROGRESS) { close (s); - msg_info ("register_redirector_call: connect() failed: %m"); + msg_info ("register_redirector_call: connect() failed: %s", strerror (errno)); } } param = memory_pool_alloc (task->task_pool, sizeof (struct redirector_param)); diff --git a/src/statfile.c b/src/statfile.c index 83d538256..80c98825f 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -125,7 +125,7 @@ statfile_pool_open (statfile_pool_t *pool, char *filename) } if (stat (filename, &st) == -1) { - msg_info ("statfile_pool_open: cannot stat file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_open: cannot stat file %s, error %s, %d", filename, strerror (errno), errno); return -1; } @@ -144,13 +144,13 @@ statfile_pool_open (statfile_pool_t *pool, char *filename) new_file = memory_pool_alloc (pool->pool, sizeof (stat_file_t)); if ((new_file->fd = open (filename, O_RDWR)) == -1 ) { - msg_info ("statfile_pool_open: cannot open file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_open: cannot open file %s, error %d, %s", filename, errno, strerror (errno)); return -1; } if ((new_file->map = mmap (NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, new_file->fd, 0)) == NULL) { close (new_file->fd); - msg_info ("statfile_pool_open: cannot mmap file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_open: cannot mmap file %s, error %d, %s", filename, errno, strerror (errno)); return -1; } @@ -217,20 +217,20 @@ statfile_pool_create (statfile_pool_t *pool, char *filename, size_t blocks) } if ((fd = open (filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1 ) { - msg_info ("statfile_pool_create: cannot create file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_create: cannot create file %s, error %d, %s", filename, errno, strerror (errno)); return -1; } header.create_time = (uint64_t)time (NULL); if (write (fd, &header, sizeof (header)) == -1) { - msg_info ("statfile_pool_create: cannot write header to file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_create: cannot write header to file %s, error %d, %s", filename, errno, strerror (errno)); close (fd); return -1; } while (blocks --) { if (write (fd, &block, sizeof (block)) == -1) { - msg_info ("statfile_pool_create: cannot write block to file %s, error %m, %d", filename, errno); + msg_info ("statfile_pool_create: cannot write block to file %s, error %d, %s", filename, errno, strerror (errno)); close (fd); return -1; } diff --git a/src/util.c b/src/util.c index a7aea229c..afcb13b23 100644 --- a/src/util.c +++ b/src/util.c @@ -750,7 +750,7 @@ open_log (struct config_file *cfg) case RSPAMD_LOG_FILE: cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (cfg->log_fd == -1) { - msg_err ("open_log: cannot open desired log file: %s, %m", cfg->log_file); + msg_err ("open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno)); return -1; } return 0; diff --git a/src/worker.c b/src/worker.c index 03912930f..dee49ef4d 100644 --- a/src/worker.c +++ b/src/worker.c @@ -233,10 +233,7 @@ accept_socket (int fd, short what, void *arg) setsockopt (nfd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)); new_task = g_malloc (sizeof (struct worker_task)); - if (new_task == NULL) { - msg_err ("accept_socket: cannot allocate memory for task, %m"); - return; - } + msg_debug ("accept_socket: new task allocated: %p", new_task); bzero (new_task, sizeof (struct worker_task)); new_task->worker = worker; @@ -251,6 +248,7 @@ accept_socket (int fd, short what, void *arg) memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)rcpt_destruct, new_task); new_task->results = g_hash_table_new (g_str_hash, g_str_equal); memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)g_hash_table_destroy, new_task->results); + worker->srv->stat->connections_count ++; /* Set up dispatcher */ |