try to ignore SIGPIPE, shorter power off timeout

This commit is contained in:
matthias.ringwald 2009-10-25 21:43:04 +00:00
parent 583942ad47
commit afef42bd47
2 changed files with 17 additions and 5 deletions

View File

@ -191,7 +191,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
bt_send_cmd(&hci_disconnect, wiiMoteConHandle, 0x13); // remote closed connection
wiiMoteConHandle = 0;
}
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_OFF );
// bt_send_cmd(&btstack_set_power_mode, HCI_POWER_OFF );
bt_close();
UIAlertView* alertView = [[UIAlertView alloc] init];
@ -233,7 +233,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
if (wiiMoteConHandle) {
bt_send_cmd(&hci_disconnect, wiiMoteConHandle, 0x13); // remote closed connection
}
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_OFF );
// bt_send_cmd(&btstack_set_power_mode, HCI_POWER_OFF );
bt_close();
}

View File

@ -39,7 +39,7 @@
#include "hci_transport_usb.h"
#endif
#define DAEMON_NO_CONNECTION_TIMEOUT 60000
#define DAEMON_NO_CONNECTION_TIMEOUT 20000
static hci_transport_t * transport;
static hci_uart_config_t config;
@ -188,6 +188,10 @@ static void daemon_sigint_handler(int param){
exit(0);
}
static void daemon_sigpipe_handler(int param){
printf(" <= SIGPIPE received.. trying to ignore..\n");
}
int main (int argc, const char * argv[]){
bt_control_t * control = NULL;
@ -239,9 +243,17 @@ int main (int argc, const char * argv[]){
signal(SIGINT, daemon_sigint_handler);
// handle SIGTERM - suggested for launchd
signal(SIGTERM, daemon_sigint_handler);
#if 0
// avoid crashing on closed socket
signal(SIGPIPE, SIG_IGN);
signal(SIGPIPE, daemon_sigpipe_handler);
#else 0
struct sigaction act;
act.sa_handler = SIG_IGN;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
sigaction (SIGPIPE, &act, NULL);
#endif
// make stderr unbuffered
setbuf(stderr, NULL);
setbuf(stdout, NULL);