mirror of https://github.com/ericonr/sndio.git
sndiod: Record if a client belongs to a session
This commit is contained in:
parent
5736faa146
commit
5750e312db
|
@ -151,7 +151,7 @@ sock_close(struct sock *f)
|
|||
}
|
||||
#endif
|
||||
if (f->pstate > SOCK_AUTH)
|
||||
sock_sesrefs--;
|
||||
sock_sesrefs -= f->sesrefs;
|
||||
if (f->slot) {
|
||||
slot_del(f->slot);
|
||||
f->slot = NULL;
|
||||
|
@ -792,11 +792,12 @@ sock_auth(struct sock *f)
|
|||
if (sock_sesrefs == 0) {
|
||||
/* start a new session */
|
||||
memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN);
|
||||
f->sesrefs = 1;
|
||||
} else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) {
|
||||
/* another session is active, drop connection */
|
||||
return 0;
|
||||
}
|
||||
sock_sesrefs++;
|
||||
sock_sesrefs += f->sesrefs;
|
||||
f->pstate = SOCK_HELLO;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ struct sock {
|
|||
#define SOCK_CTLVAL 2 /* send value changes */
|
||||
unsigned int ctlops; /* bitmap of above */
|
||||
int ctlsyncpending; /* CTLSYNC waiting to be transmitted */
|
||||
unsigned int sesrefs; /* 1 if socket belongs to a session */
|
||||
};
|
||||
|
||||
struct sock *sock_new(int fd);
|
||||
|
|
Loading…
Reference in New Issue