summaryrefslogtreecommitdiffstats
path: root/src/worker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/worker.c')
-rw-r--r--src/worker.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/worker.c b/src/worker.c
index 115c3be11..5ebdaf84b 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -443,16 +443,15 @@ static void
accept_socket (int fd, short what, void *arg)
{
struct rspamd_worker *worker = (struct rspamd_worker *)arg;
- struct sockaddr_storage ss;
- struct sockaddr_in *sin;
+ union sa_union su;
struct worker_task *new_task;
GList *cur;
struct custom_filter *filt;
- socklen_t addrlen = sizeof (ss);
+ socklen_t addrlen = sizeof (su.ss);
int nfd;
- if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
+ if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
msg_warn ("accept failed: %s", strerror (errno));
return;
}
@@ -463,14 +462,13 @@ accept_socket (int fd, short what, void *arg)
new_task = construct_task (worker);
- if (ss.ss_family == AF_UNIX) {
+ if (su.ss.ss_family == AF_UNIX) {
msg_info ("accepted connection from unix socket");
new_task->client_addr.s_addr = INADDR_NONE;
}
- else if (ss.ss_family == AF_INET) {
- sin = (struct sockaddr_in *)&ss;
- msg_info ("accepted connection from %s port %d", inet_ntoa (sin->sin_addr), ntohs (sin->sin_port));
- memcpy (&new_task->client_addr, &sin->sin_addr, sizeof (struct in_addr));
+ else if (su.ss.ss_family == AF_INET) {
+ msg_info ("accepted connection from %s port %d", inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
+ memcpy (&new_task->client_addr, &su.s4.sin_addr, sizeof (struct in_addr));
}
new_task->sock = nfd;