Changeset 5061:df215e585134 in roaraudio


Ignore:
Timestamp:
06/17/11 22:12:21 (10 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added control connection to select() to detect errors without waiting for the timeout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/simple.c

    r5024 r5061  
    164164#endif 
    165165#ifdef ROAR_HAVE_SELECT 
     166 int confh; 
    166167 fd_set fds; 
    167168 struct timeval timeout = {10, 0}; 
     
    276277   FD_SET(listen, &fds); 
    277278 
    278    if ( select(listen + 1, &fds, &fds, &fds, &timeout) < 1 ) { 
     279   confh = roar_get_connection_fh(con); 
     280 
     281   if ( confh != -1 ) { 
     282    FD_SET(confh, &fds); 
     283   } 
     284 
     285   if ( select((confh > listen ? confh : listen) + 1, &fds, &fds, &fds, &timeout) < 1 ) { 
    279286    close(listen); 
    280287 
     
    289296   } 
    290297 
    291    if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 
    292     /* errr, do we need we any error handling here? */ 
     298   if ( FD_ISSET(listen, &fds) ) { 
     299    if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 
     300     /* errr, do we need we any error handling here? */ 
     301    } 
     302   } else { 
     303    // we don't need to check the content as we know it failed... 
     304    if ( roar_recv_message(con, &mes, NULL) == -1 ) 
     305     return -1; 
     306 
     307    if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
     308     return -1; 
     309 
     310    return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir); 
    293311   } 
    294312   if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
     
    335353*/ 
    336354 
    337  if ( dir == ROAR_DIR_PLAY ) { 
    338   (void)ROAR_SHUTDOWN(fh, SHUT_RD); 
    339  } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 
    340   (void)ROAR_SHUTDOWN(fh, SHUT_WR); 
     355 if ( fh != -1 ) { 
     356  if ( dir == ROAR_DIR_PLAY ) { 
     357   (void)ROAR_SHUTDOWN(fh, SHUT_RD); 
     358  } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 
     359   (void)ROAR_SHUTDOWN(fh, SHUT_WR); 
     360  } 
    341361 } 
    342362 
Note: See TracChangeset for help on using the changeset viewer.