From b9b63c93e2e7a08427280392434f8d6af74d4158 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 28 Aug 2009 06:37:07 +0000 Subject: add a new AMSG_BYE, sent by the client to requst the server to free resources and drop the connection. This allows the client to ensuire that at any time it's using only one connection, thus only one MIDI control channel. --- usr.bin/aucat/amsg.h | 3 ++- usr.bin/aucat/sock.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'usr.bin/aucat') diff --git a/usr.bin/aucat/amsg.h b/usr.bin/aucat/amsg.h index f0563e9019a..7536f99c7b9 100644 --- a/usr.bin/aucat/amsg.h +++ b/usr.bin/aucat/amsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amsg.h,v 1.9 2009/07/25 10:52:18 ratchov Exp $ */ +/* $OpenBSD: amsg.h,v 1.10 2009/08/28 06:37:06 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -39,6 +39,7 @@ struct amsg { #define AMSG_GETCAP 7 /* get capabilities */ #define AMSG_SETVOL 8 /* set volume */ #define AMSG_HELLO 9 /* say hello, check versions and so ... */ +#define AMSG_BYE 10 /* ask server to drop connection */ uint32_t cmd; uint32_t __pad; union { diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c index 2c0e0705366..d79ec01f04d 100644 --- a/usr.bin/aucat/sock.c +++ b/usr.bin/aucat/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.27 2009/08/27 06:54:23 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.28 2009/08/28 06:37:06 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -947,6 +947,12 @@ sock_execmsg(struct sock *f) f->rstate = SOCK_RRET; f->rtodo = sizeof(struct amsg); break; + case AMSG_BYE: + DPRINTFN(2, "sock_execmsg: %p: BYE\n", f); + if (f->pstate != SOCK_INIT) + DPRINTF("sock_execmsg: %p: BYE, bad state\n", f); + aproc_del(f->pipe.file.rproc); + return 0; default: DPRINTF("sock_execmsg: %p bogus command\n", f); aproc_del(f->pipe.file.rproc); -- cgit v1.2.3