From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] logger: allow to log using tcp transport protocol
Date: Mon, 8 Apr 2013 16:39:05 +0200 [thread overview]
Message-ID: <20130408143905.GO14350@x2.net.home> (raw)
In-Reply-To: <1365193044-14783-1-git-send-email-kerolasa@iki.fi>
On Fri, Apr 05, 2013 at 09:17:24PM +0100, Sami Kerola wrote:
> misc-utils/logger.1 | 37 ++++++++++-----
> misc-utils/logger.c | 130 +++++++++++++++++++++++++++++++++-------------------
> 2 files changed, 108 insertions(+), 59 deletions(-)
Applied, thanks.
> -myopenlog(const char *sock, int optd)
> +myopenlog(const char *sock, const int socket_type)
I have renamed the function to unix_socket() to keep the code more
consistent.
> {
> - int fd;
> + int fd, i, st = -1;
> static struct sockaddr_un s_addr; /* AF_UNIX address of local logger */
>
> if (strlen(sock) >= sizeof(s_addr.sun_path))
> @@ -107,46 +113,72 @@ myopenlog(const char *sock, int optd)
> s_addr.sun_family = AF_UNIX;
> (void)strcpy(s_addr.sun_path, sock);
>
> - if (optd == 0) {
> - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
> - goto udp_socket;
> + for (i = 2; i; i--) {
you need to reset 'st' here
int st = -1;
> + if (i == 2 && socket_type & TYPE_UDP)
> + st = SOCK_DGRAM;
> + if (i == 1 && socket_type & TYPE_TCP)
> + st = SOCK_STREAM;
> + if (st == -1 || (fd = socket(AF_UNIX, st, 0)) == -1)
> + continue;
> if (connect(fd, (struct sockaddr *)&s_addr, sizeof(s_addr)) == -1) {
> close(fd);
> - goto udp_socket;
> + continue;
> }
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2013-04-08 14:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-05 20:17 [PATCH] logger: allow to log using tcp transport protocol Sami Kerola
2013-04-08 14:39 ` Karel Zak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130408143905.GO14350@x2.net.home \
--to=kzak@redhat.com \
--cc=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox