|
From: Anders J. <and...@us...> - 2001-11-15 15:52:16
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.123 1.124=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Changed timeouts to not take any action except unlocking waitqueues.
* No more use of connection objects after a deletion :).
The diff of the modified file(s):
--- l2cap.c 2001/10/22 13:25:54 1.123
+++ l2cap.c 2001/11/15 15:52:15 1.124
@@ -210,7 +210,7 @@
static void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
-static void start_rtx(l2cap_con *con, unsigned short timeout, unsigned sho=
rt action);
+static void start_rtx(l2cap_con *con, unsigned short timeout);
static void disable_rtx(l2cap_con *con);
=20
static void start_ertx(l2cap_con *con, unsigned short timeout);
@@ -1046,7 +1046,6 @@
l2ca_wakeup("Got connect rsp neg", con);
=20=09=09=09
ENTERSTATE(con, CLOSED);
- delete_con(con);
}
break;
=20=20=20=20=20=20=20=20
@@ -1381,10 +1380,10 @@
=20=20=20=20=20=20=20
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
-=09=09=09
- l2ca_wakeup(__FUNCTION__, con);
}
=20
+=09=09
+
return 1;
} else {
/* neg cfm */
@@ -1576,6 +1575,7 @@
retval =3D lp_connect_req(con->remote_bd);
if(retval < 0) {
D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
+ delete_con(con);
return retval;
}
=20
@@ -1594,19 +1594,45 @@
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* Leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
+ do {
/* baseband is up, now initiate send connect req */
- retval =3D l2cap_connect_req(con, con->psm);
- if(retval < 0) {
+ if((retval =3D l2cap_connect_req(con, con->psm)) < 0) {=20
+ /* This can be a result of insufficient memory and it's the=20=20
+ callers responsibility to take proper action */
D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
+ if(!tmpcon) {
+ lp_disconnect(con->hci_hdl);
+ }
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ return retval;
}
/* wait until we received a response or after timeout */
l2ca_wait(__FUNCTION__ ": wait rsp", con);
+ } while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT);
+=09
+
+ if (con->c_status !=3D RES_SUCCESS) {
+ if(con->c_status =3D=3D CSTATUS_ERTX_TIMEOUT) {
+ l2ca_disconnect_ind(con);
}
=20
- if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX && !retval) {
+ if(!tmpcon) {
+ lp_disconnect(con->hci_hdl);
+ }
+=09=09
+ switch(con->c_status) {
+ case CSTATUS_MAX_NO_RTX:
retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_RTX_TIMEOUT);
+ break;
+=09=09=09
+ default:=20=20=20
+ retval =3D -MSGCODE(MSG_LAYER_L2CAP, con->c_status);
}
+=09=09
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ }
return retval;
}
=20
@@ -1679,10 +1705,8 @@
do {
retval =3D l2cap_disconnect_req(con);
if(retval < 0) {
- /* This will result in a timeout and we need to try again
- as the error is a result of insufficent space in our
- memorypool and we try again after a timeout */
D_ERR(__FUNCTION__ ": Failed (status %d)\n", retval);
+ return retval;
}
=20=09=09=09
l2ca_wait(__FUNCTION__, con);
@@ -1695,23 +1719,17 @@
return -MSGCODE(MSG_LAYER_L2CAP, L2CAP_INVALID_STATE);=20=20=20=20
}
=20=09
- if(con->c_status !=3D CSTATUS_MAX_NO_RTX) {
- if (con->current_state =3D=3D CLOSED) {=09
- /* remove l2cap connection */
- delete_con(con);
- } else {
- /* FIXME: If we reach here, should we delete the connection? */
- D_ERR(__FUNCTION__ ": Failed (Connection not closed)");
- PRINTSTATE(con);
- retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_FAILED);
- }
- }
+ ENTERSTATE(con, CLOSED);
=20=09
+ if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
+ retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_RTX_TIMEOUT);
+ l2ca_disconnect_cfm(con);
+ }
=20=09
- /* fixme -- if we want to keep baseband connection we must=20
- leave the l2cap connection which holds the hci handle=20
- simply just clear l2cap params but keep hci handle ! */
+ delete_con(con);
=20=09
+ /* If this is the last l2cap-session on the baseband connection we
+ disconnect the baseband as well */
if (count_con(tmp_hdl) =3D=3D 0) {
DSYS("l2ca_disconnect_req : (C) no more l2cap cons\n");
DSYS("Shutdown baseband\n");
@@ -1935,7 +1953,7 @@
if (con->timer.rtx_no =3D=3D MAX_NO_RTX) {
con->c_status =3D CSTATUS_MAX_NO_RTX;
=20
- D_TIM("Connection unresponsive\n");
+ D_TIM(__FUNCTION__ ": Max number of retransmit reached\n");
=20
show_con("Connection unresponsive\n", con);
=20
@@ -1946,17 +1964,6 @@
=20
/* reset rtx counter */
con->timer.rtx_no =3D 0;
-
- if (con->timer.rtx_action =3D=3D RTX_ACTION_START_ERTX) {
- /* start ertx timer */
- D_TIM("Starting ERTX\n");
- start_ertx(con, ERTX_TIMEOUT);
- } else if (con->timer.rtx_action =3D=3D RTX_ACTION_TERMINATE) {
- D_TIM("Removing connection\n");
- l2ca_disconnect_ind(con);
- ENTERSTATE(con, CLOSED);
- delete_con(con);
- }
} else {
con->timer.rtx_no++;
l2ca_timeoutind(con);=09
@@ -1980,20 +1987,8 @@
return;
}
=20
- if (con->timer.ertx_action =3D=3D ERTX_ACTION_TERMINATE) {
- D_TIM("Removing connection\n");
- l2ca_disconnect_ind(con);
- ENTERSTATE(con, CLOSED);
- delete_con(con);
- } else if (con->timer.ertx_action =3D=3D ERTX_ACTION_DISCONNECT) {
-=09=09
- D_TIM("Disconnect connection\n");
- /* set dont sleep flag so that we wont do sleep=20
- when not running in usermode context */
- con->c_flags |=3D FLAG_DONTSLEEP;
- ENTERSTATE(con, CONFIG); /* CERT HACK ! */
- l2ca_disconnect_req(con);
- }
+ con->c_status =3D CSTATUS_ERTX_TIMEOUT;
+ l2ca_wakeup("ertx_timeout", con);
}
=20
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
@@ -2082,7 +2077,7 @@
=20=09
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2210,7 +2205,7 @@
print_data("l2cap options: ", (char*)opt , opt_len);
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2260,7 +2255,7 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2308,7 +2303,7 @@
tx->cur_len =3D L2CAP_HDRSIZE + payload_len;
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_DISCONNECT);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2393,7 +2388,7 @@
tx->cur_len =3D L2CAP_HDRSIZE + payload_len; /* Increased when lower
layers add header data */
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2861,6 +2856,7 @@
retval =3D lp_connect_req(con->remote_bd);
if(retval < 0) {
D_ERR(__FUNCTION__ ": lp_connect_req failed (status %d)\n", retval);
+ delete_con(con);
return retval;
}
=20
@@ -2896,7 +2892,7 @@
=20
if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
/* max number reached, try to disconnect */
- retval =3D l2ca_disconnect_req(con);
+ retval =3D l2cap_disconnect_req(con);
}
=20
return retval;
@@ -2951,8 +2947,9 @@
D_XMIT("Now we got baseband, send info req !\n");
} else {
D_ERR(__FUNCTION__ ": lp_connect_req failed, no connection (status %d)\=
n", con->c_status);
+ retval =3D -MSGCODE(MSG_LAYER_HCI, con->c_status);
delete_con(con);
- return -MSGCODE(MSG_LAYER_HCI, con->c_status);
+ return retval;
}
}
=20
@@ -2966,7 +2963,7 @@
retval =3D l2cap_info_req(con, infotype);
if(retval < 0) {
D_ERR(__FUNCTION__ ": l2cap_info_req failed (status %d)\n", retval);
- /* Timeout and then try again */
+ return retval;
}
=20
/* wait until we received a response or after timeout */
@@ -2991,7 +2988,7 @@
/* Action is used when the sending function doesn't want
to handle the action it self */
void
-start_rtx(l2cap_con *con, unsigned short timeout, u16 action)
+start_rtx(l2cap_con *con, unsigned short timeout)
{
/* multiply by 2 each rtx */
=20
@@ -3015,7 +3012,6 @@
con->timer.rtx.data =3D (unsigned long)con;
con->timer.rtx.expires =3D jiffies + timeout*HZ;
con->timer.rtx_inuse =3D 1;
- con->timer.rtx_action =3D action;
add_timer(&con->timer.rtx);=20=20
=20
#else /* Usermode stack */
|