Re: [PATCH] logger: allow to log using tcp transport protocol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux