git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@865
959494ce-11ee-0310-bf91-
de5d638817bd
- if(sk->fd >= 0)
- close(sk->fd);
if(sk->remote != NULL)
free(sk->remote);
free(sk);
if(sk->remote != NULL)
free(sk->remote);
free(sk);
void closesock(struct socket *sk)
{
void closesock(struct socket *sk)
{
+ struct sockaddr_un *un;
+
+ if((sk->family == AF_UNIX) && !sockgetlocalname(sk, (struct sockaddr **)&un, NULL) && (un->sun_family == PF_UNIX))
+ {
+ if(strchr(un->sun_path, '/'))
+ {
+ if(unlink(un->sun_path))
+ flog(LOG_WARNING, "could not unlink UNIX socket %s: %s", un->sun_path, strerror(errno));
+ }
+ }
sk->state = SOCK_STL;
close(sk->fd);
sk->fd = -1;
sk->state = SOCK_STL;
close(sk->fd);
sk->fd = -1;
return(-1);
}
*namebuf = memcpy(smalloc(len), &name, len);
return(-1);
}
*namebuf = memcpy(smalloc(len), &name, len);
+ if(lenbuf != NULL)
+ *lenbuf = len;