mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
drop HAVE_SO_NOSIGPIPE
This commit is contained in:
parent
f0573431be
commit
e32b1c032a
@ -35,7 +35,6 @@ HAVE_B600_MAPPED_TO_3000000 | posix | Hack to use serial port with 3 mpbs
|
||||
HAVE_EHCILL | cc256x radio | CC256x/WL18xx with eHCILL is used
|
||||
HAVE_MALLOC | | dynamic memory used
|
||||
HAVE_POSIX_FILE_IO | posix | POSIX File i/o used for hci dump
|
||||
HAVE_SO_NOSIGPIPE | posix | libc supports SO_NOSIGPIPE
|
||||
HAVE_STDIO | | STDIN is available for examples
|
||||
HAVE_TICK | embedded | System provides tick interrupt
|
||||
HAVE_TIME | posix | System provides time function
|
||||
|
@ -85,6 +85,8 @@ static int socket_packet_handler(connection_t *connection, uint16_t packet_type,
|
||||
// init BTstack library
|
||||
int bt_open(void){
|
||||
|
||||
socket_connection_int();
|
||||
|
||||
socket_connection_register_packet_callback(socket_packet_handler);
|
||||
|
||||
// BTdaemon
|
||||
|
@ -1959,15 +1959,7 @@ int main (int argc, char * const * argv){
|
||||
// handle SIGTERM - suggested for launchd
|
||||
signal(SIGTERM, daemon_sigint_handler);
|
||||
|
||||
// TODO: win32 variant
|
||||
#ifndef _WIN32
|
||||
// handle SIGPIPE
|
||||
struct sigaction act;
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigemptyset (&act.sa_mask);
|
||||
act.sa_flags = 0;
|
||||
sigaction (SIGPIPE, &act, NULL);
|
||||
#endif
|
||||
socket_connection_int();
|
||||
|
||||
btstack_control_t * control = NULL;
|
||||
void * config;
|
||||
|
@ -56,8 +56,9 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -137,13 +138,6 @@ static int socket_connection_dummy_handler(connection_t *connection, uint16_t pa
|
||||
return 0;
|
||||
}
|
||||
|
||||
void socket_connection_set_no_sigpipe(int fd){
|
||||
#ifdef HAVE_SO_NOSIGPIPE
|
||||
int set = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
|
||||
void socket_connection_free_connection(connection_t *conn){
|
||||
// remove from run_loop
|
||||
btstack_run_loop_remove_data_source(&conn->ds);
|
||||
@ -292,9 +286,6 @@ static void socket_connection_accept(btstack_data_source_t *socket_ds, btstack_d
|
||||
return;
|
||||
}
|
||||
|
||||
// no sigpipe
|
||||
socket_connection_set_no_sigpipe(fd);
|
||||
|
||||
log_info("socket_connection_accept new connection %u", fd);
|
||||
|
||||
connection_t * connection = socket_connection_register_new_connection(fd);
|
||||
@ -515,15 +506,8 @@ void socket_connection_send_packet(connection_t *conn, uint16_t type, uint16_t c
|
||||
little_endian_store_16(header, 0, type);
|
||||
little_endian_store_16(header, 2, channel);
|
||||
little_endian_store_16(header, 4, size);
|
||||
#if defined(HAVE_SO_NOSIGPIPE) || defined (_WIN32)
|
||||
// BSD Variants like Darwin and iOS
|
||||
write(conn->ds.fd, header, 6);
|
||||
write(conn->ds.fd, packet, size);
|
||||
#else
|
||||
// Linux
|
||||
send(conn->ds.fd, header, 6, MSG_NOSIGNAL);
|
||||
send(conn->ds.fd, packet, size, MSG_NOSIGNAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -620,3 +604,17 @@ int socket_connection_close_unix(connection_t * connection){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init socket connection module
|
||||
*/
|
||||
void socket_connection_init(void){
|
||||
// just ignore broken sockets - NO_SO_SIGPIPE
|
||||
#ifndef _WIN32
|
||||
sig_t result = signal(SIGPIPE, SIG_IGN);
|
||||
if (result)}{
|
||||
log_error("socket_connection_init: failed to ignore SIGPIPE, error: %s", strerror(errno));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +56,11 @@ extern "C" {
|
||||
/** opaque connection type */
|
||||
typedef struct connection connection_t;
|
||||
|
||||
/**
|
||||
* Init socket connection module
|
||||
*/
|
||||
void socket_connection_init(void);
|
||||
|
||||
/**
|
||||
* create socket data_source for socket specified by launchd configuration
|
||||
*/
|
||||
|
@ -56,8 +56,6 @@ AM_CONDITIONAL(HAVE_LIBUSB, [test "x$HAVE_LIBUSB" == "xyes"])
|
||||
echo
|
||||
echo "BTstack configured for HCI $HCI_TRANSPORT Transport"
|
||||
|
||||
HAVE_SO_NOSIGPIPE="no"
|
||||
|
||||
btstack_run_loop_SOURCES="btstack_run_loop_posix.c"
|
||||
case "$host_os" in
|
||||
darwin*)
|
||||
@ -68,7 +66,6 @@ case "$host_os" in
|
||||
REMOTE_DEVICE_DB_SOURCES="btstack_link_key_db_corefoundation.m btstack_device_name_db_corefoundation.m rfcomm_service_db_corefoundation.m"
|
||||
BTSTACK_LINK_KEY_DB_INSTANCE="btstack_link_key_db_corefoundation_instance"
|
||||
BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_corefoundation_instance"
|
||||
HAVE_SO_NOSIGPIPE="yes";
|
||||
;;
|
||||
mingw*)
|
||||
echo "Building on mingw32"
|
||||
@ -113,7 +110,6 @@ fi
|
||||
|
||||
echo "BTSTACK_LINK_KEY_DB: $BTSTACK_LINK_KEY_DB_INSTANCE"
|
||||
echo "BTSTACK_DEVICE_NAME_DB: $BTSTACK_DEVICE_NAME_DB_INSTANCE"
|
||||
echo "HAVE_SO_NOSIGPIPE: $HAVE_SO_NOSIGPIPE"
|
||||
echo
|
||||
echo
|
||||
|
||||
@ -132,11 +128,6 @@ echo >> btstack_config.h
|
||||
echo "// Port related features" >> btstack_config.h
|
||||
echo "#define HAVE_TIME" >> btstack_config.h
|
||||
echo "#define HAVE_MALLOC" >> btstack_config.h
|
||||
if test "x$HAVE_SO_NOSIGPIPE" == xyes ; then
|
||||
echo "#define HAVE_SO_NOSIGPIPE" >> btstack_config.h
|
||||
else
|
||||
echo "// #undef HAVE_SO_NOSIGPIPE" >> btstack_config.h
|
||||
fi
|
||||
echo >> btstack_config.h
|
||||
|
||||
# todo: HAVE -> ENABLE in features below
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_PLATFORM_IPHONE_OS
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_SO_NOSIGPIPE
|
||||
#define HAVE_TIME
|
||||
|
||||
// BTstack features that can be enabled
|
||||
|
@ -8,7 +8,6 @@
|
||||
// Port related features
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_SO_NOSIGPIPE
|
||||
#define HAVE_STDIO
|
||||
#define HAVE_TIME
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
// Port related features
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
// #define HAVE_SO_NOSIGPIPE
|
||||
#define HAVE_TIME
|
||||
|
||||
// BTstack features that can be enabled
|
||||
|
@ -8,7 +8,6 @@
|
||||
// Port related features
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_POSIX_FILE_IO
|
||||
#define HAVE_SO_NOSIGPIPE
|
||||
#define HAVE_STDIO
|
||||
#define HAVE_TIME
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user