Print this page
10108 libstmfproxy needs smatch fixes
*** 21,30 ****
--- 21,34 ----
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+ /*
+ * Copyright (c) 2018, Joyent, Inc.
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
*** 119,129 ****
goto serv_out;
}
sh = malloc(sizeof (*sh));
sh->sockfd = new_sfd;
serv_out:
! close(sfd);
} else {
struct hostent *hp;
/*
* Assume IP dot notation or if that fails, gethostbyname()
--- 123,133 ----
goto serv_out;
}
sh = malloc(sizeof (*sh));
sh->sockfd = new_sfd;
serv_out:
! (void) close(sfd);
} else {
struct hostent *hp;
/*
* Assume IP dot notation or if that fails, gethostbyname()
*** 149,168 ****
/* XXX pass in from smf */
sin.sin_port = htons(6543);
while (connect(sfd, (struct sockaddr *)&sin,
sizeof (sin)) < 0) {
! close(sfd);
if (errno == ECONNREFUSED) {
/* get a fresh socket and retry */
sfd = socket(AF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
syslog(LOG_DAEMON|LOG_WARNING,
"socket() call failed: %d", errno);
return (NULL);
}
! sleep(2);
} else {
syslog(LOG_DAEMON|LOG_CRIT,
"Cannot connect %s - %d", server, errno);
return (NULL);
}
--- 153,172 ----
/* XXX pass in from smf */
sin.sin_port = htons(6543);
while (connect(sfd, (struct sockaddr *)&sin,
sizeof (sin)) < 0) {
! (void) close(sfd);
if (errno == ECONNREFUSED) {
/* get a fresh socket and retry */
sfd = socket(AF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
syslog(LOG_DAEMON|LOG_WARNING,
"socket() call failed: %d", errno);
return (NULL);
}
! (void) sleep(2);
} else {
syslog(LOG_DAEMON|LOG_CRIT,
"Cannot connect %s - %d", server, errno);
return (NULL);
}