Difference for socket/lowlevel.c from version 1.4 to 1.5


version 1.4 version 1.5
Line 1
 
Line 1
   
 /*  /*
  * static char *rcsid_sockets_c =   * static char *rcsid_sockets_c =
  *    "$Id: lowlevel.c,v 1.4 2000/11/08 07:19:37 cvs Exp $";   *    "$Id: lowlevel.c,v 1.5 2001/04/06 00:43:40 michtoen Exp $";
  */   */
   
 /*  /*
Line 105
 
Line 105
     }      }
     /* We already have a partial packet */      /* We already have a partial packet */
     if (sl->len<2) {      if (sl->len<2) {
   #ifdef WIN32 // ***WIN32 SockList_ReadPacket: change read() to recv()
   
    stat=recv(fd, sl->buf + sl->len, 2-sl->len,0);
   
   #else
  do {   do {
      stat=read(fd, sl->buf + sl->len, 2-sl->len);       stat=read(fd, sl->buf + sl->len, 2-sl->len);
  } while ((stat==-1) && (errno==EINTR));   } while ((stat==-1) && (errno==EINTR));
   #endif
  if (stat<0) {   if (stat<0) {
      /* In non blocking mode, EAGAIN is set when there is no       /* In non blocking mode, EAGAIN is set when there is no
       * data available.        * data available.
       */        */
   #ifdef WIN32 // ***WIN32 SockList_ReadPacket: error handling for win32
    if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {
    if(WSAGetLastError() == WSAECONNRESET)
    LOG(llevDebug,"Connection closed by client\n");
    else
    {
    perror("ReadPacket got an error."); //***win32 <- for what is this instead of log?
    LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());
    }
    return -1; // kick this user!
        }
   #else
      if (errno!=EAGAIN && errno!=EWOULDBLOCK) {       if (errno!=EAGAIN && errno!=EWOULDBLOCK) {
  perror("ReadPacket got an error.");   perror("ReadPacket got an error.");
  LOG(llevDebug,"ReadPacket got error %d, returning 0\n",errno);   LOG(llevDebug,"ReadPacket got error %d, returning 0\n",errno);
      }       }
   #endif
      return 0; /*Error */       return 0; /*Error */
  }   }
  if (stat==0) return -1;   if (stat==0) return -1;
Line 137
 
Line 156
  * closing the socket anyways, then reading this extra 100 bytes   * closing the socket anyways, then reading this extra 100 bytes
  * shouldn't hurt.   * shouldn't hurt.
  */   */
   #ifdef WIN32 // ***win32 SockList_ReadPacket: change read() to recv()
    recv(fd, sl->buf+2, 100, 0);
   #else
  read(fd, sl->buf+2, 100);   read(fd, sl->buf+2, 100);
   #endif // end win32
   
  /* return error so the socket is closed */   /* return error so the socket is closed */
  return -1;   return -1;
     }      }
     do {      do {
   #ifdef WIN32 // ***win32 SockList_ReadPacket: change read() to recv()
    stat = recv(fd, sl->buf+ sl->len, toread, 0);
   #else
  do {   do {
      stat = read(fd, sl->buf+ sl->len, toread);       stat = read(fd, sl->buf+ sl->len, toread);
  } while ((stat<0) && (errno==EINTR));   } while ((stat<0) && (errno==EINTR));
   #endif
  if (stat<0) {   if (stat<0) {
   
   #ifdef WIN32 // ***win32 SockList_ReadPacket: change error handling for win32
    if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {
    if(WSAGetLastError() == WSAECONNRESET)
    LOG(llevDebug,"Connection closed by client\n");
    else
    {
    perror("ReadPacket got an error.");
    LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());
    }
    return -1; // kick this user!
        }
   #else
      if (errno!=EAGAIN && errno!=EWOULDBLOCK) {       if (errno!=EAGAIN && errno!=EWOULDBLOCK) {
  perror("ReadPacket got an error.");   perror("ReadPacket got an error.");
  LOG(llevDebug,"ReadPacket got error %d, returning 0\n",errno);   LOG(llevDebug,"ReadPacket got error %d, returning 0\n",errno);
      }       }
   #endif
      return 0; /*Error */       return 0; /*Error */
  }   }
  if (stat==0) return -1;   if (stat==0) return -1;
Line 231
 
Line 273
  max = SOCKETBUFSIZE - ns->outputbuffer.start;   max = SOCKETBUFSIZE - ns->outputbuffer.start;
  if (ns->outputbuffer.len<max) max = ns->outputbuffer.len;   if (ns->outputbuffer.len<max) max = ns->outputbuffer.len;
   
   #ifdef WIN32 // ***win32 write_socket_buffer: change write() to send()
    amt=send(ns->fd, ns->outputbuffer.data + ns->outputbuffer.start, max,0);
   #else
  do {   do {
      amt=write(ns->fd, ns->outputbuffer.data + ns->outputbuffer.start, max);       amt=write(ns->fd, ns->outputbuffer.data + ns->outputbuffer.start, max);
  } while ((amt<0) && (errno==EINTR));   } while ((amt<0) && (errno==EINTR));
   #endif
   
  if (amt < 0) { /* We got an error */   if (amt < 0) { /* We got an error */
   
   #ifdef WIN32 // ***win32 write_socket_buffer: change error handling
    if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {
    LOG(llevError,"New socket write failed (wsb) (%d).\n", WSAGetLastError());
   #else
      if (errno != EWOULDBLOCK) {       if (errno != EWOULDBLOCK) {
  LOG(llevError,"New socket write failed (%d: %s).\n",   LOG(llevError,"New socket write failed (wsb) (%d: %s).\n",
      errno, strerror_local(errno));       errno, strerror_local(errno));
   #endif
  ns->status=Ns_Dead;   ns->status=Ns_Dead;
  return;   return;
      }       }
Line 282
 
Line 333
     /* If we manage to write more than we wanted, take it as a bonus */      /* If we manage to write more than we wanted, take it as a bonus */
     while (len>0) {      while (len>0) {
   
   #ifdef WIN32 // ***win32 Write_To_Socket: change write() to send()
        amt=send(ns->fd, pos, len,0);
   #else
  do {   do {
      amt=write(ns->fd, pos, len);       amt=write(ns->fd, pos, len);
  } while ((amt<0) && (errno==EINTR));   } while ((amt<0) && (errno==EINTR));
   #endif
   
  if (amt < 0) { /* We got an error */   if (amt < 0) { /* We got an error */
   #ifdef WIN32 // ***win32 Write_To_Socket: change error handling
    if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {
    LOG(llevError,"New socket write failed WTS (%d).\n",WSAGetLastError());
   #else
      if (errno != EWOULDBLOCK) {       if (errno != EWOULDBLOCK) {
  LOG(llevError,"New socket write failed (%d: %s).\n",   LOG(llevError,"New socket write failed WTS (%d: %s).\n", // ---WIN32
      errno, strerror_local(errno));       errno, strerror_local(errno));
   #endif
  ns->status=Ns_Dead;   ns->status=Ns_Dead;
  return;   return;
      }       }


Legend:
line(s) removed in v.1.4 
line(s) changed
 line(s) added in v.1.5

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:36