killfnetnode(data);
putfnetnode(data);
} else {
- netcsconn(addr, addrlen, (void (*)(struct socket *, int, void *))conncb, data);
+ putsock(netcsconn(addr, addrlen, (void (*)(struct socket *, int, void *))conncb, data));
}
}
{
char *p;
struct dchub *hub;
- struct socket *newsk;
struct sockaddr_in addr;
hub = fn->data;
addr.sin_port = htons(atoi(p));
if(!inet_aton(args, &addr.sin_addr))
return;
- newsk = netcsconn((struct sockaddr *)&addr, sizeof(addr), (void (*)(struct socket *, int, void *))peerconnect, fn);
+ putsock(netcsconn((struct sockaddr *)&addr, sizeof(addr), (void (*)(struct socket *, int, void *))peerconnect, fn));
getfnetnode(fn);
hubhandleaction(sk, fn, cmd, args);
}
memcpy(sk->ufd->d.s.remote = smalloc(addrlen), addr, sk->ufd->d.s.remotelen = addrlen);
sk->back->conncb = func;
sk->back->data = data;
+ getsock(sk->back);
+ putsock(sk);
if(!connect(sk->ufd->fd, addr, addrlen))
{
sksetstate(sk, SOCK_EST);
static void cleansocks(void)
{
struct ufd *ufd, *next;
+ int dead;
for(ufd = ufds; ufd != NULL; ufd = next) {
next = ufd->next;
- if(ufd->sk && ((ufd->fd < 0) || (sockgetdatalen(ufd->sk) == 0))) {
+ if(ufd->sk) {
+ dead = (ufd->fd < 0);
+ if(ufd->sk->state == SOCK_STL)
+ dead = 1;
+ if((ufd->sk->state == SOCK_EST) && (sockgetdatalen(ufd->sk) == 0))
+ dead = 1;
+ if(!dead)
+ continue;
if(ufd->sk->eos == 1) {
ufd->sk->eos = 2;
closeufd(ufd);