be nice, and linger to let the L2CAP connection close down gracefully

This commit is contained in:
plunky 2007-04-07 21:08:46 +00:00
parent 535dee52f6
commit 93d3f2eebc
1 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: session.c,v 1.1 2006/06/19 15:44:36 gdamore Exp $ */
/* $NetBSD: session.c,v 1.2 2007/04/07 21:08:46 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -57,12 +57,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: session.c,v 1.1 2006/06/19 15:44:36 gdamore Exp $
* $Id: session.c,v 1.2 2007/04/07 21:08:46 plunky Exp $
* $FreeBSD: src/lib/libsdp/session.c,v 1.3 2004/01/09 22:44:28 emax Exp $
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: session.c,v 1.1 2006/06/19 15:44:36 gdamore Exp $");
__RCSID("$NetBSD: session.c,v 1.2 2007/04/07 21:08:46 plunky Exp $");
#include <sys/types.h>
#include <sys/un.h>
@ -80,6 +80,7 @@ sdp_open(bdaddr_t const *l, bdaddr_t const *r)
{
sdp_session_p ss = NULL;
struct sockaddr_bt sa;
struct linger li;
socklen_t size;
if ((ss = calloc(1, sizeof(*ss))) == NULL)
@ -96,6 +97,14 @@ sdp_open(bdaddr_t const *l, bdaddr_t const *r)
goto fail;
}
memset(&li, 0, sizeof(li));
li.l_onoff = 1;
li.l_linger = 5;
if (setsockopt(ss->s, SOL_SOCKET, SO_LINGER, &li, sizeof(li)) < 0) {
ss->error = errno;
goto fail;
}
memset(&sa, 0, sizeof(sa));
sa.bt_len = sizeof(sa);
sa.bt_family = AF_BLUETOOTH;