Changeset 5373:8da157c10483 in roaraudio for libroar/basic.c


Ignore:
Timestamp:
12/21/11 19:02:52 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:
  • Updated config structure
  • Added a flag to ask libroar to only connect to local servers
  • Added a way to override fork()
  • added support for +internal
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/basic.c

    r5369 r5373  
    6464 } 
    6565 
    66  // TODO: FIXME: we should move this into the config structure. 
    6766 if ( daemonimage == NULL ) 
     67  daemonimage = roar_libroar_get_config()->daemonimage; 
     68 
     69 // we keep this step to be compatible with older versions. 
     70 if ( daemonimage == NULL || *daemonimage == 0 ) { 
    6871  daemonimage = getenv("ROAR_DAEMONIMAGE"); 
     72  if ( daemonimage != NULL ) { 
     73   ROAR_WARN("_start_server(*): Usage of $ROAR_DAEMONIMAGE is obsolete. Use ROAR_OPTIONS=daemonimage:..."); 
     74  } 
     75 } 
    6976 
    7077 if ( daemonimage == NULL || *daemonimage == 0 ) 
     
    7683 } 
    7784 
    78  r = fork(); 
     85 r = roar_fork(NULL); 
    7986 
    8087 if ( r == -1 ) { // error! 
    81   roar_err_from_errno(); 
    82   ROAR_ERR("roar_socket_open_fork(*): Can not fork: %s", strerror(errno)); 
     88  ROAR_ERR("_start_server(*): Can not fork: %s", roar_error2str(roar_error)); 
    8389  close(socks[0]); 
    8490  close(socks[1]); 
     
    106112 
    107113  // we are still alive? 
    108   ROAR_ERR("roar_socket_open_fork(*): alive after exec(), that's bad!"); 
     114  ROAR_ERR("_start_server(*): alive after exec(), that's bad!"); 
    109115  _exit(1); 
    110116 } else { // we are the parent 
     
    121127 return -1; 
    122128#else 
    123  ROAR_ERR("roar_socket_open_fork(*): There is no UNIX Domain Socket support in win32, download a real OS."); 
     129 ROAR_ERR("_start_server(*): There is no UNIX Domain Socket support in win32, download a real OS."); 
    124130 return -1; 
    125131#endif 
     132} 
     133 
     134static int _connect_internal(struct roar_connection * con, const char * server, int type, int flags, uint_least32_t timeout) { 
     135 struct roar_libroar_config * config = roar_libroar_get_config(); 
     136 struct roar_vio_calls * vio; 
     137 
     138 if ( config->connect_internal != NULL ) { 
     139  vio = config->connect_internal(con, server, type, flags, timeout); 
     140  if ( vio == NULL ) 
     141   return -1; 
     142 
     143  con->viocon = vio; 
     144  con->flags |= ROAR_CON_FLAGS_VIO; 
     145 
     146  return 0; 
     147 } 
     148 
     149 roar_err_set(ROAR_ERROR_BADHOST); 
     150 return -1; 
    126151} 
    127152 
     
    153178 } else if ( !strcmp(server, "+fork") || !strncmp(server, "+fork=", 6) ) { 
    154179  return _start_server(con, server, type, flags, timeout); 
     180 } else if ( !strcmp(server, "+internal") || !strncmp(server, "+internal=", 10) ) { 
     181  return _connect_internal(con, server, type, flags, timeout); 
    155182 } 
    156183 
     
    346373#ifdef ROAR_HAVE_LIBSLP 
    347374 if ( !(config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_NO_SLP) && 
    348       !(flags & ROAR_ENUM_FLAG_NONBLOCK) 
     375      !(flags & ROAR_ENUM_FLAG_NONBLOCK) && 
     376      !(flags & ROAR_ENUM_FLAG_LOCALONLY) 
    349377    ) { 
    350378  if ( (server = roar_slp_find_roard(0)) != NULL ) { 
     
    391419 
    392420int roar_connect     (struct roar_connection * con, const char * server, int flags, uint_least32_t timeout) { 
     421 struct roar_libroar_config * config = roar_libroar_get_config(); 
     422 
    393423 if ( con == NULL ) { 
    394424  roar_err_set(ROAR_ERROR_FAULT); 
     
    400430 
    401431 roar_err_set(ROAR_ERROR_UNKNOWN); 
    402  if ( roar_connect_raw(con, server, flags, timeout) == -1 ) 
    403   return -1; 
    404  
     432 if ( roar_connect_raw(con, server, flags | config->serverflags, timeout) == -1 ) 
     433  return -1; 
     434 
     435 // TODO: this should be moved to be within _connect_server() so it also stores server names of auto located servers. 
    405436 if ( server != NULL ) { 
    406437  con->server_name = roar_mm_strdup(server); 
Note: See TracChangeset for help on using the changeset viewer.