Changeset 5608:584b36c566e2 in roaraudio for roard


Ignore:
Timestamp:
07/31/12 15:31:35 (7 years ago)
Author:
phi
Branch:
default
Message:

Handle super long client names well (Closes: #286)

Location:
roard
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r5607 r5608  
    758758  return -1; 
    759759 
    760  roar_connect_fh(&con, ROAR_CLIENT(cs)->fh); 
     760 if ( roar_connect_fh(&con, ROAR_CLIENT(cs)->fh) == -1 ) { 
     761  ROAR_WARN("clients_check(id=%i): Can not create con object for client: %s", id, roar_errorstring); 
     762 } 
    761763 
    762764 ROAR_DBG("clients_check(id=%i): c->proto=%i", id, ROAR_CLIENT(cs)->proto); 
     
    802804    } else { 
    803805     roar_notify_core_emit_simple(event, id, -1, -1, m.cmd, -1, NULL, 0); 
    804      roar_send_message(&con, &m, flags[1] & COMMAND_FLAG_OUT_LONGDATA ? data : NULL); 
     806     if ( roar_send_message(&con, &m, flags[1] & COMMAND_FLAG_OUT_LONGDATA ? data : NULL) == -1 ) { 
     807      ROAR_WARN("clients_check(id=%i): Can not send answer to client: %s", id, roar_errorstring); 
     808     } 
    805809    } 
    806810 
    807811    if ( flags[1] & COMMAND_FLAG_OUT_CLOSECON ) 
    808812     clients_close(id, 1); 
     813 
     814    if ( flags[1] & COMMAND_FLAG_OUT_DELETE ) 
     815     clients_delete(id); 
    809816 
    810817   break; 
  • roard/commands.c

    r5381 r5608  
    4848 
    4949  {ROAR_CMD_EXEC_STREAM,  _NAME("EXEC_STREAM"),  req_on_exec_stream,  ACCLEV_PWRUSER}, 
    50   {ROAR_CMD_QUIT,         _NAME("QUIT"),         (int(*)(int client, struct roar_message * mes, char ** data, uint32_t flags[2]))clients_delete, ACCLEV_NONE}, 
     50  {ROAR_CMD_QUIT,         _NAME("QUIT"),         req_on_quit, ACCLEV_NONE}, 
    5151 
    5252  {ROAR_CMD_CON_STREAM,   _NAME("CON_STREAM"),   req_on_con_stream,   ACCLEV_PWRUSER}, 
  • roard/include/commands.h

    r5381 r5608  
    3636#define COMMAND_FLAG_OUT_LONGDATA  0x00000002 
    3737#define COMMAND_FLAG_OUT_NOSEND    0x00000004 
     38#define COMMAND_FLAG_OUT_DELETE    0x00000008 /* delete the client */ 
    3839 
    3940struct roar_command { 
  • roard/include/req.h

    r5381 r5608  
    3030 
    3131int req_on_noop        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
     32int req_on_quit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
    3233 
    3334int req_on_identify    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
  • roard/req.c

    r5586 r5608  
    8181} 
    8282 
     83int req_on_quit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 
     84 (void)client, (void)data; 
     85 mes->cmd     = ROAR_CMD_OK; 
     86 mes->pos     = g_pos; 
     87 mes->datalen = 0; 
     88 flags[1] |= COMMAND_FLAG_OUT_DELETE; 
     89 return 0; 
     90} 
     91 
    8392int req_on_identify    (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 
    8493 struct roar_client_server * cs; 
     
    10671076int req_on_get_client  (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 
    10681077 struct roar_client * c; 
     1078 int ret; 
    10691079 
    10701080 if ( mes->datalen != 1 ) 
    10711081  return -1; 
    10721082 
     1083 if ( *data != NULL ) 
     1084  roar_mm_free(*data); 
     1085 *data = NULL; 
     1086 
    10731087 if ( clients_get(mes->data[0], &c) == -1 ) 
    10741088  return -1; 
     
    10761090 mes->cmd = ROAR_CMD_OK; 
    10771091 
    1078  return roar_ctl_c2m(mes, c); 
     1092 ret = roar_ctl_c2m2(mes, c, data); 
     1093 
     1094 if ( *data != NULL ) 
     1095  flags[1] |= COMMAND_FLAG_OUT_LONGDATA; 
     1096 
     1097 return ret; 
    10791098} 
    10801099 
Note: See TracChangeset for help on using the changeset viewer.