Changeset 5567:6ecf012d7063 in roaraudio for roard/roard.c


Ignore:
Timestamp:
07/16/12 17:02:17 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

roard now tries to auto load missing protocols as plugins (Closes: #275)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/roard.c

    r5566 r5567  
    953953 return 0; 
    954954} 
     955 
     956static int check_listen(void) { 
     957 const struct roard_proto_handle * proto; 
     958 const char * protoname; 
     959 char buffer[80]; 
     960 size_t i, j; 
     961 
     962 for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { 
     963  if ( g_listen[i].used ) { 
     964   proto = clients_get_protohandle(g_listen[i].proto); 
     965   if ( proto != NULL ) 
     966    continue; 
     967   protoname = roar_proto2str(g_listen[i].proto); 
     968   if ( protoname == NULL ) { 
     969    ROAR_ERR("check_listen(void): protocol %i is unknown (protocol ID not assigned?)."); 
     970   } else { 
     971    ROAR_DBG("check_listen(void): Unknown protocol %s(%i) is used.", protoname, g_listen[i].proto); 
     972    snprintf(buffer, sizeof(buffer), "protocol-%s", protoname); 
     973    for (j = 0; buffer[j]; j++) 
     974     buffer[j] = tolower(buffer[j]); 
     975 
     976    ROAR_DBG("check_listen(void): Trying to load plugin \"%s\"", buffer); 
     977    if ( plugins_load(buffer, NULL) == -1 ) { 
     978     ROAR_WARN("check_listen(void): unabled to load plugin: %s: %s", buffer, roar_errorstring); 
     979    } 
     980   } 
     981 
     982   // recheck: 
     983   proto = clients_get_protohandle(g_listen[i].proto); 
     984   if ( proto == NULL ) { 
     985    ROAR_WARN("check_listen(void): Protocol %s(%i) is still unknown. Deleting listen socket.", protoname, g_listen[i].proto); 
     986    roar_vio_close(&(g_listen[i].sock)); 
     987#ifdef ROAR_HAVE_UNIX 
     988    if ( server[i] != NULL ) 
     989     if ( server[i][0] == '/' ) 
     990      unlink(server[i]); 
     991#endif 
     992    g_listen[i].used = 0; 
     993    server[i] = NULL; 
     994   } 
     995  } 
     996 } 
     997 
     998 return 0; 
     999} 
    9551000#endif 
    9561001 
     
    24002445 } 
    24012446 
     2447 if ( check_listen() == -1 ) { 
     2448  ROAR_ERR("Can not check listen sockets. BAD."); 
     2449  return 1; 
     2450 } 
    24022451 
    24032452 // we should handle this on microcontrollers, too. 
Note: See TracChangeset for help on using the changeset viewer.