summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5cbc1d)
raw | patch | inline | side by side (parent: d5cbc1d)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 12 Dec 2006 10:11:49 +0000 (11:11 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 13 Dec 2006 07:01:08 +0000 (08:01 +0100) |
Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/email.c | patch | blob | history |
diff --git a/src/email.c b/src/email.c
index 0f9c2f3de016f521b62a2ebfbdd0aaa3a4eb84c9..7c23e9b4fe2d478441efcce640afd291b54208c0 100644 (file)
--- a/src/email.c
+++ b/src/email.c
#define MAX_CONNS 5
#define MAX_CONNS_LIMIT 16384
+#define log_err(...) syslog (LOG_ERR, MODULE_NAME": "__VA_ARGS__)
+#define log_warn(...) syslog (LOG_WARNING, MODULE_NAME": "__VA_ARGS__)
+
/*
* Private data structures
*/
FD_SET (src->socket, &fdset);
if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
- syslog (LOG_ERR, "select() failed: %s", strerror (errno));
+ log_err ("select() failed: %s", strerror (errno));
return '\0';
}
errno = 0;
if (0 > (len = read (src->socket, (void *)&ret, 1))) {
if (EINTR != errno) {
- syslog (LOG_ERR, "read() failed: %s", strerror (errno));
+ log_err ("read() failed: %s", strerror (errno));
return '\0';
}
}
FD_SET (src->socket, &fdset);
if (-1 == select (src->socket + 1, &fdset, NULL, NULL, NULL)) {
- syslog (LOG_ERR, "select() failed: %s", strerror (errno));
+ log_err ("select() failed: %s", strerror (errno));
return NULL;
}
(void *)(src->buffer + src->idx),
BUFSIZE - src->idx))) {
if (EINTR != errno) {
- syslog (LOG_ERR, "read() failed: %s", strerror (errno));
+ log_err ("read() failed: %s", strerror (errno));
return NULL;
}
}
errno = 0;
if (-1 == fcntl (connection->socket, F_GETFL, &flags)) {
- syslog (LOG_ERR, "fcntl() failed: %s", strerror (errno));
+ log_err ("fcntl() failed: %s", strerror (errno));
loop = 0;
}
errno = 0;
if (-1 == fcntl (connection->socket, F_SETFL, flags | O_NONBLOCK)) {
- syslog (LOG_ERR, "fcntl() failed: %s", strerror (errno));
+ log_err ("fcntl() failed: %s", strerror (errno));
loop = 0;
}
}
}
if (':' != line[1]) {
- syslog (LOG_ERR, "email: syntax error in line '%s'", line);
+ log_err ("syntax error in line '%s'", line);
continue;
}
int bytes = 0;
if (NULL == tmp) {
- syslog (LOG_ERR, "email: syntax error in line '%s'", line);
+ log_err ("syntax error in line '%s'", line);
continue;
}
} while (NULL != (type = strtok_r (NULL, ",", &ptr)));
}
else {
- syslog (LOG_ERR, "email: unknown type '%c'", line[0]);
+ log_err ("unknown type '%c'", line[0]);
}
} /* while (loop) */
errno = 0;
if (-1 == (connector_socket = socket (PF_UNIX, SOCK_STREAM, 0))) {
disabled = 1;
- syslog (LOG_ERR, "socket() failed: %s", strerror (errno));
+ log_err ("socket() failed: %s", strerror (errno));
pthread_exit ((void *)1);
}
offsetof (struct sockaddr_un, sun_path)
+ strlen(addr.sun_path))) {
disabled = 1;
- syslog (LOG_ERR, "bind() failed: %s", strerror (errno));
+ log_err ("bind() failed: %s", strerror (errno));
pthread_exit ((void *)1);
}
errno = 0;
if (-1 == listen (connector_socket, 5)) {
disabled = 1;
- syslog (LOG_ERR, "listen() failed: %s", strerror (errno));
+ log_err ("listen() failed: %s", strerror (errno));
pthread_exit ((void *)1);
}
if (NULL != (grp = getgrnam (sock_group))) {
errno = 0;
if (0 != chown (SOCK_PATH, (uid_t)-1, grp->gr_gid)) {
- syslog (LOG_WARNING, "chown() failed: %s", strerror (errno));
+ log_warn ("chown() failed: %s", strerror (errno));
}
}
else {
- syslog (LOG_WARNING, "getgrnam() failed: %s", strerror (errno));
+ log_warn ("getgrnam() failed: %s", strerror (errno));
}
}
else {
- syslog (LOG_WARNING, "not running as root");
+ log_warn ("not running as root");
}
errno = 0;
if (0 != chmod (SOCK_PATH, sock_perms)) {
- syslog (LOG_WARNING, "chmod() failed: %s", strerror (errno));
+ log_warn ("chmod() failed: %s", strerror (errno));
}
{ /* initialize collector threads */
if (0 != (err = pthread_create (&collectors[i]->thread, &ptattr,
collect, collectors[i]))) {
- syslog (LOG_ERR, "pthread_create() failed: %s",
- strerror (err));
+ log_err ("pthread_create() failed: %s", strerror (err));
}
}
if (-1 == (remote = accept (connector_socket, NULL, NULL))) {
if (EINTR != errno) {
disabled = 1;
- syslog (LOG_ERR, "accept() failed: %s", strerror (errno));
+ log_err ("accept() failed: %s", strerror (errno));
pthread_exit ((void *)1);
}
}
if (0 != (err = pthread_create (&connector, NULL,
open_connection, NULL))) {
disabled = 1;
- syslog (LOG_ERR, "pthread_create() failed: %s", strerror (err));
+ log_err ("pthread_create() failed: %s", strerror (err));
return;
}
#endif /* EMAIL_HAVE_READ */