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


version 1.5 version 1.6
Line 1
 
Line 1
   
 /*  /*
  * static char *rcsid_sockets_c =   * static char *rcsid_sockets_c =
  *    "$Id: lowlevel.c,v 1.5 2001/04/06 00:43:40 michtoen Exp $";   *    "$Id: lowlevel.c,v 1.6 2001/04/06 19:08:08 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()  #ifdef WIN32 /* ***WIN32 SockList_ReadPacket: change read() to recv() */
   
  stat=recv(fd, sl->buf + sl->len, 2-sl->len,0);   stat=recv(fd, sl->buf + sl->len, 2-sl->len,0);
   
Line 118
 
Line 118
      /* 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  #ifdef WIN32 /* ***WIN32 SockList_ReadPacket: error handling for win32 */
  if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {   if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {
  if(WSAGetLastError() == WSAECONNRESET)   if(WSAGetLastError() == WSAECONNRESET)
  LOG(llevDebug,"Connection closed by client\n");   LOG(llevDebug,"Connection closed by client\n");
  else   else
  {   {
  perror("ReadPacket got an error."); //***win32 <- for what is this instead of log?   perror("ReadPacket got an error."); /* ***win32 <- for what is this instead of log? */
  LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());   LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());
  }   }
  return -1; // kick this user!   return -1; /* kick this user! */
      }       }
 #else  #else
  if (errno != EAGAIN && errno !=EWOULDBLOCK) {   if (errno != EAGAIN && errno !=EWOULDBLOCK) {
Line 156
 
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()  #ifdef WIN32 /* ***win32 SockList_ReadPacket: change read() to recv() */
  recv(fd, sl->buf+2, 100, 0);   recv(fd, sl->buf+2, 100, 0);
 #else  #else
  read(fd, sl->buf+2, 100);   read(fd, sl->buf+2, 100);
 #endif // end win32  #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()  #ifdef WIN32 /* ***win32 SockList_ReadPacket: change read() to recv() */
  stat = recv(fd, sl->buf+ sl->len, toread, 0);   stat = recv(fd, sl->buf+ sl->len, toread, 0);
 #else  #else
  do {   do {
Line 175
 
Line 175
 #endif  #endif
  if (stat<0) {   if (stat<0) {
   
 #ifdef WIN32 // ***win32 SockList_ReadPacket: change error handling for win32  #ifdef WIN32 /* ***win32 SockList_ReadPacket: change error handling for win32 */
  if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {   if ((stat==-1) && WSAGetLastError() !=WSAEWOULDBLOCK) {
  if(WSAGetLastError() == WSAECONNRESET)   if(WSAGetLastError() == WSAECONNRESET)
  LOG(llevDebug,"Connection closed by client\n");   LOG(llevDebug,"Connection closed by client\n");
Line 184
 
Line 184
  perror("ReadPacket got an error.");   perror("ReadPacket got an error.");
  LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());   LOG(llevDebug,"ReadPacket got error %d, returning 0\n",WSAGetLastError());
  }   }
  return -1; // kick this user!   return -1; /* kick this user! */
      }       }
 #else  #else
  if (errno != EAGAIN && errno !=EWOULDBLOCK) {   if (errno != EAGAIN && errno !=EWOULDBLOCK) {
Line 273
 
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()  #ifdef WIN32 /* ***win32 write_socket_buffer: change write() to send() */
  amt=send(ns->fd, ns->outputbuffer.data + ns->outputbuffer.start, max,0);   amt=send(ns->fd, ns->outputbuffer.data + ns->outputbuffer.start, max,0);
 #else  #else
  do {   do {
Line 283
 
Line 283
   
  if (amt < 0) { /* We got an error */   if (amt < 0) { /* We got an error */
   
 #ifdef WIN32 // ***win32 write_socket_buffer: change error handling  #ifdef WIN32 /* ***win32 write_socket_buffer: change error handling */
  if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {   if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {
  LOG(llevError,"New socket write failed (wsb) (%d).\n", WSAGetLastError());   LOG(llevError,"New socket write failed (wsb) (%d).\n", WSAGetLastError());
 #else  #else
Line 333
 
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()  #ifdef WIN32 /* ***win32 Write_To_Socket: change write() to send() */
      amt=send(ns->fd, pos, len,0);       amt=send(ns->fd, pos, len,0);
 #else  #else
  do {   do {
Line 342
 
Line 342
 #endif  #endif
   
  if (amt < 0) { /* We got an error */   if (amt < 0) { /* We got an error */
 #ifdef WIN32 // ***win32 Write_To_Socket: change error handling  #ifdef WIN32 /* ***win32 Write_To_Socket: change error handling */
  if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {   if (amt == -1 && WSAGetLastError() !=WSAEWOULDBLOCK) {
  LOG(llevError,"New socket write failed WTS (%d).\n",WSAGetLastError());   LOG(llevError,"New socket write failed WTS (%d).\n",WSAGetLastError());
 #else  #else
  if (errno !=EWOULDBLOCK) {   if (errno !=EWOULDBLOCK) {
  LOG(llevError,"New socket write failed WTS (%d: %s).\n", // ---WIN32   LOG(llevError,"New socket write failed WTS (%d: %s).\n", /* ---WIN32 */
      errno, strerror_local(errno));       errno, strerror_local(errno));
 #endif  #endif
  ns->status=Ns_Dead;   ns->status=Ns_Dead;


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

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