extract socket_connection_create_launchd from unix part

This commit is contained in:
matthias.ringwald 2010-03-02 20:58:27 +00:00
parent 0f1a967503
commit 46acae3723
4 changed files with 21 additions and 10 deletions

View File

@ -7,6 +7,7 @@ NEXT:
- BUG: bt_close crashes when used in CocoaTouch app - BUG: bt_close crashes when used in CocoaTouch app
- BUG: BTdaemon crashes on iPhone when CocoaTouch app is closed (sometimes) - BUG: BTdaemon crashes on iPhone when CocoaTouch app is closed (sometimes)
- BUG: malloc warning when BTdaemon is started by launchd - BUG: malloc warning when BTdaemon is started by launchd
- Support TCP socket server on 13333 via launchd in addition to the unix socket
- Provide BTstackManager Objective-C class - Provide BTstackManager Objective-C class
- implement l2cap code - implement l2cap code
- implement rfcomm code - implement rfcomm code

View File

@ -344,13 +344,16 @@ int main (int argc, char * const * argv){
l2cap_register_event_packet_handler(daemon_event_handler); l2cap_register_event_packet_handler(daemon_event_handler);
timeout.process = daemon_no_connections_timeout; timeout.process = daemon_no_connections_timeout;
#ifdef USE_LAUNCHD
socket_connection_create_launchd();
#else
// create server // create server
if (tcp_flag) { if (tcp_flag) {
socket_connection_create_tcp(BTSTACK_PORT); socket_connection_create_tcp(BTSTACK_PORT);
} else { } else {
socket_connection_create_unix(BTSTACK_UNIX); socket_connection_create_unix(BTSTACK_UNIX);
} }
#endif
socket_connection_register_packet_callback(daemon_client_handler); socket_connection_register_packet_callback(daemon_client_handler);
// handle CTRL-c // handle CTRL-c

View File

@ -270,11 +270,10 @@ int socket_connection_create_tcp(int port){
} }
/** /**
* create socket data_source for unix domain socket * create socket data_source for socket specified by launchd configuration
* */ */
int socket_connection_create_unix(char *path){
#ifdef USE_LAUNCHD #ifdef USE_LAUNCHD
int socket_connection_create_launchd(){
launch_data_t sockets_dict, checkin_response; launch_data_t sockets_dict, checkin_response;
launch_data_t checkin_request; launch_data_t checkin_request;
@ -348,8 +347,13 @@ int socket_connection_create_unix(char *path){
} }
launch_data_free(checkin_response); launch_data_free(checkin_response);
}
#endif
#else /**
* create socket data_source for unix domain socket
*/
int socket_connection_create_unix(char *path){
// create data_source_t // create data_source_t
data_source_t *ds = malloc( sizeof(data_source_t)); data_source_t *ds = malloc( sizeof(data_source_t));
@ -389,8 +393,6 @@ int socket_connection_create_unix(char *path){
run_loop_add_data_source(ds); run_loop_add_data_source(ds);
#endif
printf ("Server up and running ...\n"); printf ("Server up and running ...\n");
return 0; return 0;
} }

View File

@ -45,6 +45,11 @@
/** opaque connection type */ /** opaque connection type */
typedef struct connection connection_t; typedef struct connection connection_t;
/**
* create socket data_source for socket specified by launchd configuration
*/
int socket_connection_create_launchd();
/** /**
* create socket for incoming tcp connections * create socket for incoming tcp connections
*/ */