diff options
author | samr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109> | 2008-11-05 18:35:32 +0000 |
---|---|---|
committer | samr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109> | 2008-11-05 18:35:32 +0000 |
commit | c5888a20447a4df65fbc876893240d23d42c1fc1 (patch) | |
tree | 62770b6417feea31f798a60a3e999653a0b2049b /libhfp/hfp.cpp | |
parent | 17b59333c42d82c9b2b73042a7353f55ac201034 (diff) | |
download | nohands-c5888a20447a4df65fbc876893240d23d42c1fc1.tar.gz |
Fix error reporting with locally initiated SCO connections.
Attempt to fix TIOCOUTQ handling of SCO sockets.
git-svn-id: http://nohands.svn.sourceforge.net/svnroot/nohands/trunk@26 126591fb-c623-4b62-a76d-97a8e4f34109
Diffstat (limited to 'libhfp/hfp.cpp')
-rw-r--r-- | libhfp/hfp.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/libhfp/hfp.cpp b/libhfp/hfp.cpp index de98973..26d2535 100644 --- a/libhfp/hfp.cpp +++ b/libhfp/hfp.cpp @@ -815,6 +815,9 @@ ScoAccept(int ssock) void HfpSession:: ScoConnectNotify(SocketNotifier *notp, int fh) { + int sockerr; + socklen_t sl; + assert(m_sco_state == BVS_SocketConnecting); if (notp) { @@ -823,15 +826,32 @@ ScoConnectNotify(SocketNotifier *notp, int fh) m_sco_not = 0; } + m_sco_state = BVS_Connected; + assert(m_sco_not == 0); + + /* Check for a connect error */ + sl = sizeof(sockerr); + if (getsockopt(m_sco_sock, SOL_SOCKET, SO_ERROR, + &sockerr, &sl) < 0) { + GetDi()->LogWarn("Retrieve status of SCO connect: %s\n", + strerror(errno)); + __DisconnectSco(true, true, false); + return; + } + + if (sockerr) { + GetDi()->LogWarn("SCO connect: %s\n", strerror(sockerr)); + __DisconnectSco(true, true, false); + return; + } + + /* Retrieve the connection parameters */ if (!ScoGetParams(m_sco_sock)) { /* Both callbacks synchronous */ __DisconnectSco(true, true, false); return; } - m_sco_state = BVS_Connected; - assert(m_sco_not == 0); - BufOpen(m_sco_packet_samps, 2); if (cb_NotifyVoiceConnection.Registered()) @@ -853,12 +873,12 @@ ScoDataNotify(SocketNotifier *notp, int fh) return; if (m_sco_use_tiocoutq) { - if (!ioctl(m_sco_sock, TIOCOUTQ, &outq) < 0) { - outq /= 2; - } else { + if (ioctl(m_sco_sock, TIOCOUTQ, &outq)) { GetDi()->LogWarn("SCO TIOCOUTQ: %s\n", strerror(errno)); outq = m_hw_outq; + } else { + outq /= 2; } } else { outq = m_hw_outq; |