Changeset 244 in flair-src for trunk/tools/FlairGCS/src/UdtSocket.cpp


Ignore:
Timestamp:
May 24, 2018, 11:45:33 AM (4 years ago)
Author:
Sanahuja Guillaume
Message:

modifs segfault when closing connection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/UdtSocket.cpp

    r242 r244  
    3939  bool blocking = false;
    4040  if (UDT::setsockopt(socket, 0, UDT_RCVSYN, &blocking, sizeof(bool)) != 0)
    41     printf("UDT::setsockopt error (UDT_RCVSYN)\n");
     41    fprintf(stderr,"UDT::setsockopt error (UDT_RCVSYN)\n");
    4242   
    4343  heartbeat_timer = new QTimer(this);
     
    5757
    5858void UdtSocket::setName(QString name) {
    59   printf("  %s is %s\n",this->name.toLocal8Bit().constData(),name.toLocal8Bit().constData());
     59  fprintf(stderr,"  %s is %s\n",this->name.toLocal8Bit().constData(),name.toLocal8Bit().constData());
    6060  this->name=name;
    6161}
     
    7979  UDT::TRACEINFO perf;
    8080  if (UDT::ERROR == UDT::perfmon(socket, &perf))   {
    81     printf("perfmon: %s\n",UDT::getlasterror().getErrorMessage());
     81    fprintf(stderr,"perfmon: %s\n",UDT::getlasterror().getErrorMessage());
    8282  }/* else {
    83     printf("%s socket stats:\n",name.toLocal8Bit().constData());
    84     printf("total number of sent packets, including retransmissions: %i\n",perf.pktSentTotal);
    85     printf("total number of received packets: %i\n",perf.pktRecvTotal);
    86     printf("total number of lost packets, measured in the sending side: %i\n",perf.pktSndLossTotal);
    87     printf("total number of lost packets, measured in the receiving side: %i\n",perf.pktRcvLossTotal);
    88     printf("total number of retransmitted packets, measured in the sending side: %i\n",perf.pktRetransTotal);
    89     printf("total number of sent ACK packets: %i\n",perf.pktSentACKTotal);
    90     printf("total number of received ACK packets: %i\n",perf.pktRecvACKTotal);
    91     printf("total number of sent NAK packets: %i\n",perf.pktSentNAKTotal);
    92     printf("total number of received NAK packets: %i\n",perf.pktRecvNAKTotal);
    93     printf("round trip time: %fms\n",perf.msRTT);
     83    fprintf(stderr,"%s socket stats:\n",name.toLocal8Bit().constData());
     84    fprintf(stderr,"total number of sent packets, including retransmissions: %i\n",perf.pktSentTotal);
     85    fprintf(stderr,"total number of received packets: %i\n",perf.pktRecvTotal);
     86    fprintf(stderr,"total number of lost packets, measured in the sending side: %i\n",perf.pktSndLossTotal);
     87    fprintf(stderr,"total number of lost packets, measured in the receiving side: %i\n",perf.pktRcvLossTotal);
     88    fprintf(stderr,"total number of retransmitted packets, measured in the sending side: %i\n",perf.pktRetransTotal);
     89    fprintf(stderr,"total number of sent ACK packets: %i\n",perf.pktSentACKTotal);
     90    fprintf(stderr,"total number of received ACK packets: %i\n",perf.pktRecvACKTotal);
     91    fprintf(stderr,"total number of sent NAK packets: %i\n",perf.pktSentNAKTotal);
     92    fprintf(stderr,"total number of received NAK packets: %i\n",perf.pktRecvNAKTotal);
     93    fprintf(stderr,"round trip time: %fms\n",perf.msRTT);
    9494     
    9595  }*/
     
    114114  char *buf = (char *)malloc(buf_size);
    115115  if (!buf) {
    116     printf("error malloc UdtSocket::receiveData buffer\n");
     116    fprintf(stderr,"error malloc UdtSocket::receiveData buffer\n");
    117117    return;
    118118  }
    119119  char *uncompressbuf=(char *)malloc(COMPRESS_CHUNK);
    120120  if (!uncompressbuf) {
    121     printf("error malloc UdtSocket::receiveData uncompress buffer\n");
     121    fprintf(stderr,"error malloc UdtSocket::receiveData uncompress buffer\n");
    122122    free(buf);
    123123    return;
    124124  }
    125   //fprintf(stderr,"receiveData %x\n",thread());
     125  //ffprintf(stderr,stderr,"receiveData %x\n",thread());
    126126 
    127127  while (!stop) {
     
    135135    int eid = UDT::epoll_create();
    136136    if (eid < 0) {
    137       printf("%s: epoll_create error (%s)\n",name.toLocal8Bit().constData(),UDT::getlasterror().getErrorMessage());
     137      fprintf(stderr,"%s: epoll_create error (%s)\n",name.toLocal8Bit().constData(),UDT::getlasterror().getErrorMessage());
    138138    }
    139139
    140140    if (UDT::epoll_add_usock(eid, socket) < 0) {
    141141      if (UDT::getlasterror().getErrorCode() == 5004) {
    142         printf("disconnected from %s\n",name.toLocal8Bit().constData());
     142        fprintf(stderr,"disconnected from %s\n",name.toLocal8Bit().constData());
    143143        heartbeat_timer->stop();
    144144        deleteLater();
    145145        stop=true;;
    146146      } else {
    147         printf("%s: epoll_add_usock error (%s)\n",name.toLocal8Bit().constData(),UDT::getlasterror().getErrorMessage());
     147        fprintf(stderr,"%s: epoll_add_usock error (%s)\n",name.toLocal8Bit().constData(),UDT::getlasterror().getErrorMessage());
    148148      }
    149149    }
     
    155155    if (rv == -1) {
    156156      if (UDT::getlasterror().getErrorCode() != 6003)
    157         printf("prob %i\n", UDT::getlasterror().getErrorCode());
     157        fprintf(stderr,"prob %i\n", UDT::getlasterror().getErrorCode());
    158158    } else if(readfds==socket && num==1 && rv==1) {
    159159       
     
    201201      } else {
    202202        if(UDT::getlasterror().getErrorCode()!=6002)
    203           printf("udt socket:%s %i\n",UDT::getlasterror().getErrorMessage(),size);
     203          fprintf(stderr,"udt socket: %s %i\n",UDT::getlasterror().getErrorMessage(),size);
    204204        //UDT::close(socket);//si deconnecté
    205205        //free(buf);
     
    207207      }
    208208    } else {
    209       printf("udt socket:%s\n",UDT::getlasterror().getErrorMessage());
     209      fprintf(stderr,"udt socket: %s\n",UDT::getlasterror().getErrorMessage());
    210210    }
    211211    UDT::epoll_remove_usock(eid, socket);
     
    220220  qint64 sent = UDT::sendmsg(socket, buf, size, ttl, inOrder);
    221221  if (sent != size) {
    222     printf("%s, error writting to udt (%s)\n",name.toLocal8Bit().constData(), UDT::getlasterror().getErrorMessage());
     222    fprintf(stderr,"%s, error writting to udt (%s)\n",name.toLocal8Bit().constData(), UDT::getlasterror().getErrorMessage());
    223223    if (UDT::getlasterror().getErrorCode() == 2001) {
     224      fprintf(stderr,"%s, closing connection\n",name.toLocal8Bit().constData());
    224225      stop = true;
    225226      heartbeat_timer->stop();
Note: See TracChangeset for help on using the changeset viewer.